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
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef ANASAZI_LOCA_MULTIVECTRAITS_H
00043 #define ANASAZI_LOCA_MULTIVECTRAITS_H
00044
00045
00046 #include "AnasaziMultiVecTraits.hpp"
00047
00048
00049 #include "NOX_Abstract_MultiVector.H"
00050
00051 namespace Anasazi {
00052
00062 template <>
00063 class MultiVecTraits<double,NOX::Abstract::MultiVector> {
00064 public:
00065
00067 typedef double ScalarType;
00068
00070 typedef NOX::Abstract::MultiVector MV;
00071
00073
00079 static Teuchos::RCP<MV> Clone( const MV& mv, const int numvecs )
00080 {
00081 return mv.clone(numvecs);
00082 }
00083
00090 static Teuchos::RCP<MV> CloneCopy( const MV& mv )
00091 {
00092 return mv.clone(NOX::DeepCopy);
00093 }
00094
00103 static Teuchos::RCP<MV> CloneCopy( const MV& mv,
00104 const std::vector<int>& index )
00105 {
00106 return mv.subCopy(index);
00107 }
00108
00117 static Teuchos::RCP<MV> CloneView( MV& mv,
00118 const std::vector<int>& index )
00119 {
00120 return mv.subView(index);
00121 }
00122
00132 static Teuchos::RCP<const MV> CloneView( const MV& mv,
00133 const std::vector<int>& index )
00134 {
00135 return mv.subView(index);
00136 }
00137
00139
00141
00143 static int GetVecLength( const MV& mv )
00144 {
00145 return mv.length();
00146 }
00147
00149 static int GetNumberVecs( const MV& mv )
00150 {
00151 return mv.numVectors();
00152 }
00153
00155
00157
00161 static void MvTimesMatAddMv( const ScalarType alpha, const MV& A,
00162 const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
00163 const ScalarType beta, MV& mv )
00164 {
00165 mv.update(Teuchos::NO_TRANS, alpha, A, B, beta);
00166 }
00167
00171 static void MvAddMv( const ScalarType alpha, const MV& A,
00172 const ScalarType beta, const MV& B, MV& mv )
00173 {
00174 mv.update(alpha, A, beta, B);
00175 }
00176
00181 static void MvTransMv( const ScalarType alpha, const MV& A, const MV& mv,
00182 Teuchos::SerialDenseMatrix<int,ScalarType>& B)
00183 {
00184 mv.multiply(alpha, A, B);
00185 }
00186
00192 static void MvDot ( const MV& mv, const MV& A,
00193 std::vector<ScalarType> &b)
00194 {
00195 for (unsigned int i=0; i<b.size(); i++)
00196 b[i] = A[i].innerProduct(mv[i]);
00197 }
00198
00202 static void MvScale ( MV& mv, const ScalarType alpha )
00203 {
00204 mv.scale(alpha);
00205 }
00206
00211 static void MvScale ( MV& mv, const std::vector<ScalarType>& alpha )
00212 {
00213 for (unsigned int i=0; i<alpha.size(); i++)
00214 mv[i].scale(alpha[i]);
00215 }
00216
00218
00219
00225 static void MvNorm( const MV& mv,
00226 std::vector<double> &normvec )
00227 {
00228 mv.norm(normvec);
00229 }
00230
00232
00234
00243 static void SetBlock( const MV& A, const std::vector<int>& index, MV& mv )
00244 {
00245 mv.setBlock(A, index);
00246 }
00247
00251 static void MvRandom( MV& mv )
00252 {
00253 mv.random();
00254 }
00255
00259 static void MvInit( MV& mv,
00260 const ScalarType alpha = 0.0 )
00261 {
00262 mv.init(alpha);
00263 }
00264
00266
00268
00272 static void MvPrint( const MV& mv, ostream& os )
00273 {
00274 mv.print(os);
00275 }
00276
00278 };
00279 }
00280
00281 #endif