45 #ifndef __BelosTsqrOrthoManager_hpp 46 #define __BelosTsqrOrthoManager_hpp 78 template<
class Scalar,
class MV>
82 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType
magnitude_type;
87 typedef Teuchos::SerialDenseMatrix<int, Scalar>
mat_type;
122 Teuchos::Array<mat_ptr> C,
124 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const = 0;
136 template<
class Scalar,
class MV>
140 public Teuchos::ParameterListAcceptor
148 typedef Teuchos::SerialDenseMatrix<int, Scalar>
mat_type;
152 impl_.setParameterList (params);
156 return impl_.getNonconstParameterList ();
160 return impl_.unsetParameterList ();
171 return impl_.getValidParameters();
184 return impl_.getFastParameters();
204 const std::string& label =
"Belos") :
205 impl_ (params, label)
243 impl_.setReorthogonalizationCallback (callback);
246 void innerProd (
const MV &X,
const MV &Y, mat_type& Z)
const {
247 return impl_.innerProd (X, Y, Z);
250 void norm (
const MV& X, std::vector<magnitude_type>& normVec)
const {
251 return impl_.norm (X, normVec);
256 Teuchos::Array<mat_ptr> C,
257 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 259 return impl_.project (X, C, Q);
265 return impl_.normalize (X, B);
270 Teuchos::Array<mat_ptr> C,
272 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 274 return impl_.projectAndNormalize (X, C, B, Q);
296 return impl_.normalizeOutOfPlace (X, Q, B);
322 Teuchos::Array<mat_ptr> C,
324 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 326 return impl_.projectAndNormalizeOutOfPlace (X_in, X_out, C, B, Q);
330 return impl_.orthonormError (X);
334 return impl_.orthogError (X1, X2);
345 impl_.setLabel (label);
348 const std::string&
getLabel()
const {
return impl_.getLabel(); }
376 template<
class Scalar,
class MV,
class OP>
380 public Teuchos::ParameterListAcceptorDefaultBase
390 typedef Teuchos::SerialDenseMatrix<int, Scalar>
mat_type;
438 const std::string& label =
"Belos",
439 Teuchos::RCP<const OP> Op = Teuchos::null) :
441 tsqr_ (params, label),
442 pDgks_ (Teuchos::null)
454 Teuchos::RCP<const OP> Op = Teuchos::null) :
457 pDgks_ (Teuchos::null)
471 return tsqr_.getValidParameters ();
484 return tsqr_.getFastParameters ();
488 tsqr_.setParameterList (params);
491 const std::string&
getLabel()
const {
return tsqr_.getLabel (); }
501 base_type::setOp (Op);
503 if (! Op.is_null()) {
509 Teuchos::RCP<const OP>
getOp ()
const {
512 return base_type::getOp();
518 Teuchos::Array<mat_ptr> C,
519 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 521 if (getOp().is_null()) {
522 tsqr_.project (X, C, Q);
523 if (! MX.is_null()) {
525 MVT::Assign (X, *MX);
529 pDgks_->project (X, MX, C, Q);
535 Teuchos::Array<mat_ptr> C,
536 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 538 project (X, Teuchos::null, C, Q);
544 if (getOp().is_null()) {
545 const int rank = tsqr_.normalize (X, B);
546 if (! MX.is_null()) {
548 MVT::Assign (X, *MX);
553 return pDgks_->normalize (X, MX, B);
558 return normalize (X, Teuchos::null, B);
564 Teuchos::Array<mat_ptr> C,
566 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 568 if (getOp().is_null()) {
569 const int rank = tsqr_.projectAndNormalize (X, C, B, Q);
570 if (! MX.is_null()) {
572 MVT::Assign (X, *MX);
577 return pDgks_->projectAndNormalize (X, MX, C, B, Q);
584 if (getOp().is_null()) {
585 return tsqr_.normalizeOutOfPlace (X, Q, B);
589 const int rank = pDgks_->normalize (X, B);
598 Teuchos::Array<mat_ptr> C,
600 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 604 if (getOp().is_null()) {
605 return tsqr_.projectAndNormalizeOutOfPlace (X_in, X_out, C, B, Q);
609 const int rank = pDgks_->projectAndNormalize (X_in, null, C, B, Q);
610 MVT::Assign (X_in, X_out);
618 if (getOp().is_null()) {
619 return tsqr_.orthonormError (X);
622 return pDgks_->orthonormError (X, MX);
627 return orthonormError (X, Teuchos::null);
631 return orthogError (X1, Teuchos::null, X2);
636 Teuchos::RCP<const MV> MX1,
639 if (getOp().is_null()) {
641 return tsqr_.orthogError (X1, X2);
644 return pDgks_->orthogError (X1, MX1, X2);
651 tsqr_.setLabel (label);
655 if (! pDgks_.is_null()) {
656 pDgks_->setLabel (label);
663 ensureDgksInit ()
const 668 if (pDgks_.is_null()) {
669 pDgks_ = Teuchos::rcp (
new dgks_type (getLabel(), getOp()));
680 mutable tsqr_type tsqr_;
686 mutable Teuchos::RCP<dgks_type> pDgks_;
691 #endif // __BelosTsqrOrthoManager_hpp Teuchos::RCP< mat_type > mat_ptr
void project(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< mat_ptr > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
Teuchos::RCP< mat_type > mat_ptr
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
Interface of callback invoked by TsqrOrthoManager on reorthogonalization.
virtual ~TsqrMatOrthoManager()
Destructor (declared virtual for memory safety of derived classes).
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.
int projectAndNormalize(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
void norm(const MV &X, std::vector< magnitude_type > &normVec) const
void project(MV &X, Teuchos::Array< mat_ptr > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
Mixin for out-of-place orthogonalization.
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters()
Get "fast" parameters for TsqrMatOrthoManager.
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
const std::string & getLabel() const
This method returns the label being used by the timers in the orthogonalization manager.
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitude_type
TSQR-based OrthoManager subclass implementation.
virtual ~OutOfPlaceNormalizerMixin()
Trivial virtual destructor, to silence compiler warnings.
int normalize(MV &X, mat_ptr B) const
magnitude_type orthonormError(const MV &X, Teuchos::RCP< const MV > MX) const
This method computes the error in orthonormality of a multivector. The method has the option of explo...
OP operator_type
Operator type with which this class was specialized.
Teuchos::RCP< mat_type > mat_ptr
void setLabel(const std::string &label)
Set the label for (the timers for) this orthogonalization manager, and create new timers if the label...
const std::string & getLabel() const
This method returns the label being used by the timers in the orthogonalization manager.
Teuchos::SerialDenseMatrix< int, Scalar > mat_type
Traits class which defines basic operations on multivectors.
TsqrOrthoManager(const std::string &label)
Constructor (that sets default parameters).
int normalize(MV &X, Teuchos::RCP< MV > MX, mat_ptr B) const
Belos's templated virtual class for providing routines for orthogonalization and orthonormzalition of...
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const
Normalize X into Q*B, overwriting X with invalid values.
Classical Gram-Schmidt (with DGKS correction) implementation of the Belos::OrthoManager class...
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitude_type
void innerProd(const MV &X, const MV &Y, mat_type &Z) const
Provides the inner product defining the orthogonality concepts.
void setOp(Teuchos::RCP< const OP > Op)
void setReorthogonalizationCallback(const Teuchos::RCP< ReorthogonalizationCallback< Scalar > > &callback)
Set callback to be invoked on reorthogonalization.
magnitude_type orthonormError(const MV &X) const
This method computes the error in orthonormality of a multivector.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Get default parameters for TsqrMatOrthoManager.
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitude_type
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.
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const
Normalize X into Q*B.
virtual ~TsqrOrthoManager()
Destructor, declared virtual for safe inheritance.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Default valid parameter list.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
int normalize(MV &X, mat_ptr B) const
MV multivector_type
Multivector type with which this class was specialized.
Teuchos::SerialDenseMatrix< int, Scalar > mat_type
MV multivector_type
Multivector type with which this class was specialized.
void setLabel(const std::string &label)
This method sets the label used by the timers in the orthogonalization manager.
TsqrMatOrthoManager(const std::string &label="Belos", Teuchos::RCP< const OP > Op=Teuchos::null)
Constructor (that sets default parameters).
Teuchos::SerialDenseMatrix< int, Scalar > mat_type
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).
virtual int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const =0
Normalize X into Q*B.
An implementation of the Belos::MatOrthoManager that performs orthogonalization using (potentially) m...
Orthogonalization manager back end based on Tall Skinny QR (TSQR)
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
magnitude_type orthogError(const MV &X1, const MV &X2) const
This method computes the error in orthogonality of two multivectors. This method. ...
Belos's templated virtual class for providing routines for orthogonalization and orthonormzalition of...
int projectAndNormalize(MV &X, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
MatOrthoManager subclass using TSQR or DGKS.
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters() const
Get "fast" parameters for TsqrOrthoManager.
Teuchos::RCP< const OP > getOp() const
magnitude_type orthogError(const MV &X1, Teuchos::RCP< const MV > MX1, const MV &X2) const
This method computes the error in orthogonality of two multivectors. The method has the option of exp...
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.
TsqrOrthoManager(const Teuchos::RCP< Teuchos::ParameterList > ¶ms, const std::string &label="Belos")
Constructor (that sets user-specified parameters).
void project(MV &X, Teuchos::Array< mat_ptr > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
magnitude_type orthonormError(const MV &X) const
This method computes the error in orthonormality of a multivector.
TSQR-based OrthoManager subclass.
magnitude_type orthogError(const MV &X1, const MV &X2) const
This method computes the error in orthogonality of two multivectors.