PlayaSimpleTransposedOpImpl.hpp
00001
00002
00003
00004
00005 #ifndef PLAYA_SIMPLE_TRANSPOSED_OP_IMPL_HPP
00006 #define PLAYA_SIMPLE_TRANSPOSED_OP_IMPL_HPP
00007
00008
00009
00010 #include "PlayaSimpleTransposedOpDecl.hpp"
00011 #include "PlayaSimpleZeroOpDecl.hpp"
00012 #include "PlayaOut.hpp"
00013 #include "PlayaTabs.hpp"
00014
00015 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00016 #include "PlayaLinearOperatorImpl.hpp"
00017 #include "PlayaSimpleZeroOpImpl.hpp"
00018 #endif
00019
00020
00021 namespace Playa
00022 {
00023 using namespace Teuchos;
00024
00025
00026
00027
00028
00029
00030
00031
00032 template <class Scalar> inline
00033 SimpleTransposedOp<Scalar>::SimpleTransposedOp(const LinearOperator<Scalar>& A)
00034 : LinearOpWithSpaces<Scalar>(
00035 A.range(), A.domain()
00036 )
00037 , A_(A)
00038 {}
00039
00040
00041 template <class Scalar> inline
00042 void SimpleTransposedOp<Scalar>::apply(Teuchos::ETransp transApplyType,
00043 const Vector<Scalar>& in,
00044 Vector<Scalar> out) const
00045 {
00046 Tabs tab(0);
00047 PLAYA_MSG2(this->verb(), tab << "SimpleTransposedOp::apply()");
00048
00049 if (transApplyType == Teuchos::NO_TRANS)
00050 A_.applyTranspose(in, out);
00051 else if (transApplyType == Teuchos::TRANS)
00052 A_.apply(in, out);
00053 else
00054 TEUCHOS_TEST_FOR_EXCEPT(transApplyType !=Teuchos::TRANS && transApplyType != Teuchos::NO_TRANS);
00055
00056 PLAYA_MSG2(this->verb(), tab << "done SimpleTransposedOp::apply()");
00057 }
00058
00059
00060 template <class Scalar> inline
00061 std::string SimpleTransposedOp<Scalar>::description() const
00062 {
00063 return "(" + A_.description() + "^T)";
00064 }
00065
00066
00067
00068 template <class Scalar> inline
00069 LinearOperator<Scalar> transposedOperator(
00070 const LinearOperator<Scalar>& op)
00071 {
00072
00073
00074 const SimpleTransposedOp<Scalar>* tPtr
00075 = dynamic_cast<const SimpleTransposedOp<Scalar>*>(op.ptr().get());
00076 if (tPtr)
00077 {
00078 return tPtr->op();
00079 }
00080
00081
00082 const SimpleZeroOp<Scalar>* zPtr
00083 = dynamic_cast<const SimpleZeroOp<Scalar>*>(op.ptr().get());
00084
00085 if (zPtr != 0)
00086 {
00087 VectorSpace<Scalar> r = op.range();
00088 VectorSpace<Scalar> d = op.domain();
00089 return zeroOperator(r, d);
00090 }
00091
00092
00093
00094 RCP<LinearOperatorBase<Scalar> > A
00095 = rcp(new SimpleTransposedOp<Scalar>(op));
00096
00097 return A;
00098 }
00099
00100
00101
00102
00103 }
00104
00105 #endif