45 #ifndef __AnasaziTsqrOrthoManager_hpp 46 #define __AnasaziTsqrOrthoManager_hpp 48 #include "AnasaziTsqrOrthoManagerImpl.hpp" 75 template<
class Scalar,
class MV>
78 typedef Scalar scalar_type;
79 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitude_type;
84 typedef Teuchos::SerialDenseMatrix<int, Scalar> mat_type;
85 typedef Teuchos::RCP<mat_type> mat_ptr;
119 Teuchos::Array<mat_ptr> C,
121 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const = 0;
133 template<
class Scalar,
class MV>
137 public Teuchos::ParameterListAcceptor
140 typedef Scalar scalar_type;
141 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitude_type;
145 typedef Teuchos::SerialDenseMatrix<int, Scalar> mat_type;
146 typedef Teuchos::RCP<mat_type> mat_ptr;
148 void setParameterList (
const Teuchos::RCP<Teuchos::ParameterList>& params) {
149 impl_.setParameterList (params);
152 Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList () {
153 return impl_.getNonconstParameterList ();
156 Teuchos::RCP<Teuchos::ParameterList> unsetParameterList () {
157 return impl_.unsetParameterList ();
168 return impl_.getValidParameters();
181 return impl_.getFastParameters();
201 const std::string& label =
"Anasazi") :
202 impl_ (params, label)
216 void innerProd (
const MV &X,
const MV& Y, mat_type& Z)
const {
217 return impl_.innerProd (X, Y, Z);
220 void norm (
const MV& X, std::vector<magnitude_type>& normVec)
const {
221 return impl_.norm (X, normVec);
226 Teuchos::Array<Teuchos::RCP<const MV> > Q,
227 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,Scalar> > > C
228 = Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix<int,Scalar> >(Teuchos::null)))
const 230 return impl_.project (X, C, Q);
234 normalize (MV &X, mat_ptr B = Teuchos::null)
const 236 return impl_.normalize (X, B);
241 Teuchos::Array<Teuchos::RCP<const MV> > Q,
242 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,Scalar> > > C
243 = Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix<int,Scalar> >(Teuchos::null)),
244 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,Scalar> > B = Teuchos::null)
const 246 return impl_.projectAndNormalize (X, C, B, Q);
268 return impl_.normalizeOutOfPlace (X, Q, B);
294 Teuchos::Array<mat_ptr> C,
296 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 298 return impl_.projectAndNormalizeOutOfPlace (X_in, X_out, C, B, Q);
302 return impl_.orthonormError (X);
306 return impl_.orthogError (X1, X2);
331 template<
class Scalar,
class MV,
class OP>
335 public Teuchos::ParameterListAcceptorDefaultBase
338 typedef Scalar scalar_type;
339 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitude_type;
345 typedef Teuchos::SerialDenseMatrix<int, Scalar> mat_type;
346 typedef Teuchos::RCP<mat_type> mat_ptr;
393 const std::string& label =
"Belos",
394 Teuchos::RCP<const OP> Op = Teuchos::null) :
396 tsqr_ (params, label),
397 pSvqb_ (Teuchos::null)
409 Teuchos::RCP<const OP> Op = Teuchos::null) :
412 pSvqb_ (Teuchos::null)
442 void setParameterList (
const Teuchos::RCP<Teuchos::ParameterList>& params) {
456 if (! Op.is_null()) {
462 Teuchos::RCP<const OP>
getOp ()
const {
470 Teuchos::Array<Teuchos::RCP<const MV> > Q,
471 Teuchos::Array<Teuchos::RCP<mat_type> > C =
472 Teuchos::tuple (Teuchos::RCP<mat_type> (Teuchos::null)),
473 Teuchos::RCP<MV> MX = Teuchos::null,
474 Teuchos::Array<Teuchos::RCP<const MV> > MQ =
475 Teuchos::tuple (Teuchos::null))
const 477 if (
getOp().is_null()) {
485 if (! MX.is_null()) {
492 pSvqb_->projectMat (X, Q, C, MX, MQ);
498 mat_ptr B = Teuchos::null,
499 Teuchos::RCP<MV> MX = Teuchos::null)
const 501 if (
getOp().is_null()) {
509 if (! MX.is_null()) {
517 return pSvqb_->normalizeMat (X, B, MX);
523 Teuchos::Array<Teuchos::RCP<const MV> > Q,
524 Teuchos::Array<Teuchos::RCP<mat_type> > C =
525 Teuchos::tuple (Teuchos::RCP<mat_type> (Teuchos::null)),
526 Teuchos::RCP<mat_type> B = Teuchos::null,
527 Teuchos::RCP<MV> MX = Teuchos::null,
528 Teuchos::Array<Teuchos::RCP<const MV> > MQ =
529 Teuchos::tuple (Teuchos::RCP<const MV> (Teuchos::null)))
const 531 if (
getOp().is_null()) {
540 if (! MX.is_null()) {
548 return pSvqb_->projectAndNormalizeMat (X, Q, C, B, MX, MQ);
555 if (
getOp().is_null()) {
560 const int rank = pSvqb_->normalize (X, B);
569 Teuchos::Array<mat_ptr> C,
571 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const 575 if (
getOp().is_null()) {
581 Teuchos::Array<Teuchos::RCP<const MV> > Q_array (Q);
582 const int rank = pSvqb_->projectAndNormalize (X_in, Q_array, C, B);
593 if (
getOp().is_null()) {
598 return pSvqb_->orthonormErrorMat (X, MX);
605 Teuchos::RCP<const MV> MX = Teuchos::null,
606 Teuchos::RCP<const MV> MY = Teuchos::null)
const 608 if (
getOp().is_null()) {
613 return pSvqb_->orthogErrorMat (X, Y, MX, MY);
620 ensureSvqbInit ()
const 624 if (pSvqb_.is_null()) {
625 pSvqb_ = Teuchos::rcp (
new svqb_type (
getOp()));
636 mutable tsqr_type tsqr_;
642 mutable Teuchos::RCP<svqb_type> pSvqb_;
647 #endif // __AnasaziTsqrOrthoManager_hpp Teuchos::RCP< const Teuchos::ParameterList > getFastParameters() const
Get "fast" parameters for TsqrOrthoManager.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Default valid parameter list.
MatOrthoManager subclass using TSQR or SVQB.
TSQR-based OrthoManager subclass implementation.
magnitude_type orthonormError(const MV &X) const
Return .
MV multivector_type
Multivector type with which this class was specialized.
magnitude_type orthonormError(const MV &X) const
This method computes the error in orthonormality of a multivector.
magnitude_type orthogError(const MV &X1, const MV &X2) const
Return the Frobenius norm of the inner product of X1 with itself.
virtual void setOp(Teuchos::RCP< const OP > Op)
Set operator used for inner product.
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters()
Get "fast" parameters for TsqrMatOrthoManager.
Mixin for out-of-place orthogonalization.
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.
TsqrMatOrthoManager(const std::string &label="Belos", Teuchos::RCP< const OP > Op=Teuchos::null)
Constructor (that sets default parameters).
MV multivector_type
Multivector type with which this class was specialized.
virtual ~TsqrMatOrthoManager()
Destructor (declared virtual for memory safety of derived classes).
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::RCP< const Teuchos::ParameterList > getValidParameters() const
Get default parameters for TsqrMatOrthoManager.
An implementation of the Anasazi::MatOrthoManager that performs orthogonalization using the SVQB iter...
static void Assign(const MV &A, MV &mv)
mv := A
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.
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const
Normalize X into Q*B, overwriting X with invalid values.
virtual int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const =0
Normalize X into Q*B.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Set parameters from the given parameter list.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package...
virtual ~OutOfPlaceNormalizerMixin()
Trivial virtual destructor, to silence compiler warnings.
Anasazi's templated virtual class for providing routines for orthogonalization and orthonormalization...
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.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Default valid parameter list.
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.
Traits class which defines basic operations on multivectors.
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters()
Get "fast" parameters for TsqrOrthoManagerImpl.
void project(MV &X, Teuchos::Array< mat_ptr > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q)
Compute and .
magnitude_type orthonormErrorMat(const MV &X, Teuchos::RCP< const MV > MX=Teuchos::null) const
This method computes the error in orthonormality of a multivector.
Orthogonalization manager based on the SVQB technique described in "A Block Orthogonalization Procedu...
magnitude_type orthogError(const MV &X1, const MV &X2) const
This method computes the error in orthogonality of two multivectors.
virtual Teuchos::RCP< const OP > getOp() const
Get operator used for inner product.
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.
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 ...
void innerProd(const MV &X, const MV &Y, mat_type &Z) const
Provides the inner product defining the orthogonality concepts.
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...
Teuchos::RCP< const OP > getOp() const
Get operator used for inner product.
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...
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 normalize(MV &X, mat_ptr B)
Orthogonalize the columns of X in place.
virtual void setOp(Teuchos::RCP< const OP > Op)
Set operator used for inner product.
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.
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B) const
Normalize X into Q*B.
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.