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();
203 const std::string& label =
"Belos") :
204 impl_ (params, label)
242 impl_.setReorthogonalizationCallback (callback);
245 void innerProd (
const MV &X,
const MV &Y, mat_type& Z)
const {
246 return impl_.innerProd (X, Y, Z);
249 void norm (
const MV& X, std::vector<magnitude_type>& normVec)
const {
250 return impl_.norm (X, normVec);
255 Teuchos::Array<mat_ptr> C,
256 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 258 return impl_.project (X, C, Q);
264 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);
297 return impl_.normalizeOutOfPlace (X, Q, B);
323 Teuchos::Array<mat_ptr> C,
325 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 327 return impl_.projectAndNormalizeOutOfPlace (X_in, X_out, C, B, Q);
331 return impl_.orthonormError (X);
335 return impl_.orthogError (X1, X2);
346 impl_.setLabel (label);
349 const std::string&
getLabel()
const {
return impl_.getLabel(); }
377 template<
class Scalar,
class MV,
class OP>
381 public Teuchos::ParameterListAcceptorDefaultBase
391 typedef Teuchos::SerialDenseMatrix<int, Scalar>
mat_type;
439 const std::string& label =
"Belos",
440 Teuchos::RCP<const OP> Op = Teuchos::null) :
442 tsqr_ (params, label),
443 pDgks_ (Teuchos::null)
455 Teuchos::RCP<const OP> Op = Teuchos::null) :
458 pDgks_ (Teuchos::null)
472 return tsqr_.getValidParameters ();
485 return tsqr_.getFastParameters ();
489 tsqr_.setParameterList (params);
492 const std::string&
getLabel()
const {
return tsqr_.getLabel (); }
502 base_type::setOp (Op);
504 if (! Op.is_null()) {
510 Teuchos::RCP<const OP>
getOp ()
const {
513 return base_type::getOp();
519 Teuchos::Array<mat_ptr> C,
520 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 522 if (getOp().is_null()) {
523 tsqr_.project (X, C, Q);
524 if (! MX.is_null()) {
526 MVT::Assign (X, *MX);
530 pDgks_->project (X, MX, C, Q);
536 Teuchos::Array<mat_ptr> C,
537 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 539 project (X, Teuchos::null, C, Q);
545 if (getOp().is_null()) {
546 const int rank = tsqr_.normalize (X, B);
547 if (! MX.is_null()) {
549 MVT::Assign (X, *MX);
554 return pDgks_->normalize (X, MX, B);
559 return normalize (X, Teuchos::null, B);
572 Teuchos::Array<mat_ptr> C,
574 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 576 if (getOp().is_null()) {
577 const int rank = tsqr_.projectAndNormalize (X, C, B, Q);
578 if (! MX.is_null()) {
580 MVT::Assign (X, *MX);
585 return pDgks_->projectAndNormalize (X, MX, C, B, Q);
593 if (getOp().is_null()) {
594 return tsqr_.normalizeOutOfPlace (X, Q, B);
598 const int rank = pDgks_->normalize (X, B);
607 Teuchos::Array<mat_ptr> C,
609 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 613 if (getOp().is_null()) {
614 return tsqr_.projectAndNormalizeOutOfPlace (X_in, X_out, C, B, Q);
618 const int rank = pDgks_->projectAndNormalize (X_in, null, C, B, Q);
619 MVT::Assign (X_in, X_out);
627 if (getOp().is_null()) {
628 return tsqr_.orthonormError (X);
631 return pDgks_->orthonormError (X, MX);
636 return orthonormError (X, Teuchos::null);
640 return orthogError (X1, Teuchos::null, X2);
645 Teuchos::RCP<const MV> MX1,
648 if (getOp ().is_null ()) {
650 return tsqr_.orthogError (X1, X2);
653 return pDgks_->orthogError (X1, MX1, X2);
660 tsqr_.setLabel (label);
664 if (! pDgks_.is_null ()) {
665 pDgks_->setLabel (label);
672 ensureDgksInit ()
const 676 if (pDgks_.is_null ()) {
677 pDgks_ = Teuchos::rcp (
new dgks_type (getLabel (), getOp ()));
688 mutable tsqr_type tsqr_;
695 mutable Teuchos::RCP<dgks_type> pDgks_;
700 #endif // __BelosTsqrOrthoManager_hpp Teuchos::RCP< mat_type > mat_ptr
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.
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).
virtual int projectAndNormalizeWithMxImpl(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
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.
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.
virtual int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const =0
Normalize X into Q*B.
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
virtual int projectAndNormalizeImpl(MV &X, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
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).
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...
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...
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.