13#ifndef __BelosTsqrOrthoManager_hpp
14#define __BelosTsqrOrthoManager_hpp
46template<
class Scalar,
class MV>
50 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType
magnitude_type;
55 typedef Teuchos::SerialDenseMatrix<int, Scalar>
mat_type;
90 Teuchos::Array<mat_ptr> C,
92 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const = 0;
104template<
class Scalar,
class MV>
115 typedef Teuchos::SerialDenseMatrix<int, Scalar>
mat_type;
119 impl_.setParameterList (
params);
123 return impl_.getNonconstParameterList ();
127 return impl_.unsetParameterList ();
138 return impl_.getValidParameters();
151 return impl_.getFastParameters();
170 const std::string&
label =
"Belos") :
209 impl_.setReorthogonalizationCallback (
callback);
213 return impl_.innerProd (
X, Y, Z);
222 Teuchos::Array<mat_ptr> C,
223 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const
225 return impl_.project (
X, C,
Q);
231 return impl_.normalize (
X, B);
237 Teuchos::Array<mat_ptr> C,
239 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const
241 return impl_.projectAndNormalize (
X, C, B,
Q);
264 return impl_.normalizeOutOfPlace (
X,
Q, B);
290 Teuchos::Array<mat_ptr> C,
292 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const
294 return impl_.projectAndNormalizeOutOfPlace (
X_in,
X_out, C, B,
Q);
298 return impl_.orthonormError (
X);
302 return impl_.orthogError (
X1,
X2);
313 impl_.setLabel (
label);
316 const std::string&
getLabel()
const {
return impl_.getLabel(); }
344template<
class Scalar,
class MV,
class OP>
357 typedef Teuchos::SerialDenseMatrix<int, Scalar>
mat_type;
405 const std::string&
label =
"Belos",
406 Teuchos::RCP<const OP>
Op = Teuchos::null) :
409 pDgks_ (Teuchos::
null)
421 Teuchos::RCP<const OP>
Op = Teuchos::null) :
424 pDgks_ (Teuchos::
null)
438 return tsqr_.getValidParameters ();
451 return tsqr_.getFastParameters ();
455 tsqr_.setParameterList (
params);
458 const std::string&
getLabel()
const {
return tsqr_.getLabel (); }
470 if (!
Op.is_null()) {
476 Teuchos::RCP<const OP>
getOp ()
const {
485 Teuchos::Array<mat_ptr> C,
486 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const
489 tsqr_.project (
X, C,
Q);
490 if (!
MX.is_null()) {
492 MVT::Assign (
X, *
MX);
496 pDgks_->project (
X,
MX, C,
Q);
502 Teuchos::Array<mat_ptr> C,
503 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const
512 const int rank = tsqr_.normalize (
X, B);
513 if (!
MX.is_null()) {
515 MVT::Assign (
X, *
MX);
520 return pDgks_->normalize (
X,
MX, B);
538 Teuchos::Array<mat_ptr> C,
540 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const
543 const int rank = tsqr_.projectAndNormalize (
X, C, B,
Q);
544 if (!
MX.is_null()) {
546 MVT::Assign (
X, *
MX);
551 return pDgks_->projectAndNormalize (
X,
MX, C, B,
Q);
560 return tsqr_.normalizeOutOfPlace (
X,
Q, B);
564 const int rank = pDgks_->normalize (
X, B);
573 Teuchos::Array<mat_ptr> C,
575 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const
580 return tsqr_.projectAndNormalizeOutOfPlace (
X_in,
X_out, C, B,
Q);
584 const int rank = pDgks_->projectAndNormalize (
X_in,
null, C, B,
Q);
594 return tsqr_.orthonormError (
X);
597 return pDgks_->orthonormError (
X,
MX);
611 Teuchos::RCP<const MV>
MX1,
616 return tsqr_.orthogError (
X1,
X2);
619 return pDgks_->orthogError (
X1,
MX1,
X2);
626 tsqr_.setLabel (
label);
630 if (! pDgks_.is_null ()) {
631 pDgks_->setLabel (
label);
638 ensureDgksInit ()
const
642 if (pDgks_.is_null ()) {
643 pDgks_ = Teuchos::rcp (
new dgks_type (
getLabel (),
getOp ()));
654 mutable tsqr_type tsqr_;
661 mutable Teuchos::RCP<dgks_type> pDgks_;
Classical Gram-Schmidt (with DGKS correction) implementation of the Belos::OrthoManager class.
Orthogonalization manager back end based on Tall Skinny QR (TSQR)
Belos's templated virtual class for providing routines for orthogonalization and orthonormzalition of...
void setOp(Teuchos::RCP< const OP > Op)
Set operator.
Teuchos::RCP< const OP > getOp() const
Get operator.
Alternative run-time polymorphic interface for operators.
Belos's templated virtual class for providing routines for orthogonalization and orthonormzalition of...
Mixin for out-of-place orthogonalization.
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitude_type
MV multivector_type
Multivector type with which this class was specialized.
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.
Teuchos::RCP< mat_type > mat_ptr
virtual int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const =0
Normalize X into Q*B.
Teuchos::SerialDenseMatrix< int, Scalar > mat_type
virtual ~OutOfPlaceNormalizerMixin()
Trivial virtual destructor, to silence compiler warnings.
MatOrthoManager subclass using TSQR or DGKS.
int normalize(MV &X, Teuchos::RCP< MV > MX, mat_ptr B) const
virtual ~TsqrMatOrthoManager()
Destructor (declared virtual for memory safety of derived classes).
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...
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters()
Get "fast" parameters for TsqrMatOrthoManager.
int normalize(MV &X, mat_ptr B) const
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
void project(MV &X, Teuchos::Array< mat_ptr > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
Teuchos::SerialDenseMatrix< int, Scalar > mat_type
TsqrMatOrthoManager(const std::string &label="Belos", Teuchos::RCP< const OP > Op=Teuchos::null)
Constructor (that sets default parameters).
magnitude_type orthonormError(const MV &X) const
This method computes the error in orthonormality of a multivector.
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const
Normalize X into Q*B.
void setLabel(const std::string &label)
This method sets the label used by the timers in the orthogonalization manager.
Teuchos::RCP< const OP > getOp() const
MV multivector_type
Multivector type with which this class was specialized.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Get default parameters for TsqrMatOrthoManager.
magnitude_type orthogError(const MV &X1, const MV &X2) const
This method computes the error in orthogonality of two multivectors. This method.
void setOp(Teuchos::RCP< const OP > Op)
const std::string & getLabel() const
This method returns the label being used by the timers in the orthogonalization manager.
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...
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).
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitude_type
void project(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< mat_ptr > C, 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.
Teuchos::RCP< mat_type > mat_ptr
OP operator_type
Operator type with which this class was specialized.
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
TSQR-based OrthoManager subclass.
TsqrOrthoManager(const std::string &label)
Constructor (that sets default parameters).
magnitude_type orthonormError(const MV &X) const
This method computes the error in orthonormality of a multivector.
void project(MV &X, Teuchos::Array< mat_ptr > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
void norm(const MV &X, std::vector< magnitude_type > &normVec) const
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitude_type
const std::string & getLabel() const
This method returns the label being used by the timers in the orthogonalization manager.
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters() const
Get "fast" parameters for TsqrOrthoManager.
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
void innerProd(const MV &X, const MV &Y, mat_type &Z) const
Provides the inner product defining the orthogonality concepts.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Default valid parameter list.
virtual int projectAndNormalizeImpl(MV &X, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
magnitude_type orthogError(const MV &X1, const MV &X2) const
This method computes the error in orthogonality of two multivectors.
int normalize(MV &X, mat_ptr B) const
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const
Normalize X into Q*B, overwriting X with invalid values.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
TsqrOrthoManager(const Teuchos::RCP< Teuchos::ParameterList > ¶ms, const std::string &label="Belos")
Constructor (that sets user-specified parameters).
Teuchos::SerialDenseMatrix< int, Scalar > mat_type
virtual ~TsqrOrthoManager()
Destructor, declared virtual for safe inheritance.
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.
Teuchos::RCP< mat_type > mat_ptr
void setReorthogonalizationCallback(const Teuchos::RCP< ReorthogonalizationCallback< Scalar > > &callback)
Set callback to be invoked on reorthogonalization.
void setLabel(const std::string &label)
Set the label for (the timers for) this orthogonalization manager, and create new timers if the label...