32 #ifndef __AnasaziTsqrOrthoManager_hpp 33 #define __AnasaziTsqrOrthoManager_hpp 35 #include "AnasaziTsqrOrthoManagerImpl.hpp" 62 template<
class Scalar,
class MV>
65 typedef Scalar scalar_type;
66 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitude_type;
71 typedef Teuchos::SerialDenseMatrix<int, Scalar> mat_type;
72 typedef Teuchos::RCP<mat_type> mat_ptr;
106 Teuchos::Array<mat_ptr> C,
108 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const = 0;
120 template<
class Scalar,
class MV>
124 public Teuchos::ParameterListAcceptor
127 typedef Scalar scalar_type;
128 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitude_type;
132 typedef Teuchos::SerialDenseMatrix<int, Scalar> mat_type;
133 typedef Teuchos::RCP<mat_type> mat_ptr;
135 void setParameterList (
const Teuchos::RCP<Teuchos::ParameterList>& params) {
136 impl_.setParameterList (params);
139 Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList () {
140 return impl_.getNonconstParameterList ();
143 Teuchos::RCP<Teuchos::ParameterList> unsetParameterList () {
144 return impl_.unsetParameterList ();
155 return impl_.getValidParameters();
168 return impl_.getFastParameters();
188 const std::string& label =
"Anasazi") :
189 impl_ (params, label)
203 void innerProd (
const MV &X,
const MV& Y, mat_type& Z)
const {
204 return impl_.innerProd (X, Y, Z);
207 void norm (
const MV& X, std::vector<magnitude_type>& normVec)
const {
208 return impl_.norm (X, normVec);
213 Teuchos::Array<Teuchos::RCP<const MV> > Q,
214 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,Scalar> > > C
215 = Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix<int,Scalar> >(Teuchos::null)))
const 217 return impl_.project (X, C, Q);
221 normalize (MV &X, mat_ptr B = Teuchos::null)
const 223 return impl_.normalize (X, B);
228 Teuchos::Array<Teuchos::RCP<const MV> > Q,
229 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,Scalar> > > C
230 = Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix<int,Scalar> >(Teuchos::null)),
231 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,Scalar> > B = Teuchos::null)
const 233 return impl_.projectAndNormalize (X, C, B, Q);
255 return impl_.normalizeOutOfPlace (X, Q, B);
281 Teuchos::Array<mat_ptr> C,
283 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 285 return impl_.projectAndNormalizeOutOfPlace (X_in, X_out, C, B, Q);
289 return impl_.orthonormError (X);
293 return impl_.orthogError (X1, X2);
318 template<
class Scalar,
class MV,
class OP>
322 public Teuchos::ParameterListAcceptorDefaultBase
325 typedef Scalar scalar_type;
326 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitude_type;
332 typedef Teuchos::SerialDenseMatrix<int, Scalar> mat_type;
333 typedef Teuchos::RCP<mat_type> mat_ptr;
380 const std::string& label =
"Belos",
381 Teuchos::RCP<const OP> Op = Teuchos::null) :
383 tsqr_ (params, label),
384 pSvqb_ (Teuchos::null)
396 Teuchos::RCP<const OP> Op = Teuchos::null) :
399 pSvqb_ (Teuchos::null)
413 return tsqr_.getValidParameters ();
426 return tsqr_.getFastParameters ();
429 void setParameterList (
const Teuchos::RCP<Teuchos::ParameterList>& params) {
430 tsqr_.setParameterList (params);
441 base_type::setOp (Op);
443 if (! Op.is_null()) {
449 Teuchos::RCP<const OP>
getOp ()
const {
452 return base_type::getOp();
457 Teuchos::Array<Teuchos::RCP<const MV> > Q,
458 Teuchos::Array<Teuchos::RCP<mat_type> > C =
459 Teuchos::tuple (Teuchos::RCP<mat_type> (Teuchos::null)),
460 Teuchos::RCP<MV> MX = Teuchos::null,
461 Teuchos::Array<Teuchos::RCP<const MV> > MQ =
462 Teuchos::tuple (Teuchos::null))
const 464 if (getOp().is_null()) {
467 tsqr_.project (X, C, Q);
472 if (! MX.is_null()) {
474 MVT::Assign (X, *MX);
479 pSvqb_->projectMat (X, Q, C, MX, MQ);
485 mat_ptr B = Teuchos::null,
486 Teuchos::RCP<MV> MX = Teuchos::null)
const 488 if (getOp().is_null()) {
491 const int rank = tsqr_.normalize (X, B);
496 if (! MX.is_null()) {
498 MVT::Assign (X, *MX);
504 return pSvqb_->normalizeMat (X, B, MX);
510 Teuchos::Array<Teuchos::RCP<const MV> > Q,
511 Teuchos::Array<Teuchos::RCP<mat_type> > C =
512 Teuchos::tuple (Teuchos::RCP<mat_type> (Teuchos::null)),
513 Teuchos::RCP<mat_type> B = Teuchos::null,
514 Teuchos::RCP<MV> MX = Teuchos::null,
515 Teuchos::Array<Teuchos::RCP<const MV> > MQ =
516 Teuchos::tuple (Teuchos::RCP<const MV> (Teuchos::null)))
const 518 if (getOp().is_null()) {
521 const int rank = tsqr_.projectAndNormalize (X, C, B, Q);
527 if (! MX.is_null()) {
529 MVT::Assign (X, *MX);
535 return pSvqb_->projectAndNormalizeMat (X, Q, C, B, MX, MQ);
542 if (getOp().is_null()) {
543 return tsqr_.normalizeOutOfPlace (X, Q, B);
547 const int rank = pSvqb_->normalize (X, B);
556 Teuchos::Array<mat_ptr> C,
558 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 562 if (getOp().is_null()) {
563 return tsqr_.projectAndNormalizeOutOfPlace (X_in, X_out, C, B, Q);
568 Teuchos::Array<Teuchos::RCP<const MV> > Q_array (Q);
569 const int rank = pSvqb_->projectAndNormalize (X_in, Q_array, C, B);
572 MVT::Assign (X_in, X_out);
580 if (getOp().is_null()) {
581 return tsqr_.orthonormError (X);
585 return pSvqb_->orthonormErrorMat (X, MX);
592 Teuchos::RCP<const MV> MX = Teuchos::null,
593 Teuchos::RCP<const MV> MY = Teuchos::null)
const 595 if (getOp().is_null()) {
596 return tsqr_.orthogError (X, Y);
600 return pSvqb_->orthogErrorMat (X, Y, MX, MY);
607 ensureSvqbInit ()
const 611 if (pSvqb_.is_null()) {
612 pSvqb_ = Teuchos::rcp (
new svqb_type (getOp()));
623 mutable tsqr_type tsqr_;
629 mutable Teuchos::RCP<svqb_type> pSvqb_;
634 #endif // __AnasaziTsqrOrthoManager_hpp magnitude_type orthonormError(const MV &X) const
This method computes the error in orthonormality of a multivector.
MatOrthoManager subclass using TSQR or SVQB.
void projectMat(MV &X, Teuchos::Array< Teuchos::RCP< const MV > > Q, Teuchos::Array< Teuchos::RCP< mat_type > > C=Teuchos::tuple(Teuchos::RCP< mat_type >(Teuchos::null)), Teuchos::RCP< MV > MX=Teuchos::null, Teuchos::Array< Teuchos::RCP< const MV > > MQ=Teuchos::tuple(Teuchos::null)) const
Provides matrix-based projection method.
TSQR-based OrthoManager subclass implementation.
MV multivector_type
Multivector type with which this class was specialized.
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters()
Get "fast" parameters for TsqrMatOrthoManager.
int projectAndNormalizeOutOfPlace(MV &X_in, MV &X_out, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
Project and normalize X_in into X_out.
Mixin for out-of-place orthogonalization.
TsqrMatOrthoManager(const std::string &label="Belos", Teuchos::RCP< const OP > Op=Teuchos::null)
Constructor (that sets default parameters).
magnitude_type orthogErrorMat(const MV &X, const MV &Y, Teuchos::RCP< const MV > MX=Teuchos::null, Teuchos::RCP< const MV > MY=Teuchos::null) const
This method computes the error in orthogonality of two multivectors.
MV multivector_type
Multivector type with which this class was specialized.
virtual ~TsqrMatOrthoManager()
Destructor (declared virtual for memory safety of derived classes).
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Default valid parameter list.
TsqrMatOrthoManager(const Teuchos::RCP< Teuchos::ParameterList > ¶ms, const std::string &label="Belos", Teuchos::RCP< const OP > Op=Teuchos::null)
Constructor (that sets user-specified parameters).
An implementation of the Anasazi::MatOrthoManager that performs orthogonalization using the SVQB iter...
virtual int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const =0
Normalize X into Q*B.
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const
Normalize X into Q*B, overwriting X with invalid values.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package...
virtual ~OutOfPlaceNormalizerMixin()
Trivial virtual destructor, to silence compiler warnings.
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const
Normalize X into Q*B.
int projectAndNormalizeOutOfPlace(MV &X_in, MV &X_out, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
Project and normalize X_in into X_out; overwrite X_in.
Anasazi's templated virtual class for providing routines for orthogonalization and orthonormalization...
magnitude_type orthonormErrorMat(const MV &X, Teuchos::RCP< const MV > MX=Teuchos::null) const
This method computes the error in orthonormality of a multivector.
int projectAndNormalizeMat(MV &X, Teuchos::Array< Teuchos::RCP< const MV > > Q, Teuchos::Array< Teuchos::RCP< mat_type > > C=Teuchos::tuple(Teuchos::RCP< mat_type >(Teuchos::null)), Teuchos::RCP< mat_type > 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
Provides matrix-based projection/orthonormalization method.
Traits class which defines basic operations on multivectors.
Teuchos::RCP< const OP > getOp() const
Get operator used for inner product.
magnitude_type orthogError(const MV &X1, const MV &X2) const
This method computes the error in orthogonality of two multivectors.
void innerProd(const MV &X, const MV &Y, mat_type &Z) const
Provides the inner product defining the orthogonality concepts.
Orthogonalization manager based on the SVQB technique described in "A Block Orthogonalization Procedu...
TsqrOrthoManager(const Teuchos::RCP< Teuchos::ParameterList > ¶ms, const std::string &label="Anasazi")
Constructor (that sets user-specified parameters).
TSQR-based OrthoManager subclass.
virtual ~TsqrOrthoManager()
Destructor, declared virtual for safe inheritance.
TsqrOrthoManager(const std::string &label)
Constructor (that sets default parameters).
OP operator_type
Operator type with which this class was specialized.
Anasazi's templated virtual class for providing routines for orthogonalization and orthonormalization...
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Get default parameters for TsqrMatOrthoManager.
int projectAndNormalize(MV &X, Teuchos::Array< Teuchos::RCP< const MV > > Q, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, Scalar > > > C=Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix< int, Scalar > >(Teuchos::null)), Teuchos::RCP< Teuchos::SerialDenseMatrix< int, Scalar > > B=Teuchos::null) const
Given a set of bases Q[i] and a multivector X, this method computes an orthonormal basis for ...
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters() const
Get "fast" parameters for TsqrOrthoManager.
virtual void setOp(Teuchos::RCP< const OP > Op)
Set operator used for inner product.
void project(MV &X, Teuchos::Array< Teuchos::RCP< const MV > > Q, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, Scalar > > > C=Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix< int, Scalar > >(Teuchos::null))) const
Given a list of mutually orthogonal and internally orthonormal bases Q, this method projects a multiv...
virtual int projectAndNormalizeOutOfPlace(MV &X_in, MV &X_out, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const =0
Project and normalize X_in into X_out.