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, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
25 //
26 // ***********************************************************************
27 // @HEADER
28 //
29 #ifndef ANASAZI_MULTI_VEC_TRAITS_HPP
30 #define ANASAZI_MULTI_VEC_TRAITS_HPP
31 
42 
43 #include "AnasaziTypes.hpp"
45 #include "Teuchos_Range1D.hpp"
46 #include "Teuchos_RCP.hpp"
47 #include "Teuchos_SerialDenseMatrix.hpp"
48 
49 namespace Anasazi {
50 
57  template< class ScalarType, class MV >
59  {
66  static inline ScalarType notDefined() { return MV::this_type_is_missing_a_specialization(); };
67  };
68 
69 
113  template<class ScalarType, class MV>
115  public:
117 
118 
123  static Teuchos::RCP<MV> Clone( const MV& mv, const int numvecs )
124  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
125 
130  static Teuchos::RCP<MV> CloneCopy( const MV& mv )
131  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
132 
138  static Teuchos::RCP<MV> CloneCopy( const MV& mv, const std::vector<int>& index )
139  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
140 
150  static Teuchos::RCP<MV> CloneCopy( const MV& mv, const Teuchos::Range1D& index )
151  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
152 
158  static Teuchos::RCP<MV> CloneViewNonConst( MV& mv, const std::vector<int>& index )
159  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
160 
169  static Teuchos::RCP<MV> CloneViewNonConst( MV& mv, const Teuchos::Range1D& index )
170  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
171 
177  static Teuchos::RCP<const MV> CloneView( const MV& mv, const std::vector<int>& index )
178  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
179 
188  static Teuchos::RCP<MV> CloneView( MV& mv, const Teuchos::Range1D& index )
189  { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
190 
192 
194 
195 
197  static ptrdiff_t GetGlobalLength( const MV& mv )
199 
201  static int GetNumberVecs( const MV& mv )
203 
205 
207 
208 
211  static void MvTimesMatAddMv( const ScalarType alpha, const MV& A,
212  const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
213  const ScalarType beta, MV& mv )
215 
218  static void MvAddMv( const ScalarType alpha, const MV& A, const ScalarType beta, const MV& B, MV& mv )
220 
223  static void MvScale ( MV& mv, const ScalarType alpha )
225 
228  static void MvScale ( MV& mv, const std::vector<ScalarType>& alpha )
230 
234  static void
235  MvTransMv (const ScalarType alpha, const MV& A, const MV& B,
236  Teuchos::SerialDenseMatrix<int,ScalarType>& C)
238 
241  static void MvDot ( const MV& mv, const MV& A, std::vector<ScalarType> &b)
243 
245 
247 
251  static void MvNorm( const MV& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &normvec )
253 
255 
257 
258 
263  static void SetBlock( const MV& A, const std::vector<int>& index, MV& mv )
265 
278  static void SetBlock( const MV& A, const Teuchos::Range1D& index, MV& mv )
280 
284  static void Assign( const MV& A, MV& mv )
286 
289  static void MvRandom( MV& mv )
291 
294  static void MvInit( MV& mv, const ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
296 
298 
300 
301 
304  static void MvPrint( const MV& mv, std::ostream& os )
306 
308 
309 #ifdef HAVE_ANASAZI_TSQR
310  typedef Anasazi::details::StubTsqrAdapter<MV> tsqr_adaptor_type;
323 #endif // HAVE_ANASAZI_TSQR
324  };
325 
326 } // namespace Anasazi
327 
328 #endif // ANASAZI_MULTI_VEC_TRAITS_HPP
static ptrdiff_t GetGlobalLength(const MV &mv)
Return the number of rows in the given multivector mv.
static void MvInit(MV &mv, const ScalarType alpha=Teuchos::ScalarTraits< ScalarType >::zero())
Replace each element of the vectors in mv with alpha.
static void MvRandom(MV &mv)
Replace the vectors in mv with random vectors.
static void MvTimesMatAddMv(const ScalarType alpha, const MV &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta, MV &mv)
Update mv with .
static Teuchos::RCP< MV > CloneView(MV &mv, const Teuchos::Range1D &index)
Const view of specified columns of mv.
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 Assign(const MV &A, MV &mv)
mv := A
"Stub" TSQR adapter for unsupported multivector types.
static Teuchos::RCP< MV > CloneCopy(const MV &mv, const Teuchos::Range1D &index)
Deep copy of specified columns of mv.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package...
Used by MultiVecTraits to report lack of a specialization.
Traits class which defines basic operations on multivectors.
static Teuchos::RCP< MV > CloneCopy(const MV &mv)
Creates a new MV and copies contents of mv into the new vector (deep copy).
static void MvTransMv(const ScalarType alpha, const MV &A, const MV &B, Teuchos::SerialDenseMatrix< int, ScalarType > &C)
Compute C := alpha * A^H B.
static void MvScale(MV &mv, const ScalarType alpha)
Scale each element of the vectors in mv with alpha.
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const Teuchos::Range1D &index)
Non-const view of specified columns of mv.
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 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 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< 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 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 void SetBlock(const MV &A, const Teuchos::Range1D &index, MV &mv)
Deep copy of A into specified columns of mv.
static int GetNumberVecs(const MV &mv)
Obtain the number of vectors in mv.
static void MvAddMv(const ScalarType alpha, const MV &A, const ScalarType beta, const MV &B, MV &mv)
Replace mv with .
Types and exceptions used within Anasazi solvers and interfaces.
static void MvPrint(const MV &mv, std::ostream &os)
Print the mv multi-vector to the os output stream.
"Stub" TSQR adaptor for unsupported multivector types.
static ScalarType notDefined()
Any attempt to compile this method will result in a compile-time error.
static void MvScale(MV &mv, const std::vector< ScalarType > &alpha)
Scale each element of the i-th vector in mv with alpha[i].
static Teuchos::RCP< MV > Clone(const MV &mv, const int numvecs)
Creates a new empty MV containing numvecs columns.