16 #ifndef ANASAZI_SADDLE_OPERATOR_HPP
17 #define ANASAZI_SADDLE_OPERATOR_HPP
27 enum PrecType {NO_PREC, NONSYM, BD_PREC, HSS_PREC};
30 namespace Experimental {
32 template <
class ScalarType,
class MV,
class OP>
33 class SaddleOperator :
public TraceMinOp<ScalarType,SaddleContainer<ScalarType,MV>,OP>
40 SaddleOperator( ) { };
44 void Apply(
const SaddleContainer<ScalarType,MV>& X, SaddleContainer<ScalarType,MV>& Y)
const;
46 void removeIndices(
const std::vector<int>& indicesToRemove) { A_->removeIndices(indicesToRemove); };
60 template <
class ScalarType,
class MV,
class OP>
72 int nvecs = MVT::GetNumberVecs(*B);
74 Schur_ =
rcp(
new SerialDenseMatrix(nvecs,nvecs));
76 A_->Apply(*B_,*AinvB);
78 MVT::MvTransMv(1., *B_, *AinvB, *Schur_);
83 template <
class ScalarType,
class MV,
class OP>
84 void SaddleOperator<ScalarType, MV, OP>::Apply(
const SaddleContainer<ScalarType,MV>& X, SaddleContainer<ScalarType,MV>& Y)
const
93 MVT::MvTransMv(1., *B_, *(X.upper_), *Ylower);
96 A_->Apply(*(X.upper_), *(Y.upper_));
97 MVT::MvTimesMatAddMv(1., *B_, *Xlower, 1., *(Y.upper_));
99 else if(pt_ == NONSYM)
102 MVT::MvTransMv(-1., *B_, *(X.upper_), *Ylower);
105 A_->Apply(*(X.upper_), *(Y.upper_));
106 MVT::MvTimesMatAddMv(1., *B_, *Xlower, 1., *(Y.upper_));
108 else if(pt_ == BD_PREC)
113 A_->Apply(*(X.upper_),*(Y.upper_));
126 else if(pt_ == HSS_PREC)
133 A_->Apply(*(X.upper_),*(Y.upper_));
136 Ylower->scale(1./alpha_);
145 MVT::MvTransMv(1,*B_,*(Y.upper_),*Ylower);
147 Y1_lower->scale(alpha_);
149 *Ylower += *Y1_lower;
151 Ylower->scale(1/(1+alpha_*alpha_));
153 MVT::MvTimesMatAddMv(-1/alpha_,*B_,*Ylower,1/alpha_,*(Y.upper_));
161 std::cout <<
"Not a valid preconditioner type\n";
172 template<
class ScalarType,
class MV,
class OP>
173 class OperatorTraits<ScalarType, Experimental::SaddleContainer<ScalarType,MV>, Experimental::SaddleOperator<ScalarType,MV,OP> >
176 static void Apply(
const Experimental::SaddleOperator<ScalarType,MV,OP>& Op,
177 const Experimental::SaddleContainer<ScalarType,MV>& x,
178 Experimental::SaddleContainer<ScalarType,MV>& y)
179 { Op.Apply( x, y); };
184 #ifdef HAVE_ANASAZI_BELOS
187 template<
class ScalarType,
class MV,
class OP>
188 class OperatorTraits<ScalarType, Anasazi::Experimental::SaddleContainer<ScalarType,MV>, Anasazi::Experimental::SaddleOperator<ScalarType,MV,OP> >
191 static void Apply(
const Anasazi::Experimental::SaddleOperator<ScalarType,MV,OP>& Op,
192 const Anasazi::Experimental::SaddleContainer<ScalarType,MV>& x,
193 Anasazi::Experimental::SaddleContainer<ScalarType,MV>& y)
194 { Op.Apply( x, y); };
static void Apply(const OP &Op, const MV &x, MV &y)
Application method which performs operation y = Op*x. An OperatorError exception is thrown if there i...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Traits class which defines basic operations on multivectors.
Anasazi header file which uses auto-configuration information to include necessary C++ headers...
int setVectors(const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &X, const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &B)
Stores a set of vectors of the form [V; L] where V is a distributed multivector and L is a serialdens...
int setMatrix(const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &A)