Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultAddedLinearOp_decl.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_ADDED_LINEAR_OP_DECL_HPP
11 #define THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP
12 
13 
14 #include "Thyra_AddedLinearOpBase.hpp"
15 #include "Teuchos_ConstNonconstObjectContainer.hpp"
16 
17 
18 namespace Thyra {
19 
20 
52 template<class Scalar>
53 class DefaultAddedLinearOp : virtual public AddedLinearOpBase<Scalar>
54 {
55 public:
56 
59 
67 
74 
80  DefaultAddedLinearOp(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops);
81 
99  void initialize(const ArrayView<const RCP<LinearOpBase<Scalar> > > &Ops);
100 
120  void initialize(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops);
121 
128  void uninitialize();
129 
131 
134 
136  int numOps() const;
138  bool opIsConst(const int k) const;
142  RCP<const LinearOpBase<Scalar> > getOp(const int k) const;
143 
145 
148 
153 
158 
161 
163 
166 
170  std::string description() const;
171 
179  void describe(
181  const Teuchos::EVerbosityLevel verbLevel
182  ) const;
183 
185 
186 protected:
187 
190 
194  bool opSupportedImpl(EOpTransp M_trans) const;
195 
197  void applyImpl(
198  const EOpTransp M_trans,
199  const MultiVectorBase<Scalar> &X,
200  const Ptr<MultiVectorBase<Scalar> > &Y,
201  const Scalar alpha,
202  const Scalar beta
203  ) const;
204 
206 
207 private:
208 
209  std::vector<Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> > > Ops_;
210 
211  inline void assertInitialized() const;
212  inline std::string getClassName() const;
213  inline Ordinal getRangeDim() const;
214  inline Ordinal getDomainDim() const;
215 
216  void validateOps();
217  void setupDefaultObjectLabel();
218 
219  // Not defined and not to be called
221  DefaultAddedLinearOp& operator=(const DefaultAddedLinearOp&);
222 
223 };
224 
225 
227 template<class Scalar>
228 inline
230 defaultAddedLinearOp()
231 {
233 }
234 
235 
237 template<class Scalar>
238 inline
239 RCP<DefaultAddedLinearOp<Scalar> >
240 defaultAddedLinearOp(const ArrayView<const RCP<LinearOpBase<Scalar> > > &Ops)
241 {
242  return Teuchos::rcp(new DefaultAddedLinearOp<Scalar>(Ops));
243 }
244 
245 
247 template<class Scalar>
248 inline
249 RCP<DefaultAddedLinearOp<Scalar> >
250 defaultAddedLinearOp(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops)
251 {
252  return Teuchos::rcp(new DefaultAddedLinearOp<Scalar>(Ops));
253 }
254 
255 
260 template<class Scalar>
261 RCP<LinearOpBase<Scalar> >
262 nonconstAdd(
263  const RCP<LinearOpBase<Scalar> > &A,
264  const RCP<LinearOpBase<Scalar> > &B,
265  const std::string &label = ""
266  );
267 
268 
273 template<class Scalar>
274 RCP<const LinearOpBase<Scalar> >
275 add(
276  const RCP<const LinearOpBase<Scalar> > &A,
277  const RCP<const LinearOpBase<Scalar> > &B,
278  const std::string &label = ""
279  );
280 
281 
286 template<class Scalar>
287 RCP<LinearOpBase<Scalar> >
288 nonconstSubtract(
289  const RCP<LinearOpBase<Scalar> > &A,
290  const RCP<LinearOpBase<Scalar> > &B,
291  const std::string &label = ""
292  );
293 
294 
299 template<class Scalar>
300 RCP<const LinearOpBase<Scalar> >
301 subtract(
302  const RCP<const LinearOpBase<Scalar> > &A,
303  const RCP<const LinearOpBase<Scalar> > &B,
304  const std::string &label = ""
305  );
306 
307 
308 } // end namespace Thyra
309 
310 
311 #endif // THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP
bool opSupportedImpl(EOpTransp M_trans) const
Returns true only if all constituent operators support M_trans.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
Interface class for implicitly added linear operators.
RCP< const VectorSpaceBase< Scalar > > range() const
Returns this-&gt;getOp(0).range() if &lt;t&gt;this-&gt;numOps() &gt; 0 and returns Teuchos::null otherwise...
RCP< const LinearOpBase< Scalar > > clone() const
Concrete composite LinearOpBase subclass that creates an implicitly added linear operator out of one ...
DefaultAddedLinearOp()
Constructs to uninitialized.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Prints the details about the constituent linear operators.
void initialize(const ArrayView< const RCP< LinearOpBase< Scalar > > > &Ops)
Initialize given a list of non-const linear operators.
RCP< LinearOpBase< Scalar > > getNonconstOp(const int k)
void uninitialize()
Set to uninitialized.
Base class for all linear operators.
std::string description() const
Prints just the name DefaultAddedLinearOp along with the overall dimensions and the number of constit...
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
RCP< const VectorSpaceBase< Scalar > > domain() const
Returns this-&gt;getOp(this-&gt;numOps()-1).domain() if &lt;t&gt;this-&gt;numOps() &gt; 0 and returns Teuchos::null oth...
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > add(const Scalar &alpha, const bool transposeA, const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const bool transposeB, const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
RCP< const LinearOpBase< Scalar > > getOp(const int k) const