Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_ScaledAdjointLinearOpBase_def.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_SCALED_ADJOINT_LINEAR_OP_BASE_HPP
11 #define THYRA_SCALED_ADJOINT_LINEAR_OP_BASE_HPP
12 
13 #include "Thyra_ScaledAdjointLinearOpBase_decl.hpp"
14 #include "Thyra_LinearOpBase.hpp"
15 
16 
17 template<class Scalar>
19  const LinearOpBase<Scalar> &Op,
20  Scalar *scalar,
21  EOpTransp *transp,
22  const LinearOpBase<Scalar>* *origOp
23  )
24 {
25 #ifdef TEUCHOS_DEBUG
26  TEUCHOS_TEST_FOR_EXCEPT( scalar==NULL );
27  TEUCHOS_TEST_FOR_EXCEPT( transp==NULL );
28  TEUCHOS_TEST_FOR_EXCEPT( origOp==NULL );
29 #endif
32  *saOp = dynamic_cast<const ScaledAdjointLinearOpBase<Scalar>*>(&Op);
33  if(saOp) {
34  *scalar = saOp->overallScalar();
35  *transp = saOp->overallTransp();
36  *origOp = &*saOp->getOrigOp();
37  }
38  else {
39  *scalar = ST::one();
40  *transp = NOTRANS;
41  *origOp = &Op;
42  }
43 }
44 
45 
46 template<class Scalar>
47 void Thyra::unwrap(
48  const RCP<const LinearOpBase<Scalar> > &Op,
49  Scalar *scalar,
50  EOpTransp *transp,
51  RCP<const LinearOpBase<Scalar> > *origOp
52  )
53 {
54 #ifdef TEUCHOS_DEBUG
55  TEUCHOS_TEST_FOR_EXCEPT( scalar==NULL );
56  TEUCHOS_TEST_FOR_EXCEPT( transp==NULL );
57  TEUCHOS_TEST_FOR_EXCEPT( origOp==NULL );
58 #endif
60  RCP<const ScaledAdjointLinearOpBase<Scalar> >
61  saOp = Teuchos::rcp_dynamic_cast<const ScaledAdjointLinearOpBase<Scalar> >(Op);
62  if(saOp.get()) {
63  *scalar = saOp->overallScalar();
64  *transp = saOp->overallTransp();
65  *origOp = saOp->getOrigOp();
66  }
67  else {
68  *scalar = ST::one();
69  *transp = NOTRANS;
70  *origOp = Op;
71  }
72 }
73 
74 
75 //
76 // Explicit instant macro
77 //
78 
79 #define THYRA_SCALED_ADJOINT_LINEAR_OP_BASE_INSTANT(SCALAR) \
80  \
81  template void unwrap( \
82  const LinearOpBase<SCALAR > &Op, \
83  SCALAR *scalar, \
84  EOpTransp *transp, \
85  const LinearOpBase<SCALAR >* *origOp \
86  ); \
87  \
88  template void unwrap( \
89  const RCP<const LinearOpBase<SCALAR > > &Op, \
90  SCALAR *scalar, \
91  EOpTransp *transp, \
92  RCP<const LinearOpBase<SCALAR > > *origOp \
93  );
94 
95 
96 #endif // THYRA_SCALED_ADJOINT_LINEAR_OP_BASE_HPP
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
void unwrap(const LinearOpBase< Scalar > &Op, Scalar *scalar, EOpTransp *transp, const LinearOpBase< Scalar > **origOp)
Extract the overallScalar, overallTransp and const origOp from a const LinearOpBase object...
Use the non-transposed operator.
Base class for LinearOpBase decorator subclasses that wrap a LinearOpBase object and adds on an extra...
virtual EOpTransp overallTransp() const =0
Return the overall transpose (adjoint) enum.
Base class for all linear operators.
virtual Scalar overallScalar() const =0
Return the overall scale factor.
virtual RCP< const LinearOpBase< Scalar > > getOrigOp() const =0
Return the const original linear operator origOp.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)