47 #ifndef BELOS_MATORTHOMANAGER_HPP
48 #define BELOS_MATORTHOMANAGER_HPP
73 template <
class ScalarType,
class MV,
class OP>
74 class MatOrthoManager :
public OrthoManager<ScalarType,MV> {
76 Teuchos::RCP<const OP>
_Op;
93 void setOp( Teuchos::RCP<const OP> Op ) {
99 Teuchos::RCP<const OP>
getOp()
const {
return _Op; }
112 Teuchos::SerialDenseMatrix<int,ScalarType>& Z )
const {
113 typedef Teuchos::ScalarTraits<ScalarType> SCT;
117 Teuchos::RCP<const MV> P,Q;
122 if ( MVT::GetNumberVecs(X) < MVT::GetNumberVecs(Y) ) {
123 R = MVT::Clone(X,MVT::GetNumberVecs(X));
124 OPT::Apply(*
_Op,X,*R);
126 Q = Teuchos::rcp( &Y,
false );
129 P = Teuchos::rcp( &X,
false );
130 R = MVT::Clone(Y,MVT::GetNumberVecs(Y));
131 OPT::Apply(*
_Op,Y,*R);
136 P = Teuchos::rcp( &X,
false );
137 Q = Teuchos::rcp( &Y,
false );
140 MVT::MvTransMv(SCT::one(),*P,*Q,Z);
149 void innerProd(
const MV& X,
const MV& Y, Teuchos::RCP<const MV> MY,
150 Teuchos::SerialDenseMatrix<int,ScalarType>& Z )
const {
151 typedef Teuchos::ScalarTraits<ScalarType> SCT;
154 Teuchos::RCP<MV> P,Q;
156 if ( MY == Teuchos::null ) {
161 MVT::MvTransMv(SCT::one(),X,*MY,Z);
165 MVT::MvTransMv(SCT::one(),X,Y,Z);
171 void norm(
const MV& X, std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType >& normvec )
const {
172 norm(X,Teuchos::null,normvec);
194 Teuchos::RCP<const MV> MX,
195 std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec)
const
197 typedef Teuchos::ScalarTraits<ScalarType> SCT;
198 typedef Teuchos::ScalarTraits<typename SCT::magnitudeType> MT;
202 int nvecs = MVT::GetNumberVecs(X);
208 if (normvec.size() < static_cast<size_t>(nvecs))
209 normvec.resize (nvecs);
213 MX = Teuchos::rcp(&X,
false);
214 MVT::MvNorm(X, normvec);
221 if(MX == Teuchos::null) {
222 Teuchos::RCP<MV> tempVec = MVT::Clone(X,nvecs);
223 OPT::Apply(*
_Op,X,*tempVec);
229 const int numColsMX = MVT::GetNumberVecs(*MX);
230 TEUCHOS_TEST_FOR_EXCEPTION(numColsMX < nvecs, std::invalid_argument,
231 "MatOrthoManager::norm(X, MX, normvec): "
232 "MX has fewer columns than X: "
233 "MX has " << numColsMX <<
" columns, "
234 "and X has " << nvecs <<
" columns.");
237 std::vector<ScalarType> dotvec(nvecs);
238 MVT::MvDot(X,*MX,dotvec);
239 for (
int i=0; i<nvecs; i++) {
240 normvec[i] = MT::squareroot( SCT::magnitude(dotvec[i]) );
267 virtual void project ( MV &X, Teuchos::RCP<MV> MX,
268 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
269 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const = 0;
276 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
277 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const {
302 virtual int normalize ( MV &X, Teuchos::RCP<MV> MX,
303 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B )
const = 0;
308 virtual int normalize ( MV &X, Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B )
const {
317 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
318 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B,
319 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const = 0;
323 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
324 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B,
325 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const
369 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
370 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B,
371 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const
382 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
390 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
395 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
404 virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
405 orthogError(
const MV &X1, Teuchos::RCP<const MV> MX1,
const MV &X2)
const = 0;