00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00033 #ifndef ANASAZI_MULTI_VEC_HPP
00034 #define ANASAZI_MULTI_VEC_HPP
00035
00036 #include "AnasaziConfigDefs.hpp"
00037 #include "AnasaziMultiVecTraits.hpp"
00038
00039 namespace Anasazi {
00040
00041
00052 template <class ScalarType>
00053 class MultiVec {
00054 public:
00055
00057
00058
00059 MultiVec() {};
00060
00062 virtual ~MultiVec () {};
00063
00065
00066
00067
00073 virtual MultiVec<ScalarType> * Clone ( const int numvecs ) const = 0;
00074
00081 virtual MultiVec<ScalarType> * CloneCopy () const = 0;
00082
00090 virtual MultiVec<ScalarType> * CloneCopy ( const std::vector<int>& index ) const = 0;
00091
00099 virtual const MultiVec<ScalarType> * CloneView ( const std::vector<int>& index ) const = 0;
00107 virtual MultiVec<ScalarType> * CloneViewNonConst ( const std::vector<int>& index ) = 0;
00109
00111
00112
00113
00114 virtual int GetVecLength () const = 0;
00115
00117
00118 virtual int GetNumberVecs () const = 0;
00119
00121
00122
00123
00126 virtual void MvTimesMatAddMv ( ScalarType alpha, const MultiVec<ScalarType>& A,
00127 const Teuchos::SerialDenseMatrix<int,ScalarType>& B, ScalarType beta ) = 0;
00128
00132 virtual void MvAddMv ( ScalarType alpha, const MultiVec<ScalarType>& A, ScalarType beta, const MultiVec<ScalarType>& B ) = 0;
00133
00138 virtual void MvTransMv ( ScalarType alpha, const MultiVec<ScalarType>& A, Teuchos::SerialDenseMatrix<int,ScalarType>& B
00139 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00140 , ConjType conj = Anasazi::CONJ
00141 #endif
00142 ) const = 0;
00143
00147 virtual void MvDot ( const MultiVec<ScalarType>& A, std::vector<ScalarType> & b
00148 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00149 , ConjType conj = Anasazi::CONJ
00150 #endif
00151 ) const = 0;
00152
00154
00155
00156
00161 virtual void MvNorm ( std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> & normvec ) const = 0;
00162
00164
00165
00166
00171 virtual void SetBlock ( const MultiVec<ScalarType>& A, const std::vector<int>& index ) = 0;
00172
00176 virtual void MvScale ( ScalarType alpha ) = 0;
00177
00181 virtual void MvScale ( const std::vector<ScalarType>& alpha ) = 0;
00182
00186 virtual void MvRandom () = 0;
00187
00191 virtual void MvInit ( ScalarType alpha ) = 0;
00192
00194
00195
00196
00198 virtual void MvPrint ( std::ostream& os ) const = 0;
00200
00201 };
00202
00203
00205
00206
00207
00209
00218 template<class ScalarType>
00219 class MultiVecTraits<ScalarType,MultiVec<ScalarType> >
00220 {
00221 public:
00222
00224
00225
00230 static Teuchos::RCP<MultiVec<ScalarType> > Clone( const MultiVec<ScalarType>& mv, const int numvecs )
00231 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).Clone(numvecs) ); }
00232
00237 static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv )
00238 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy() ); }
00239
00245 static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00246 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy(index) ); }
00247
00253 static Teuchos::RCP<MultiVec<ScalarType> > CloneViewNonConst( MultiVec<ScalarType>& mv, const std::vector<int>& index )
00254 { return Teuchos::rcp( mv.CloneViewNonConst(index) ); }
00255
00261 static Teuchos::RCP<const MultiVec<ScalarType> > CloneView( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00262 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneView(index) ); }
00263
00265
00267
00268
00270 static int GetVecLength( const MultiVec<ScalarType>& mv )
00271 { return mv.GetVecLength(); }
00272
00274 static int GetNumberVecs( const MultiVec<ScalarType>& mv )
00275 { return mv.GetNumberVecs(); }
00276
00278
00280
00281
00284 static void MvTimesMatAddMv( ScalarType alpha, const MultiVec<ScalarType>& A,
00285 const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
00286 ScalarType beta, MultiVec<ScalarType>& mv )
00287 { mv.MvTimesMatAddMv(alpha, A, B, beta); }
00288
00291 static void MvAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, ScalarType beta, const MultiVec<ScalarType>& B, MultiVec<ScalarType>& mv )
00292 { mv.MvAddMv(alpha, A, beta, B); }
00293
00296 static void MvTransMv( ScalarType alpha, const MultiVec<ScalarType>& A, const MultiVec<ScalarType>& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B
00297 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00298 , ConjType conj = Anasazi::CONJ
00299 #endif
00300 )
00301 { mv.MvTransMv(alpha, A, B
00302 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00303 , conj
00304 #endif
00305 ); }
00306
00309 static void MvDot( const MultiVec<ScalarType>& mv, const MultiVec<ScalarType>& A, std::vector<ScalarType> & b
00310 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00311 , ConjType conj = Anasazi::CONJ
00312 #endif
00313 )
00314 { mv.MvDot( A, b
00315 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00316 , conj
00317 #endif
00318 ); }
00319
00322 static void MvScale ( MultiVec<ScalarType>& mv, ScalarType alpha )
00323 { mv.MvScale( alpha ); }
00324
00327 static void MvScale ( MultiVec<ScalarType>& mv, const std::vector<ScalarType>& alpha )
00328 { mv.MvScale( alpha ); }
00329
00331
00332
00333
00337 static void MvNorm( const MultiVec<ScalarType>& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> & normvec )
00338 { mv.MvNorm(normvec); }
00339
00341
00342
00343
00348 static void SetBlock( const MultiVec<ScalarType>& A, const std::vector<int>& index, MultiVec<ScalarType>& mv )
00349 { mv.SetBlock(A, index); }
00350
00353 static void MvRandom( MultiVec<ScalarType>& mv )
00354 { mv.MvRandom(); }
00355
00358 static void MvInit( MultiVec<ScalarType>& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
00359 { mv.MvInit(alpha); }
00360
00362
00364
00365
00368 static void MvPrint( const MultiVec<ScalarType>& mv, std::ostream& os )
00369 { mv.MvPrint(os); }
00370
00372 };
00373
00374
00375 }
00376
00377 #endif
00378
00379