00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef THYRA_MULTI_VECTOR_LINEAR_OP_WITH_SOLVE_HPP
00030 #define THYRA_MULTI_VECTOR_LINEAR_OP_WITH_SOLVE_HPP
00031
00032 #include "Thyra_DefaultMultiVectorLinearOpWithSolveDecl.hpp"
00033 #include "Thyra_DefaultDiagonalLinearOp.hpp"
00034 #include "Thyra_LinearOpWithSolveBase.hpp"
00035 #include "Thyra_SingleRhsLinearOpWithSolveBase.hpp"
00036 #include "Thyra_DefaultMultiVectorProductVectorSpace.hpp"
00037 #include "Thyra_DefaultMultiVectorProductVector.hpp"
00038 #include "Thyra_AssertOp.hpp"
00039 #include "Teuchos_dyn_cast.hpp"
00040
00041
00042 namespace Thyra {
00043
00044
00045
00046
00047
00048 template<class Scalar>
00049 DefaultMultiVectorLinearOpWithSolve<Scalar>::DefaultMultiVectorLinearOpWithSolve()
00050 {}
00051
00052
00053 template<class Scalar>
00054 void DefaultMultiVectorLinearOpWithSolve<Scalar>::initialize(
00055 const Teuchos::RCP<LinearOpWithSolveBase<Scalar> > &lows,
00056 const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
00057 const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
00058 )
00059 {
00060 validateInitialize(lows,multiVecRange,multiVecDomain);
00061 lows_ = lows;
00062 multiVecRange_ = multiVecRange;
00063 multiVecDomain_ = multiVecDomain;
00064 }
00065
00066
00067 template<class Scalar>
00068 void DefaultMultiVectorLinearOpWithSolve<Scalar>::initialize(
00069 const Teuchos::RCP<const LinearOpWithSolveBase<Scalar> > &lows,
00070 const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
00071 const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
00072 )
00073 {
00074 validateInitialize(lows,multiVecRange,multiVecDomain);
00075 lows_ = lows;
00076 multiVecRange_ = multiVecRange;
00077 multiVecDomain_ = multiVecDomain;
00078 }
00079
00080
00081 template<class Scalar>
00082 Teuchos::RCP<LinearOpWithSolveBase<Scalar> >
00083 DefaultMultiVectorLinearOpWithSolve<Scalar>::getNonconstLinearOpWithSolve()
00084 {
00085 return lows_.getNonconstObj();
00086 }
00087
00088
00089 template<class Scalar>
00090 Teuchos::RCP<const LinearOpWithSolveBase<Scalar> >
00091 DefaultMultiVectorLinearOpWithSolve<Scalar>::getLinearOpWithSolve() const
00092 {
00093 return lows_.getConstObj();
00094 }
00095
00096
00097 template<class Scalar>
00098 void DefaultMultiVectorLinearOpWithSolve<Scalar>::uninitialize()
00099 {
00100 lows_.uninitialize();
00101 multiVecRange_ = Teuchos::null;
00102 multiVecDomain_ = Teuchos::null;
00103 }
00104
00105
00106
00107
00108
00109 template<class Scalar>
00110 Teuchos::RCP< const VectorSpaceBase<Scalar> >
00111 DefaultMultiVectorLinearOpWithSolve<Scalar>::range() const
00112 {
00113 return multiVecRange_;
00114 }
00115
00116
00117 template<class Scalar>
00118 Teuchos::RCP< const VectorSpaceBase<Scalar> >
00119 DefaultMultiVectorLinearOpWithSolve<Scalar>::domain() const
00120 {
00121 return multiVecDomain_;
00122 }
00123
00124
00125 template<class Scalar>
00126 Teuchos::RCP<const LinearOpBase<Scalar> >
00127 DefaultMultiVectorLinearOpWithSolve<Scalar>::clone() const
00128 {
00129 return Teuchos::null;
00130 }
00131
00132
00133
00134
00135
00136
00137
00138
00139 template<class Scalar>
00140 bool DefaultMultiVectorLinearOpWithSolve<Scalar>::opSupported(
00141 ETransp M_trans
00142 ) const
00143 {
00144 return Thyra::opSupported(*lows_.getConstObj(),M_trans);
00145 }
00146
00147
00148
00149
00150
00151 template<class Scalar>
00152 void DefaultMultiVectorLinearOpWithSolve<Scalar>::apply(
00153 const ETransp M_trans,
00154 const VectorBase<Scalar> &x,
00155 VectorBase<Scalar> *y,
00156 const Scalar alpha,
00157 const Scalar beta
00158 ) const
00159 {
00160
00161 using Teuchos::dyn_cast;
00162 using Teuchos::RCP;
00163 typedef DefaultMultiVectorProductVector<Scalar> MVPV;
00164
00165 #ifdef TEUCHOS_DEBUG
00166 TEST_FOR_EXCEPT(0==y);
00167 #endif
00168
00169 RCP<const MultiVectorBase<Scalar> >
00170 X = dyn_cast<const MVPV>(x).getMultiVector().assert_not_null();
00171 RCP<MultiVectorBase<Scalar> >
00172 Y = dyn_cast<MVPV>(*y).getNonconstMultiVector().assert_not_null();
00173
00174 Thyra::apply( *lows_.getConstObj(), M_trans, *X, &*Y, alpha, beta );
00175
00176 }
00177
00178
00179
00180
00181
00182 template<class Scalar>
00183 bool DefaultMultiVectorLinearOpWithSolve<Scalar>::solveSupportsTrans(
00184 ETransp M_trans
00185 ) const
00186 {
00187 return Thyra::solveSupports(*lows_.getConstObj(),M_trans);
00188 }
00189
00190
00191 template<class Scalar>
00192 bool DefaultMultiVectorLinearOpWithSolve<Scalar>::solveSupportsSolveMeasureType(
00193 ETransp M_trans, const SolveMeasureType& solveMeasureType
00194 ) const
00195 {
00196 return Thyra::solveSupportsSolveMeasureType(
00197 *lows_.getConstObj(),M_trans,solveMeasureType);
00198 }
00199
00200
00201
00202
00203
00204 template<class Scalar>
00205 SolveStatus<Scalar>
00206 DefaultMultiVectorLinearOpWithSolve<Scalar>::solve(
00207 const ETransp M_trans,
00208 const VectorBase<Scalar> &b,
00209 VectorBase<Scalar> *x,
00210 const SolveCriteria<Scalar> *solveCriteria
00211 ) const
00212 {
00213
00214 using Teuchos::dyn_cast;
00215 using Teuchos::RCP;
00216 typedef DefaultMultiVectorProductVector<Scalar> MVPV;
00217
00218 #ifdef TEUCHOS_DEBUG
00219 TEST_FOR_EXCEPT(0==x);
00220 #endif
00221
00222 RCP<const MultiVectorBase<Scalar> >
00223 B = dyn_cast<const MVPV>(b).getMultiVector().assert_not_null();
00224 RCP<MultiVectorBase<Scalar> >
00225 X = dyn_cast<MVPV>(*x).getNonconstMultiVector().assert_not_null();
00226
00227 return Thyra::solve(
00228 *lows_.getConstObj(), M_trans,
00229 *B, &*X, solveCriteria
00230 );
00231
00232 }
00233
00234
00235
00236
00237
00238 template<class Scalar>
00239 void DefaultMultiVectorLinearOpWithSolve<Scalar>::validateInitialize(
00240 const Teuchos::RCP<const LinearOpWithSolveBase<Scalar> > &lows,
00241 const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
00242 const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
00243 )
00244 {
00245 #ifdef TEUCHOS_DEBUG
00246 TEST_FOR_EXCEPT(is_null(lows));
00247 TEST_FOR_EXCEPT(is_null(multiVecRange));
00248 TEST_FOR_EXCEPT(is_null(multiVecDomain));
00249 TEST_FOR_EXCEPT( multiVecRange->numBlocks() != multiVecDomain->numBlocks() );
00250 THYRA_ASSERT_VEC_SPACES(
00251 "DefaultMultiVectorLinearOpWithSolve<Scalar>::initialize(lows,multiVecRange,multiVecDomain)",
00252 *lows->range(), *multiVecRange->getBlock(0) );
00253 THYRA_ASSERT_VEC_SPACES(
00254 "DefaultMultiVectorLinearOpWithSolve<Scalar>::initialize(lows,multiVecRange,multiVecDomain)",
00255 *lows->domain(), *multiVecDomain->getBlock(0) );
00256 #endif
00257 }
00258
00259
00260 }
00261
00262
00263 #endif // THYRA_MULTI_VECTOR_LINEAR_OP_WITH_SOLVE_HPP