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);
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);
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),
455 Teuchos::RCP<const OP> Op = Teuchos::null) :
504 if (! Op.is_null()) {
510 Teuchos::RCP<const OP>
getOp ()
const {
519 Teuchos::Array<mat_ptr> C,
520 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 522 if (
getOp().is_null()) {
524 if (! MX.is_null()) {
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()) {
547 if (! MX.is_null()) {
554 return pDgks_->normalize (X, MX, B);
572 Teuchos::Array<mat_ptr> C,
574 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 576 if (
getOp().is_null()) {
578 if (! MX.is_null()) {
585 return pDgks_->projectAndNormalize (X, MX, C, B, Q);
593 if (
getOp().is_null()) {
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()) {
618 const int rank =
pDgks_->projectAndNormalize (X_in, null, C, B, Q);
627 if (
getOp().is_null()) {
631 return pDgks_->orthonormError (X, MX);
645 Teuchos::RCP<const MV> MX1,
648 if (
getOp ().is_null ()) {
653 return pDgks_->orthogError (X1, MX1, X2);
664 if (!
pDgks_.is_null ()) {
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.
magnitude_type orthonormError(const MV &X) const
Return .
TsqrOrthoManagerImpl< Scalar, MV > tsqr_type
Implementation of TSQR-based orthogonalization.
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.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Default valid parameter list.
std::string label_
Label for timers (if timers are enabled at compile time).
int projectAndNormalize(MV &X, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q)
Project X against Q and normalize X.
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).
void project(MV &X, Teuchos::Array< mat_ptr > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q)
Compute and .
Mixin for out-of-place orthogonalization.
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters()
Get "fast" parameters for TsqrMatOrthoManager.
Teuchos::RCP< dgks_type > pDgks_
DGKS orthogonalization manager.
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Set parameters from the given parameter list.
void project(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< mat_ptr > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitude_type
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters()
Get "fast" parameters for TsqrOrthoManagerImpl.
TSQR-based OrthoManager subclass implementation.
magnitude_type orthogError(const MV &X1, const MV &X2) const
This method computes the error in orthogonality of two multivectors. This method. ...
virtual ~OutOfPlaceNormalizerMixin()
Trivial virtual destructor, to silence compiler warnings.
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...
void norm(const MV &X, std::vector< magnitude_type > &normVec) const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Get default parameters for TsqrMatOrthoManager.
const std::string & getLabel() const
This method returns the label being used by the timers in the orthogonalization manager.
int normalize(MV &X, mat_ptr B)
Orthogonalize the columns of X in place.
OP operator_type
Operator type with which this class was specialized.
void setLabel(const std::string &label)
Set the label for timers.
Teuchos::RCP< mat_type > mat_ptr
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...
void setLabel(const std::string &label)
Set the label for (the timers for) this orthogonalization manager, and create new timers if the label...
Teuchos::RCP< const OP > getOp() const
Get operator.
Teuchos::SerialDenseMatrix< int, Scalar > mat_type
static void Assign(const MV &A, MV &mv)
mv := A
Traits class which defines basic operations on multivectors.
TsqrOrthoManager(const std::string &label)
Constructor (that sets default parameters).
Belos's templated virtual class for providing routines for orthogonalization and orthonormzalition of...
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
Classical Gram-Schmidt (with DGKS correction) implementation of the Belos::OrthoManager class...
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitude_type
TsqrOrthoManagerImpl< Scalar, MV > impl_
The implementation of TSQR.
Teuchos::RCP< const OP > getOp() const
void setOp(Teuchos::RCP< const OP > Op)
void project(MV &X, Teuchos::Array< mat_ptr > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
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.
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const
Normalize X into Q*B.
void ensureDgksInit() const
Ensure that the DGKSOrthoManager instance is initialized.
tsqr_type tsqr_
TSQR + BGS orthogonalization manager implementation.
int normalize(MV &X, mat_ptr B) const
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; overwrite X_in.
virtual ~TsqrOrthoManager()
Destructor, declared virtual for safe inheritance.
const std::string & getLabel() const
This method returns the label being used by the timers in the orthogonalization manager.
virtual int projectAndNormalizeImpl(MV &X, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
int normalize(MV &X, Teuchos::RCP< MV > MX, 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.
MatOrthoManager< Scalar, MV, OP > base_type
This will be used to help C++ resolve getOp().
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
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Default valid parameter list.
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters() const
Get "fast" parameters for TsqrOrthoManager.
DGKSOrthoManager< Scalar, MV, OP > dgks_type
Implementation of DGKS-based orthogonalization.
void innerProd(const MV &X, const MV &Y, mat_type &Z) const
Provides the inner product defining the orthogonality concepts.
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const
Normalize X into Q*B, overwriting X with invalid values.
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).
MultiVecTraits< Scalar, MV > MVT
Traits class for the multivector type.
An implementation of the Belos::MatOrthoManager that performs orthogonalization using (potentially) m...
Orthogonalization manager back end based on Tall Skinny QR (TSQR)
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.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
int normalize(MV &X, mat_ptr B) const
Belos's templated virtual class for providing routines for orthogonalization and orthonormzalition of...
int projectAndNormalizeOutOfPlace(MV &X_in, MV &X_out, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q)
Project and normalize X_in into X_out; overwrite X_in.
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B)
Normalize X into Q*B, overwriting X.
MatOrthoManager subclass using TSQR or DGKS.
const std::string & getLabel() const
Get the label for timers (if timers are enabled).
magnitude_type orthogError(const MV &X1, const MV &X2) const
This method computes the error in orthogonality of two multivectors.
magnitude_type orthonormError(const MV &X) const
This method computes the error in orthonormality of a multivector.
void setOp(Teuchos::RCP< const OP > Op)
Set operator.
TsqrOrthoManager(const Teuchos::RCP< Teuchos::ParameterList > ¶ms, const std::string &label="Belos")
Constructor (that sets user-specified parameters).
magnitude_type orthogError(const MV &X1, const MV &X2) const
Return the Frobenius norm of the inner product of X1 with itself.
TSQR-based OrthoManager subclass.