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
00032 #include "BelosMultiVecTraits.hpp"
00033 #include "BelosTypes.hpp"
00034 #include "BelosConfigDefs.hpp"
00035
00047 namespace Belos {
00048
00049 template <class ScalarType>
00050 class MultiVec {
00051 public:
00053
00054
00055 MultiVec() {};
00056
00058 virtual ~MultiVec () {};
00059
00061
00062
00063
00069 virtual MultiVec<ScalarType> * Clone ( const int numvecs ) const = 0;
00070
00077 virtual MultiVec<ScalarType> * CloneCopy () const = 0;
00078
00086 virtual MultiVec<ScalarType> * CloneCopy ( const std::vector<int>& index ) const = 0;
00087
00095 virtual MultiVec<ScalarType> * CloneView ( const std::vector<int>& index ) = 0;
00097
00099
00100
00101
00102 virtual int GetVecLength () const = 0;
00103
00105
00106 virtual int GetNumberVecs () const = 0;
00107
00109
00110
00111
00114 virtual void MvTimesMatAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A,
00115 const Teuchos::SerialDenseMatrix<int,ScalarType>& B, const ScalarType beta ) = 0;
00116
00120 virtual void MvAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, const ScalarType beta, const MultiVec<ScalarType>& B ) = 0;
00121
00126 virtual void MvTransMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, Teuchos::SerialDenseMatrix<int,ScalarType>& B) const = 0;
00127
00131 virtual void MvDot ( const MultiVec<ScalarType>& A, std::vector<ScalarType>* b ) const = 0;
00132
00134
00135
00136
00141 virtual void MvNorm ( std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>* normvec, NormType type = TwoNorm ) const = 0;
00142
00144
00145
00146
00151 virtual void SetBlock ( const MultiVec<ScalarType>& A, const std::vector<int>& index ) = 0;
00152
00156 virtual void MvRandom () = 0;
00157
00161 virtual void MvInit ( const ScalarType alpha ) = 0;
00162
00164
00165
00166
00168 virtual void MvPrint ( ostream& os ) const = 0;
00170 };
00171
00172
00174
00175
00176
00178
00179
00180 template<class ScalarType>
00181 class MultiVecTraits<ScalarType,MultiVec<ScalarType> >
00182 {
00183 public:
00185 static Teuchos::RefCountPtr<MultiVec<ScalarType> > Clone( const MultiVec<ScalarType>& mv, const int numvecs )
00186 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).Clone(numvecs) ); }
00188 static Teuchos::RefCountPtr<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv )
00189 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy() ); }
00191 static Teuchos::RefCountPtr<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00192 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy(index) ); }
00194 static Teuchos::RefCountPtr<MultiVec<ScalarType> > CloneView( MultiVec<ScalarType>& mv, const std::vector<int>& index )
00195 { return Teuchos::rcp( mv.CloneView(index) ); }
00197 static Teuchos::RefCountPtr<const MultiVec<ScalarType> > CloneView( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00198 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneView(index) ); }
00200 static int GetVecLength( const MultiVec<ScalarType>& mv )
00201 { return mv.GetVecLength(); }
00203 static int GetNumberVecs( const MultiVec<ScalarType>& mv )
00204 { return mv.GetNumberVecs(); }
00206 static void MvTimesMatAddMv( ScalarType alpha, const MultiVec<ScalarType>& A,
00207 const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
00208 ScalarType beta, MultiVec<ScalarType>& mv )
00209 { mv.MvTimesMatAddMv(alpha, A, B, beta); }
00211 static void MvAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, ScalarType beta, const MultiVec<ScalarType>& B, MultiVec<ScalarType>& mv )
00212 { mv.MvAddMv(alpha, A, beta, B); }
00214 static void MvTransMv( ScalarType alpha, const MultiVec<ScalarType>& A, const MultiVec<ScalarType>& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B )
00215 { mv.MvTransMv(alpha, A, B); }
00217 static void MvDot( const MultiVec<ScalarType>& mv, const MultiVec<ScalarType>& A, std::vector<ScalarType>* b )
00218 { mv.MvDot( A, b ); }
00220 static void MvNorm( const MultiVec<ScalarType>& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>* normvec, NormType type = TwoNorm )
00221 { mv.MvNorm(normvec,type); }
00223 static void SetBlock( const MultiVec<ScalarType>& A, const std::vector<int>& index, MultiVec<ScalarType>& mv )
00224 { mv.SetBlock(A, index); }
00226 static void MvRandom( MultiVec<ScalarType>& mv )
00227 { mv.MvRandom(); }
00229 static void MvInit( MultiVec<ScalarType>& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
00230 { mv.MvInit(alpha); }
00232 static void MvPrint( const MultiVec<ScalarType>& mv, ostream& os )
00233 { mv.MvPrint(os); }
00234
00235 };
00236
00237
00238 }
00239
00240 #endif
00241
00242