15#ifndef BELOS_MATORTHOMANAGER_HPP
16#define BELOS_MATORTHOMANAGER_HPP
47 template <
class ScalarType,
class MV,
class OP,
class DM = DefaultDenseMatrix<
int,ScalarType>>
50 Teuchos::RCP<const OP>
_Op;
67 void setOp( Teuchos::RCP<const OP> Op ) {
73 Teuchos::RCP<const OP>
getOp()
const {
return _Op; }
87 typedef Teuchos::ScalarTraits<ScalarType> SCT;
91 Teuchos::RCP<const MV> P,Q;
96 if ( MVT::GetNumberVecs(X) < MVT::GetNumberVecs(Y) ) {
97 R = MVT::Clone(X,MVT::GetNumberVecs(X));
98 OPT::Apply(*
_Op,X,*R);
100 Q = Teuchos::rcp( &Y,
false );
103 P = Teuchos::rcp( &X,
false );
104 R = MVT::Clone(Y,MVT::GetNumberVecs(Y));
105 OPT::Apply(*
_Op,Y,*R);
110 P = Teuchos::rcp( &X,
false );
111 Q = Teuchos::rcp( &Y,
false );
114 MVT::MvTransMv(SCT::one(),*P,*Q,Z);
123 void innerProd(
const MV& X,
const MV& Y, Teuchos::RCP<const MV> MY,
125 typedef Teuchos::ScalarTraits<ScalarType> SCT;
128 Teuchos::RCP<MV> P,Q;
130 if ( MY == Teuchos::null ) {
135 MVT::MvTransMv(SCT::one(),X,*MY,Z);
139 MVT::MvTransMv(SCT::one(),X,Y,Z);
145 void norm(
const MV& X, std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType >& normvec )
const {
146 norm(X,Teuchos::null,normvec);
168 Teuchos::RCP<const MV> MX,
169 std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec)
const
171 typedef Teuchos::ScalarTraits<ScalarType> SCT;
172 typedef Teuchos::ScalarTraits<typename SCT::magnitudeType> MT;
176 int nvecs = MVT::GetNumberVecs(X);
182 if (normvec.size() <
static_cast<size_t>(nvecs))
183 normvec.resize (nvecs);
187 MX = Teuchos::rcp(&X,
false);
188 MVT::MvNorm(X, normvec);
195 if(MX == Teuchos::null) {
196 Teuchos::RCP<MV> tempVec = MVT::Clone(X,nvecs);
197 OPT::Apply(*
_Op,X,*tempVec);
203 const int numColsMX = MVT::GetNumberVecs(*MX);
204 TEUCHOS_TEST_FOR_EXCEPTION(numColsMX < nvecs, std::invalid_argument,
205 "MatOrthoManager::norm(X, MX, normvec): "
206 "MX has fewer columns than X: "
207 "MX has " << numColsMX <<
" columns, "
208 "and X has " << nvecs <<
" columns.");
211 std::vector<ScalarType> dotvec(nvecs);
212 MVT::MvDot(X,*MX,dotvec);
213 for (
int i=0; i<nvecs; i++) {
214 normvec[i] = MT::squareroot( SCT::magnitude(dotvec[i]) );
241 virtual void project ( MV &X, Teuchos::RCP<MV> MX,
242 Teuchos::Array<Teuchos::RCP<DM> > C,
243 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const = 0;
250 Teuchos::Array<Teuchos::RCP<DM> > C,
251 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const {
277 Teuchos::RCP<DM> B )
const = 0;
282 virtual int normalize ( MV &X, Teuchos::RCP<DM> B )
const {
291 Teuchos::Array<Teuchos::RCP<DM> > C,
293 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const = 0;
297 Teuchos::Array<Teuchos::RCP<DM> > C,
299 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const
343 Teuchos::Array<Teuchos::RCP<DM> > C,
345 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const
356 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
364 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
369 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
378 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
379 orthogError(
const MV &X1, Teuchos::RCP<const MV> MX1,
const MV &X2)
const = 0;
Belos header file which uses auto-configuration information to include necessary C++ headers.
Full specialization of Belos::DenseMatTraits for Kokkos::DualView with arbitrary scalarType....
Declaration of basic traits for the multivector type.
Class which defines basic traits for the operator type.
Templated virtual class for providing orthogonalization/orthonormalization methods.
Full specialization of Belos::DenseMatTraits for Teuchos::SerialDenseMatrix with ordinal type int and...
Collection of types and exceptions used within the Belos solvers.
virtual void project(MV &X, Teuchos::Array< Teuchos::RCP< DM > > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
This method calls project(X,Teuchos::null,C,Q); see documentation for that function.
virtual int normalize(MV &X, Teuchos::RCP< DM > B) const
This method calls normalize(X,Teuchos::null,B); see documentation for that function.
void innerProd(const MV &X, const MV &Y, DM &Z) const
Provides the inner product defining the orthogonality concepts, using the provided operator.
virtual int projectAndNormalizeImpl(MV &X, Teuchos::Array< Teuchos::RCP< DM > > C, Teuchos::RCP< DM > B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
virtual Teuchos::ScalarTraits< ScalarType >::magnitudeType orthonormError(const MV &X) const
This method computes the error in orthonormality of a multivector.
void norm(const MV &X, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec) const
Provides the norm induced by innerProd().
virtual Teuchos::ScalarTraits< ScalarType >::magnitudeType orthogError(const MV &X1, Teuchos::RCP< const MV > MX1, const MV &X2) const =0
This method computes the error in orthogonality of two multivectors. The method has the option of exp...
virtual int normalize(MV &X, Teuchos::RCP< MV > MX, Teuchos::RCP< DM > B) const =0
This method takes a multivector X and attempts to compute an orthonormal basis for ,...
void innerProd(const MV &X, const MV &Y, Teuchos::RCP< const MV > MY, DM &Z) const
Provides the inner product defining the orthogonality concepts, using the provided operator....
MatOrthoManager(Teuchos::RCP< const OP > Op=Teuchos::null)
Default constructor.
Teuchos::RCP< const OP > _Op
virtual int projectAndNormalizeWithMxImpl(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< Teuchos::RCP< DM > > C, Teuchos::RCP< DM > B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const =0
void setOp(Teuchos::RCP< const OP > Op)
Set operator.
int projectAndNormalize(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< Teuchos::RCP< DM > > C, Teuchos::RCP< DM > B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
Given a set of bases Q[i] and a multivector X, this method computes an orthonormal basis for .
virtual void project(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< Teuchos::RCP< DM > > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const =0
Given a list of (mutually and internally) orthonormal bases Q, this method takes a multivector X and ...
virtual Teuchos::ScalarTraits< ScalarType >::magnitudeType orthonormError(const MV &X, Teuchos::RCP< const MV > MX) const =0
This method computes the error in orthonormality of a multivector. The method has the option of explo...
void norm(const MV &X, Teuchos::RCP< const MV > MX, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec) const
Compute norm of each column of X.
Teuchos::RCP< const OP > getOp() const
Get operator.
virtual Teuchos::ScalarTraits< ScalarType >::magnitudeType orthogError(const MV &X1, const MV &X2) const
This method computes the error in orthogonality of two multivectors. This method.
virtual ~MatOrthoManager()
Destructor.
Traits class which defines basic operations on multivectors.
Class which defines basic traits for the operator type.
OrthoManager()
Default constructor.