Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultIdentityLinearOp_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_DEFAULT_IDENTITY_LINEAR_OP_DEF_HPP
11 #define THYRA_DEFAULT_IDENTITY_LINEAR_OP_DEF_HPP
12 
13 #include "Thyra_DefaultIdentityLinearOp_decl.hpp"
14 #include "Thyra_MultiVectorStdOps.hpp"
15 #include "Thyra_AssertOp.hpp"
16 
17 
18 namespace Thyra {
19 
20 
21 // Constructors/initializers/accessors
22 
23 
24 template<class Scalar>
26 {}
27 
28 
29 template<class Scalar>
31  const Teuchos::RCP<const VectorSpaceBase<Scalar> > &space
32  )
33 {
34  initialize(space);
35 }
36 
37 
38 template<class Scalar>
40  const Teuchos::RCP<const VectorSpaceBase<Scalar> > &space
41  )
42 {
43  space_ = space.assert_not_null();
44 }
45 
46 
47 template<class Scalar>
49 {
50  space_ = Teuchos::null;
51 }
52 
53 
54 // Overridden from LinearOpBase
55 
56 
57 template<class Scalar>
60 {
61  return space_;
62 }
63 
64 
65 template<class Scalar>
68 {
69  return space_;
70 }
71 
72 
73 template<class Scalar>
76 {
77  typedef DefaultIdentityLinearOp<Scalar> this_t;
78  if(space_.get())
79  return Teuchos::rcp(new this_t(space_));
80  return Teuchos::rcp(new this_t());
81 }
82 
83 
84 // Overridden from Teuchos::Describable
85 
86 
87 template<class Scalar>
89 {
91  std::ostringstream oss;
92  oss
93  << "Thyra::DefaultIdentityLinearOp<" << ST::name() << ">{"
94  << "space="<<(space_.get()?space_->description():"NULL")
95  << "}";
96  return oss.str();
97 }
98 
99 
100 // protected
101 
102 
103 // Overridden from LinearOpBase
104 
105 
106 template<class Scalar>
108 {
109  return true;
110 }
111 
112 
113 template<class Scalar>
115  const EOpTransp M_trans,
116  const MultiVectorBase<Scalar> &X,
117  const Ptr<MultiVectorBase<Scalar> > &Y,
118  const Scalar alpha,
119  const Scalar beta
120  ) const
121 {
122  using Teuchos::tuple;
123  using Teuchos::ptrFromRef;
124 #ifdef TEUCHOS_DEBUG
126  "DefaultIdentityLinearOp<Scalar>::apply(...)", *this, M_trans, X, &*Y
127  );
128 #else
129  (void)M_trans;
130 #endif // TEUCHOS_DEBUG
131  Thyra::linear_combination<Scalar>(
132  tuple<Scalar>(alpha)(),
133  tuple<Ptr<const MultiVectorBase<Scalar> > >(ptrFromRef(X))(),
134  beta, Y
135  );
136 }
137 
138 
139 } // end namespace Thyra
140 
141 
142 template<class Scalar>
144 Thyra::identity(
145  const Teuchos::RCP<const VectorSpaceBase<Scalar> > &space,
146  const std::string &label
147  )
148 {
149  RCP<Thyra::LinearOpBase<Scalar> > ilo =
150  Teuchos::rcp(new DefaultIdentityLinearOp<Scalar>(space));
151  if (label.length())
152  ilo->setObjectLabel(label);
153  return ilo;
154 }
155 
156 
157 //
158 // Explicit instantaition
159 //
160 
161 
162 #define THYRA_DEFAULT_IDENTITY_LINEAR_OP_INSTANT(SCALAR) \
163  \
164  template class DefaultIdentityLinearOp<SCALAR >; \
165  \
166  template RCP<const LinearOpBase<SCALAR > > \
167  identity( \
168  const RCP<const VectorSpaceBase<SCALAR > > &space, \
169  const std::string &label \
170  ); \
171 
172 
173 #endif // THYRA_DEFAULT_IDENTITY_LINEAR_OP_DEF_HPP
void initialize(int *argc, char ***argv)
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
#define THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES(FUNC_NAME, M, M_T, X, Y)
This is a very useful macro that should be used to validate that the spaces for the multi-vector vers...
Represents a identity linear operator M = I.
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
std::string description() const
Prints just the name DefaultIdentityLinearOp along with the overall dimensions.
Abstract interface for objects that represent a space for vectors.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Interface for a collection of column vectors called a multi-vector.
bool opSupportedImpl(EOpTransp M_trans) const
Returns true .
void initialize(const RCP< const VectorSpaceBase< Scalar > > &space)
Initialize given a list of non-const linear operators.
RCP< const LinearOpBase< Scalar > > clone() const
RCP< const VectorSpaceBase< Scalar > > domain() const
Returns Teuchos::null if uninitialized.
RCP< const VectorSpaceBase< Scalar > > range() const
Returns Teuchos::null if uninitialized.
DefaultIdentityLinearOp()
Constructs to uninitialized.