47 #ifndef BELOS_MATORTHOMANAGER_HPP 48 #define BELOS_MATORTHOMANAGER_HPP 77 template <
class ScalarType,
class MV,
class OP>
78 class MatOrthoManager :
public OrthoManager<ScalarType,MV> {
80 Teuchos::RCP<const OP>
_Op;
97 void setOp( Teuchos::RCP<const OP> Op ) {
103 Teuchos::RCP<const OP>
getOp()
const {
return _Op; }
116 Teuchos::SerialDenseMatrix<int,ScalarType>& Z )
const {
117 typedef Teuchos::ScalarTraits<ScalarType> SCT;
121 Teuchos::RCP<const MV> P,Q;
126 if ( MVT::GetNumberVecs(X) < MVT::GetNumberVecs(Y) ) {
127 R = MVT::Clone(X,MVT::GetNumberVecs(X));
128 OPT::Apply(*
_Op,X,*R);
130 Q = Teuchos::rcp( &Y,
false );
133 P = Teuchos::rcp( &X,
false );
134 R = MVT::Clone(Y,MVT::GetNumberVecs(Y));
135 OPT::Apply(*
_Op,Y,*R);
140 P = Teuchos::rcp( &X,
false );
141 Q = Teuchos::rcp( &Y,
false );
144 MVT::MvTransMv(SCT::one(),*P,*Q,Z);
153 void innerProd(
const MV& X,
const MV& Y, Teuchos::RCP<const MV> MY,
154 Teuchos::SerialDenseMatrix<int,ScalarType>& Z )
const {
155 typedef Teuchos::ScalarTraits<ScalarType> SCT;
158 Teuchos::RCP<MV> P,Q;
160 if ( MY == Teuchos::null ) {
165 MVT::MvTransMv(SCT::one(),X,*MY,Z);
169 MVT::MvTransMv(SCT::one(),X,Y,Z);
175 void norm(
const MV& X, std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType >& normvec )
const {
176 norm(X,Teuchos::null,normvec);
198 Teuchos::RCP<const MV> MX,
199 std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec)
const 201 typedef Teuchos::ScalarTraits<ScalarType> SCT;
202 typedef Teuchos::ScalarTraits<typename SCT::magnitudeType> MT;
206 int nvecs = MVT::GetNumberVecs(X);
212 if (normvec.size() <
static_cast<size_t>(nvecs))
213 normvec.resize (nvecs);
217 MX = Teuchos::rcp(&X,
false);
218 MVT::MvNorm(X, normvec);
225 if(MX == Teuchos::null) {
226 Teuchos::RCP<MV> tempVec = MVT::Clone(X,nvecs);
227 OPT::Apply(*
_Op,X,*tempVec);
233 const int numColsMX = MVT::GetNumberVecs(*MX);
234 TEUCHOS_TEST_FOR_EXCEPTION(numColsMX < nvecs, std::invalid_argument,
235 "MatOrthoManager::norm(X, MX, normvec): " 236 "MX has fewer columns than X: " 237 "MX has " << numColsMX <<
" columns, " 238 "and X has " << nvecs <<
" columns.");
241 std::vector<ScalarType> dotvec(nvecs);
242 MVT::MvDot(X,*MX,dotvec);
243 for (
int i=0; i<nvecs; i++) {
244 normvec[i] = MT::squareroot( SCT::magnitude(dotvec[i]) );
271 virtual void project ( MV &X, Teuchos::RCP<MV> MX,
272 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
273 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const = 0;
280 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
281 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const {
306 virtual int normalize ( MV &X, Teuchos::RCP<MV> MX,
307 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B )
const = 0;
312 virtual int normalize ( MV &X, Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B )
const {
321 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
322 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B,
323 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const = 0;
327 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
328 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B,
329 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 373 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
374 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B,
375 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 386 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
394 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
399 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
408 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
409 orthogError(
const MV &X1, Teuchos::RCP<const MV> MX1,
const MV &X2)
const = 0;
Collection of types and exceptions used within the Belos solvers.
int projectAndNormalize(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C, Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
Given a set of bases Q[i] and a multivector X, this method computes an orthonormal basis for ...
void norm(const MV &X, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec) const
Provides the norm induced by innerProd().
Declaration of basic traits for the multivector type.
virtual Teuchos::ScalarTraits< ScalarType >::magnitudeType orthonormError(const MV &X) const
This method computes the error in orthonormality of a multivector.
Teuchos::RCP< const OP > getOp() const
Get operator.
Class which defines basic traits for the operator type.
virtual int normalize(MV &X, Teuchos::RCP< MV > MX, Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B) const =0
This method takes a multivector X and attempts to compute an orthonormal basis for ...
Traits class which defines basic operations on multivectors.
void norm(const MV &X, Teuchos::RCP< const MV > MX, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec) const
Compute norm of each column of X.
Teuchos::RCP< const OP > _Op
virtual ~MatOrthoManager()
Destructor.
virtual int projectAndNormalizeWithMxImpl(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C, Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const =0
virtual void project(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const =0
Given a list of (mutually and internally) orthonormal bases Q, this method takes a multivector X and ...
Templated virtual class for providing orthogonalization/orthonormalization methods.
MatOrthoManager(Teuchos::RCP< const OP > Op=Teuchos::null)
Default constructor.
void innerProd(const MV &X, const MV &Y, Teuchos::RCP< const MV > MY, Teuchos::SerialDenseMatrix< int, ScalarType > &Z) const
Provides the inner product defining the orthogonality concepts, using the provided operator...
virtual int normalize(MV &X, Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B) const
This method calls normalize(X,Teuchos::null,B); see documentation for that function.
virtual void project(MV &X, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
This method calls project(X,Teuchos::null,C,Q); see documentation for that function.
Class which defines basic traits for the operator type.
void innerProd(const MV &X, const MV &Y, Teuchos::SerialDenseMatrix< int, ScalarType > &Z) const
Provides the inner product defining the orthogonality concepts, using the provided operator...
Belos header file which uses auto-configuration information to include necessary C++ headers...
virtual int projectAndNormalizeImpl(MV &X, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C, Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
void setOp(Teuchos::RCP< const OP > Op)
Set operator.
virtual Teuchos::ScalarTraits< ScalarType >::magnitudeType orthogError(const MV &X1, const MV &X2) const
This method computes the error in orthogonality of two multivectors. This method. ...