Go to the documentation of this file.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 TSF_SIMPLE_SCALED_OP_IMPL_HPP
00030 #define TSF_SIMPLE_SCALED_OP_IMPL_HPP
00031
00032
00033
00034 #include "TSFSimpleScaledOpDecl.hpp"
00035 #include "SundanceOut.hpp"
00036 #include "SundanceTabs.hpp"
00037
00038 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00039 #include "TSFLinearOperatorImpl.hpp"
00040 #include "TSFSimplifiedLinearOpBaseImpl.hpp"
00041 #endif
00042
00043
00044 namespace TSFExtended
00045 {
00046 using namespace Teuchos;
00047 using namespace Sundance;
00048
00049
00050
00051
00052
00053
00054
00055
00056 template <class Scalar> inline
00057 SimpleScaledOp<Scalar>::SimpleScaledOp(const Scalar& alpha,
00058 const LinearOperator<Scalar>& A)
00059 : SimplifiedLinearOpWithSpaces<Scalar>(
00060 A.domain(), A.range()
00061 )
00062 , alpha_(alpha), A_(A)
00063 {}
00064
00065
00066 template <class Scalar> inline
00067 void SimpleScaledOp<Scalar>::applyOp(const Thyra::EOpTransp M_trans,
00068 const Vector<Scalar>& in,
00069 Vector<Scalar> out) const
00070 {
00071 Tabs tab(0);
00072 SUNDANCE_MSG2(this->verb(), tab << "SimpleScaledOp::applyOp()");
00073
00074 if (M_trans == Thyra::NOTRANS)
00075 A_.apply(in, out);
00076 else if (M_trans == Thyra::TRANS)
00077 A_.applyTranspose(in, out);
00078 else
00079 TEST_FOR_EXCEPT(M_trans !=Thyra::TRANS && M_trans != Thyra::NOTRANS);
00080
00081 out.scale(alpha_);
00082
00083 SUNDANCE_MSG2(this->verb(), tab << "done SimpleScaledOp::applyOp()");
00084 }
00085
00086
00087 template <class Scalar> inline
00088 std::string SimpleScaledOp<Scalar>::description() const
00089 {
00090 return "ScaledOp[alpha=" + Teuchos::toString(alpha_)
00091 + ", " + A_.description() + "]";
00092 }
00093
00094
00095
00096 template <class Scalar> inline
00097 void SimpleScaledOp<Scalar>::print(std::ostream& os) const
00098 {
00099 Tabs tab(0);
00100 os << tab << "ScaledOp[" << std::endl;
00101 Tabs tab1;
00102 os << tab1 << "scale = " << alpha_ << std::endl;
00103 os << tab1 << "operator = " << A_.description() << std::endl;
00104 os << tab << "]" << std::endl;
00105 }
00106
00107
00108
00109 template <class Scalar> inline
00110 LinearOperator<Scalar> scaledOperator(
00111 const Scalar& scale,
00112 const LinearOperator<Scalar>& op)
00113 {
00114 RCP<LinearOpBase<Scalar> > A
00115 = rcp(new SimpleScaledOp<Scalar>(scale, op));
00116
00117 return A;
00118 }
00119
00120
00121 template <class Scalar> inline
00122 LinearOperator<Scalar> operator*(const Scalar& a, const LinearOperator<Scalar>& A)
00123 {
00124 return scaledOperator(a, A);
00125 }
00126
00127
00128 }
00129
00130 #endif