Anasazi  Version of the Day
AnasaziMultiVecTraits.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Anasazi: Block Eigensolvers Package
5 // Copyright 2004 Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 //
42 #ifndef ANASAZI_MULTI_VEC_TRAITS_HPP
43 #define ANASAZI_MULTI_VEC_TRAITS_HPP
44 
55 
56 #include "AnasaziTypes.hpp"
58 #include "Teuchos_Range1D.hpp"
59 #include "Teuchos_RCP.hpp"
60 #include "Teuchos_SerialDenseMatrix.hpp"
61 
62 namespace Anasazi {
63 
70  template< class ScalarType, class MV >
72  {
79  static inline ScalarType notDefined() { return MV::this_type_is_missing_a_specialization(); };
80  };
81 
82 
126  template<class ScalarType, class MV>
128  public:
130 
131 
136  static Teuchos::RCP<MV> Clone( const MV& mv, const int numvecs )
137  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
138 
143  static Teuchos::RCP<MV> CloneCopy( const MV& mv )
144  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
145 
151  static Teuchos::RCP<MV> CloneCopy( const MV& mv, const std::vector<int>& index )
152  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
153 
163  static Teuchos::RCP<MV> CloneCopy( const MV& mv, const Teuchos::Range1D& index )
164  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
165 
171  static Teuchos::RCP<MV> CloneViewNonConst( MV& mv, const std::vector<int>& index )
172  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
173 
182  static Teuchos::RCP<MV> CloneViewNonConst( MV& mv, const Teuchos::Range1D& index )
183  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
184 
190  static Teuchos::RCP<const MV> CloneView( const MV& mv, const std::vector<int>& index )
191  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
192 
201  static Teuchos::RCP<const MV> CloneView( const MV& mv, const Teuchos::Range1D& index )
202  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
203 
205 
207 
208 
210  static ptrdiff_t GetGlobalLength( const MV& mv )
212 
214  static int GetNumberVecs( const MV& mv )
216 
218 
220 
221 
224  static void MvTimesMatAddMv( const ScalarType alpha, const MV& A,
225  const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
226  const ScalarType beta, MV& mv )
228 
231  static void MvAddMv( const ScalarType alpha, const MV& A, const ScalarType beta, const MV& B, MV& mv )
233 
236  static void MvScale ( MV& mv, const ScalarType alpha )
238 
241  static void MvScale ( MV& mv, const std::vector<ScalarType>& alpha )
243 
247  static void
248  MvTransMv (const ScalarType alpha, const MV& A, const MV& B,
249  Teuchos::SerialDenseMatrix<int,ScalarType>& C)
251 
254  static void MvDot ( const MV& mv, const MV& A, std::vector<ScalarType> &b)
256 
258 
260 
264  static void MvNorm( const MV& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &normvec )
266 
268 
270 
271 
276  static void SetBlock( const MV& A, const std::vector<int>& index, MV& mv )
278 
291  static void SetBlock( const MV& A, const Teuchos::Range1D& index, MV& mv )
293 
297  static void Assign( const MV& A, MV& mv )
299 
302  static void MvRandom( MV& mv )
304 
307  static void MvInit( MV& mv, const ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
309 
311 
313 
314 
317  static void MvPrint( const MV& mv, std::ostream& os )
319 
321 
322 #ifdef HAVE_ANASAZI_TSQR
335  typedef Anasazi::details::StubTsqrAdapter<MV> tsqr_adaptor_type;
336 #endif // HAVE_ANASAZI_TSQR
337  };
338 
339 } // namespace Anasazi
340 
341 #endif // ANASAZI_MULTI_VEC_TRAITS_HPP
"Stub" TSQR adapter for unsupported multivector types.
Types and exceptions used within Anasazi solvers and interfaces.
Traits class which defines basic operations on multivectors.
static int GetNumberVecs(const MV &mv)
Obtain the number of vectors in mv.
static Teuchos::RCP< MV > CloneCopy(const MV &mv, const Teuchos::Range1D &index)
Deep copy of specified columns of mv.
static void MvAddMv(const ScalarType alpha, const MV &A, const ScalarType beta, const MV &B, MV &mv)
Replace mv with .
static void MvPrint(const MV &mv, std::ostream &os)
Print the mv multi-vector to the os output stream.
static void MvDot(const MV &mv, const MV &A, std::vector< ScalarType > &b)
Compute a vector b where the components are the individual dot-products of the i-th columns of A and ...
static void MvScale(MV &mv, const std::vector< ScalarType > &alpha)
Scale each element of the i-th vector in mv with alpha[i].
static void MvInit(MV &mv, const ScalarType alpha=Teuchos::ScalarTraits< ScalarType >::zero())
Replace each element of the vectors in mv with alpha.
static void MvScale(MV &mv, const ScalarType alpha)
Scale each element of the vectors in mv with alpha.
static Teuchos::RCP< MV > Clone(const MV &mv, const int numvecs)
Creates a new empty MV containing numvecs columns.
static void SetBlock(const MV &A, const Teuchos::Range1D &index, MV &mv)
Deep copy of A into specified columns of mv.
static void Assign(const MV &A, MV &mv)
mv := A
static Teuchos::RCP< const MV > CloneView(const MV &mv, const std::vector< int > &index)
Creates a new const MV that shares the selected contents of mv (shallow copy).
static ptrdiff_t GetGlobalLength(const MV &mv)
Return the number of rows in the given multivector mv.
static Teuchos::RCP< const MV > CloneView(const MV &mv, const Teuchos::Range1D &index)
Const view of specified columns of mv.
static void MvTransMv(const ScalarType alpha, const MV &A, const MV &B, Teuchos::SerialDenseMatrix< int, ScalarType > &C)
Compute C := alpha * A^H B.
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const Teuchos::Range1D &index)
Non-const view of specified columns of mv.
static void MvRandom(MV &mv)
Replace the vectors in mv with random vectors.
static Teuchos::RCP< MV > CloneCopy(const MV &mv, const std::vector< int > &index)
Creates a new MV and copies the selected contents of mv into the new vector (deep copy).
static void MvTimesMatAddMv(const ScalarType alpha, const MV &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta, MV &mv)
Update mv with .
static void MvNorm(const MV &mv, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec)
Compute the 2-norm of each individual vector of mv. Upon return, normvec[i] holds the value of ,...
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const std::vector< int > &index)
Creates a new MV that shares the selected contents of mv (shallow copy).
static void SetBlock(const MV &A, const std::vector< int > &index, MV &mv)
Copy the vectors in A to a set of vectors in mv indicated by the indices given in index.
static Teuchos::RCP< MV > CloneCopy(const MV &mv)
Creates a new MV and copies contents of mv into the new vector (deep copy).
"Stub" TSQR adaptor for unsupported multivector types.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.
Used by MultiVecTraits to report lack of a specialization.
static ScalarType notDefined()
Any attempt to compile this method will result in a compile-time error.