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
00029 #ifndef BELOS_MULTI_VEC_HPP
00030 #define BELOS_MULTI_VEC_HPP
00031
00036 #include "BelosMultiVecTraits.hpp"
00037 #include "BelosTypes.hpp"
00038 #include "BelosConfigDefs.hpp"
00039
00051 namespace Belos {
00052
00053 template <class ScalarType>
00054 class MultiVec {
00055 public:
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 MultiVec<ScalarType> * CloneView ( const std::vector<int>& index ) = 0;
00101
00103
00104
00105
00106 virtual int GetVecLength () const = 0;
00107
00109
00110 virtual int GetNumberVecs () const = 0;
00111
00113
00114
00115
00118 virtual void MvTimesMatAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A,
00119 const Teuchos::SerialDenseMatrix<int,ScalarType>& B, const ScalarType beta ) = 0;
00120
00124 virtual void MvAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, const ScalarType beta, const MultiVec<ScalarType>& B ) = 0;
00125
00129 virtual void MvScale ( ScalarType alpha ) = 0;
00130
00134 virtual void MvScale ( const std::vector<ScalarType>& alpha ) = 0;
00135
00140 virtual void MvTransMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, Teuchos::SerialDenseMatrix<int,ScalarType>& B) const = 0;
00141
00145 virtual void MvDot ( const MultiVec<ScalarType>& A, std::vector<ScalarType>& b ) const = 0;
00146
00148
00149
00150
00155 virtual void MvNorm ( std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec, NormType type = TwoNorm ) const = 0;
00156
00158
00159
00160
00165 virtual void SetBlock ( const MultiVec<ScalarType>& A, const std::vector<int>& index ) = 0;
00166
00170 virtual void MvRandom () = 0;
00171
00175 virtual void MvInit ( const ScalarType alpha ) = 0;
00176
00178
00179
00180
00182 virtual void MvPrint ( std::ostream& os ) const = 0;
00184 };
00185
00186
00188
00189
00190
00192
00193
00194 template<class ScalarType>
00195 class MultiVecTraits<ScalarType,MultiVec<ScalarType> >
00196 {
00197 public:
00199 static Teuchos::RCP<MultiVec<ScalarType> > Clone( const MultiVec<ScalarType>& mv, const int numvecs )
00200 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).Clone(numvecs) ); }
00202 static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv )
00203 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy() ); }
00205 static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00206 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy(index) ); }
00208 static Teuchos::RCP<MultiVec<ScalarType> > CloneView( MultiVec<ScalarType>& mv, const std::vector<int>& index )
00209 { return Teuchos::rcp( mv.CloneView(index) ); }
00211 static Teuchos::RCP<const MultiVec<ScalarType> > CloneView( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00212 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneView(index) ); }
00214 static int GetVecLength( const MultiVec<ScalarType>& mv )
00215 { return mv.GetVecLength(); }
00217 static int GetNumberVecs( const MultiVec<ScalarType>& mv )
00218 { return mv.GetNumberVecs(); }
00220 static void MvTimesMatAddMv( ScalarType alpha, const MultiVec<ScalarType>& A,
00221 const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
00222 ScalarType beta, MultiVec<ScalarType>& mv )
00223 { mv.MvTimesMatAddMv(alpha, A, B, beta); }
00225 static void MvAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, ScalarType beta, const MultiVec<ScalarType>& B, MultiVec<ScalarType>& mv )
00226 { mv.MvAddMv(alpha, A, beta, B); }
00228 static void MvTransMv( ScalarType alpha, const MultiVec<ScalarType>& A, const MultiVec<ScalarType>& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B )
00229 { mv.MvTransMv(alpha, A, B); }
00231 static void MvDot( const MultiVec<ScalarType>& mv, const MultiVec<ScalarType>& A, std::vector<ScalarType>& b )
00232 { mv.MvDot( A, b ); }
00234 static void MvNorm( const MultiVec<ScalarType>& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec, NormType type = TwoNorm )
00235 { mv.MvNorm(normvec,type); }
00237 static void SetBlock( const MultiVec<ScalarType>& A, const std::vector<int>& index, MultiVec<ScalarType>& mv )
00238 { mv.SetBlock(A, index); }
00240 static void MvRandom( MultiVec<ScalarType>& mv )
00241 { mv.MvRandom(); }
00243 static void MvInit( MultiVec<ScalarType>& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
00244 { mv.MvInit(alpha); }
00246 static void MvPrint( const MultiVec<ScalarType>& mv, std::ostream& os )
00247 { mv.MvPrint(os); }
00248
00249 };
00250
00251
00252 }
00253
00254 #endif
00255
00256