34 #ifndef ANASAZI_MATORTHOMANAGER_HPP
35 #define ANASAZI_MATORTHOMANAGER_HPP
62 template <
class ScalarType,
class MV,
class OP>
111 const MV& X,
const MV& Y,
300 mutable int _OpCounter;
304 template <
class ScalarType,
class MV,
class OP>
306 : _Op(Op), _hasOp(Op!=Teuchos::null), _OpCounter(0) {}
308 template <
class ScalarType,
class MV,
class OP>
312 _hasOp = (_Op != Teuchos::null);
315 template <
class ScalarType,
class MV,
class OP>
321 template <
class ScalarType,
class MV,
class OP>
327 template <
class ScalarType,
class MV,
class OP>
333 template <
class ScalarType,
class MV,
class OP>
346 if ( MVT::GetNumberVecs(X) < MVT::GetNumberVecs(Y) ) {
347 R = MVT::Clone(X,MVT::GetNumberVecs(X));
348 OPT::Apply(*_Op,X,*R);
349 _OpCounter += MVT::GetNumberVecs(X);
351 Q = Teuchos::rcpFromRef(Y);
354 P = Teuchos::rcpFromRef(X);
355 R = MVT::Clone(Y,MVT::GetNumberVecs(Y));
356 OPT::Apply(*_Op,Y,*R);
357 _OpCounter += MVT::GetNumberVecs(Y);
362 P = Teuchos::rcpFromRef(X);
363 Q = Teuchos::rcpFromRef(Y);
366 MVT::MvTransMv(SCT::one(),*P,*Q,Z);
369 template <
class ScalarType,
class MV,
class OP>
380 if ( MY == Teuchos::null ) {
385 MVT::MvTransMv(SCT::one(),X,*MY,Z);
389 MVT::MvTransMv(SCT::one(),X,Y,Z);
392 for (
int j=0; j<Z.
numCols(); j++) {
393 for (
int i=0; i<Z.
numRows(); i++) {
395 "Anasazi::MatOrthoManager::innerProdMat(): detected NaN/inf.");
401 template <
class ScalarType,
class MV,
class OP>
405 this->normMat(X,normvec);
408 template <
class ScalarType,
class MV,
class OP>
420 MX = Teuchos::rcpFromRef(X);
422 else if (MX == Teuchos::null) {
424 OPT::Apply(*_Op,X,*R);
425 _OpCounter += MVT::GetNumberVecs(X);
431 std::vector<int> ind(1);
432 for (
int i=0; i<MVT::GetNumberVecs(X); i++) {
434 Xi = MVT::CloneView(X,ind);
435 MXi = MVT::CloneView(*MX,ind);
436 MVT::MvTransMv(SCT::one(),*Xi,*MXi,z);
437 normvec[i] = MT::squareroot( SCT::magnitude(z(0,0)) );
441 template <
class ScalarType,
class MV,
class OP>
448 this->projectMat(X,Q,C);
451 template <
class ScalarType,
class MV,
class OP>
455 return this->normalizeMat(X,B);
458 template <
class ScalarType,
class MV,
class OP>
466 return this->projectAndNormalizeMat(X,Q,C,B);
469 template <
class ScalarType,
class MV,
class OP>
473 return this->orthonormErrorMat(X,Teuchos::null);
476 template <
class ScalarType,
class MV,
class OP>
480 return this->orthogErrorMat(X1,X2);
void norm(const MV &X, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec) const
Implements the interface OrthoManager::norm().
virtual void setOp(Teuchos::RCP< const OP > Op)
Set operator used for inner product.
Declaration of basic traits for the multivector type.
int normalize(MV &X, Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B=Teuchos::null) const
Implements the interface OrthoManager::normalize().
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Virtual base class which defines basic traits for the operator type.
void innerProdMat(const MV &X, const MV &Y, Teuchos::SerialDenseMatrix< int, ScalarType > &Z, Teuchos::RCP< const MV > MX=Teuchos::null, Teuchos::RCP< const MV > MY=Teuchos::null) const
Provides a matrix-based inner product.
Teuchos::ScalarTraits< ScalarType >::magnitudeType orthonormError(const MV &X) const
Implements the interface OrthoManager::orthonormError().
virtual void projectMat(MV &X, Teuchos::Array< Teuchos::RCP< const MV > > Q, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C=Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > >(Teuchos::null)), Teuchos::RCP< MV > MX=Teuchos::null, Teuchos::Array< Teuchos::RCP< const MV > > MQ=Teuchos::tuple(Teuchos::RCP< const MV >(Teuchos::null))) const =0
Provides matrix-based projection method.
virtual Teuchos::RCP< const OP > getOp() const
Get operator used for inner product.
Anasazi's templated virtual class for providing routines for orthogonalization and orthonormalization...
void innerProd(const MV &X, const MV &Y, Teuchos::SerialDenseMatrix< int, ScalarType > &Z) const
Implements the interface OrthoManager::innerProd().
virtual Teuchos::ScalarTraits< ScalarType >::magnitudeType orthonormErrorMat(const MV &X, Teuchos::RCP< const MV > MX=Teuchos::null) const =0
This method computes the error in orthonormality of a multivector.
MatOrthoManager(Teuchos::RCP< const OP > Op=Teuchos::null)
Default constructor.
Templated virtual class for providing orthogonalization/orthonormalization methods.
Traits class which defines basic operations on multivectors.
Virtual base class which defines basic traits for the operator type.
virtual ~MatOrthoManager()
Destructor.
Anasazi header file which uses auto-configuration information to include necessary C++ headers...
void resetOpCounter()
Reset the operator counter to zero.
int projectAndNormalize(MV &X, Teuchos::Array< Teuchos::RCP< const MV > > Q, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C=Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > >(Teuchos::null)), Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B=Teuchos::null) const
Implements the interface OrthoManager::projectAndNormalize().
int getOpCounter() const
Retrieve operator counter.
OrdinalType numCols() const
Teuchos::ScalarTraits< ScalarType >::magnitudeType orthogError(const MV &X1, const MV &X2) const
Implements the interface OrthoManager::orthogError().
virtual int normalizeMat(MV &X, Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B=Teuchos::null, Teuchos::RCP< MV > MX=Teuchos::null) const =0
Provides matrix-based orthonormalization method.
Types and exceptions used within Anasazi solvers and interfaces.
Anasazi's templated virtual class for providing routines for orthogonalization and orthonormalization...
void project(MV &X, Teuchos::Array< Teuchos::RCP< const MV > > Q, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C=Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > >(Teuchos::null))) const
Implements the interface OrthoManager::project().
void normMat(const MV &X, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec, Teuchos::RCP< const MV > MX=Teuchos::null) const
Provides the norm induced by the matrix-based inner product.
virtual Teuchos::ScalarTraits< ScalarType >::magnitudeType orthogErrorMat(const MV &X, const MV &Y, Teuchos::RCP< const MV > MX=Teuchos::null, Teuchos::RCP< const MV > MY=Teuchos::null) const =0
This method computes the error in orthogonality of two multivectors.
OrdinalType numRows() const
virtual int projectAndNormalizeMat(MV &X, Teuchos::Array< Teuchos::RCP< const MV > > Q, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C=Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > >(Teuchos::null)), Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B=Teuchos::null, Teuchos::RCP< MV > MX=Teuchos::null, Teuchos::Array< Teuchos::RCP< const MV > > MQ=Teuchos::tuple(Teuchos::RCP< const MV >(Teuchos::null))) const =0
Provides matrix-based projection/orthonormalization method.