Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_DefaultAddedLinearOp_decl.hpp
1// @HEADER
2// ***********************************************************************
3//
4// Thyra: Interfaces and Support for Abstract Numerical Algorithms
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38//
39// ***********************************************************************
40// @HEADER
41
42#ifndef THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP
43#define THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP
44
45
46#include "Thyra_AddedLinearOpBase.hpp"
47#include "Teuchos_ConstNonconstObjectContainer.hpp"
48
49
50namespace Thyra {
51
52
84template<class Scalar>
85class DefaultAddedLinearOp : virtual public AddedLinearOpBase<Scalar>
86{
87public:
88
91
99
106
112 DefaultAddedLinearOp(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops);
113
131 void initialize(const ArrayView<const RCP<LinearOpBase<Scalar> > > &Ops);
132
152 void initialize(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops);
153
160 void uninitialize();
161
163
166
168 int numOps() const;
170 bool opIsConst(const int k) const;
174 RCP<const LinearOpBase<Scalar> > getOp(const int k) const;
175
177
180
185
190
193
195
198
202 std::string description() const;
203
211 void describe(
213 const Teuchos::EVerbosityLevel verbLevel
214 ) const;
215
217
218protected:
219
222
226 bool opSupportedImpl(EOpTransp M_trans) const;
227
229 void applyImpl(
230 const EOpTransp M_trans,
232 const Ptr<MultiVectorBase<Scalar> > &Y,
233 const Scalar alpha,
234 const Scalar beta
235 ) const;
236
238
239private:
240
241 std::vector<Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> > > Ops_;
242
243 inline void assertInitialized() const;
244 inline std::string getClassName() const;
245 inline Ordinal getRangeDim() const;
246 inline Ordinal getDomainDim() const;
247
248 void validateOps();
249 void setupDefaultObjectLabel();
250
251 // Not defined and not to be called
254
255};
256
257
259template<class Scalar>
260inline
262defaultAddedLinearOp()
263{
265}
266
267
269template<class Scalar>
270inline
271RCP<DefaultAddedLinearOp<Scalar> >
272defaultAddedLinearOp(const ArrayView<const RCP<LinearOpBase<Scalar> > > &Ops)
273{
274 return Teuchos::rcp(new DefaultAddedLinearOp<Scalar>(Ops));
275}
276
277
279template<class Scalar>
280inline
281RCP<DefaultAddedLinearOp<Scalar> >
282defaultAddedLinearOp(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops)
283{
284 return Teuchos::rcp(new DefaultAddedLinearOp<Scalar>(Ops));
285}
286
287
292template<class Scalar>
293RCP<LinearOpBase<Scalar> >
295 const RCP<LinearOpBase<Scalar> > &A,
296 const RCP<LinearOpBase<Scalar> > &B,
297 const std::string &label = ""
298 );
299
300
305template<class Scalar>
308 const RCP<const LinearOpBase<Scalar> > &A,
309 const RCP<const LinearOpBase<Scalar> > &B,
310 const std::string &label = ""
311 );
312
313
318template<class Scalar>
321 const RCP<LinearOpBase<Scalar> > &A,
322 const RCP<LinearOpBase<Scalar> > &B,
323 const std::string &label = ""
324 );
325
326
331template<class Scalar>
334 const RCP<const LinearOpBase<Scalar> > &A,
335 const RCP<const LinearOpBase<Scalar> > &B,
336 const std::string &label = ""
337 );
338
339
340} // end namespace Thyra
341
342
343#endif // THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP
Interface class for implicitly added linear operators.
Concrete composite LinearOpBase subclass that creates an implicitly added linear operator out of one ...
RCP< LinearOpBase< Scalar > > nonconstSubtract(const RCP< LinearOpBase< Scalar > > &A, const RCP< LinearOpBase< Scalar > > &B, const std::string &label="")
Form an implicit subtraction of two linear operators: M = A - B.
RCP< LinearOpBase< Scalar > > getNonconstOp(const int k)
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 DefaultAddedLinearOp along with the overall dimensions and the number of constit...
RCP< const VectorSpaceBase< Scalar > > domain() const
Returns this->getOp(this->numOps()-1).domain() if <t>this->numOps() > 0 and returns Teuchos::null oth...
RCP< LinearOpBase< Scalar > > nonconstAdd(const RCP< LinearOpBase< Scalar > > &A, const RCP< LinearOpBase< Scalar > > &B, const std::string &label="")
Form an implicit addition of two linear operators: M = A + B.
RCP< const VectorSpaceBase< Scalar > > range() const
Returns this->getOp(0).range() if <t>this->numOps() > 0 and returns Teuchos::null otherwise.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Prints the details about the constituent linear operators.
DefaultAddedLinearOp()
Constructs to uninitialized.
void initialize(const ArrayView< const RCP< LinearOpBase< Scalar > > > &Ops)
Initialize given a list of non-const linear operators.
RCP< const LinearOpBase< Scalar > > add(const RCP< const LinearOpBase< Scalar > > &A, const RCP< const LinearOpBase< Scalar > > &B, const std::string &label="")
Form an implicit addition of two linear operators: M = A + B.
bool opSupportedImpl(EOpTransp M_trans) const
Returns true only if all constituent operators support M_trans.
RCP< const LinearOpBase< Scalar > > subtract(const RCP< const LinearOpBase< Scalar > > &A, const RCP< const LinearOpBase< Scalar > > &B, const std::string &label="")
Form an implicit subtraction of two linear operators: M = A - B.
RCP< const LinearOpBase< Scalar > > clone() const
RCP< const LinearOpBase< Scalar > > getOp(const int k) const
Base class for all linear operators.
Interface for a collection of column vectors called a multi-vector.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)