47 #include "Teko_BlockUpperTriInverseOp.hpp"
49 #include "Teuchos_Utils.hpp"
65 BlockUpperTriInverseOp::BlockUpperTriInverseOp(BlockedLinearOp & U,
const std::vector<LinearOp> & invDiag)
71 int blocks = blockRowCount(
U_);
72 TEUCHOS_ASSERT(blocks>0);
73 TEUCHOS_ASSERT(blocks==blockColCount(
U_));
74 TEUCHOS_ASSERT(blocks==(
int)
invDiag_.size());
85 const double alpha,
const double beta)
const
104 const BlockedMultiVector & src, BlockedMultiVector & dst,
105 const double alpha,
const double beta)
const
107 int blocks = blockCount(src);
109 TEUCHOS_ASSERT(blocks==blockRowCount(
U_));
110 TEUCHOS_ASSERT(blocks==blockCount(dst));
113 srcScrap_ = datacopy(src,srcScrap_);
114 BlockedMultiVector dstCopy;
116 dstScrap_ = datacopy(dst,dstScrap_);
124 std::vector<MultiVector> dstVec;
125 std::vector<MultiVector> scrapVec;
126 for(
int b=0;b<blocks;b++) {
127 dstVec.push_back(getBlock(b,dstCopy));
128 scrapVec.push_back(getBlock(b,srcScrap_));
133 if(M_trans==Thyra::NOTRANS) {
134 for(
int b=blocks-1;b>=0;b--) {
135 applyOp(
invDiag_[b], scrapVec[b], dstVec[b]);
138 for(
int i=0;i<b;i++) {
139 LinearOp u_ib = getBlock(i,b,
U_);
140 if(u_ib!=Teuchos::null) {
141 applyOp(u_ib,dstVec[b],scrapVec[i],-1.0,1.0);
146 else if(M_trans==Thyra::TRANS || M_trans==Thyra::CONJTRANS) {
147 for(
int b=0;b<blocks;b++) {
148 applyTransposeOp(
invDiag_[b], scrapVec[b], dstVec[b]);
151 for(
int i=b+1;i<blocks;i++) {
152 LinearOp u_bi = getBlock(b,i,
U_);
153 if(u_bi!=Teuchos::null) {
154 applyTransposeOp(u_bi,dstVec[b],scrapVec[i],-1.0,1.0);
160 TEUCHOS_TEST_FOR_EXCEPT(
true);
165 update(alpha,dstCopy,beta,dst);
170 void BlockUpperTriInverseOp::describe(Teuchos::FancyOStream & out_arg,
171 const Teuchos::EVerbosityLevel verbLevel)
const
173 using Teuchos::OSTab;
175 RCP<Teuchos::FancyOStream> out = rcp(&out_arg,
false);
178 case Teuchos::VERB_DEFAULT:
179 case Teuchos::VERB_LOW:
180 *out << this->description() << std::endl;
182 case Teuchos::VERB_MEDIUM:
183 case Teuchos::VERB_HIGH:
184 case Teuchos::VERB_EXTREME:
186 *out << Teuchos::Describable::description() <<
"{"
187 <<
"rangeDim=" << this->
range()->dim()
188 <<
",domainDim=" << this->
domain()->dim()
189 <<
",rows=" << blockRowCount(
U_)
190 <<
",cols=" << blockColCount(
U_)
194 *out <<
"[U Operator] = ";
195 *out << Teuchos::describe(*
U_,verbLevel);
199 *out <<
"[invDiag Operators]:\n";
201 for(
int i=0;i<blockRowCount(
U_);i++) {
202 *out <<
"[invD(" << i <<
")] = ";
203 *out << Teuchos::describe(*
invDiag_[i],verbLevel);
209 TEUCHOS_TEST_FOR_EXCEPT(
true);
virtual VectorSpace domain() const
Domain space of this operator.
std::vector< LinearOp > invDiag_
(Approximate) Inverses of the diagonal operators
virtual VectorSpace range() const
Range space of this operator.
Teuchos::RCP< const Thyra::ProductVectorSpaceBase< double > > productRange_
Range vector space.
virtual void implicitApply(const BlockedMultiVector &x, BlockedMultiVector &y, const double alpha=1.0, const double beta=0.0) const
Perform a matrix vector multiply with this operator.
const BlockedLinearOp U_
operator
Teuchos::RCP< const Thyra::ProductVectorSpaceBase< double > > productDomain_
Domain vector space.