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 //
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 
50 namespace Thyra {
51 
52 
84 template<class Scalar>
85 class DefaultAddedLinearOp : virtual public AddedLinearOpBase<Scalar>
86 {
87 public:
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 
218 protected:
219 
222 
226  bool opSupportedImpl(EOpTransp M_trans) const;
227 
229  void applyImpl(
230  const EOpTransp M_trans,
231  const MultiVectorBase<Scalar> &X,
232  const Ptr<MultiVectorBase<Scalar> > &Y,
233  const Scalar alpha,
234  const Scalar beta
235  ) const;
236 
238 
239 private:
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
253  DefaultAddedLinearOp& operator=(const DefaultAddedLinearOp&);
254 
255 };
256 
257 
259 template<class Scalar>
260 inline
262 defaultAddedLinearOp()
263 {
265 }
266 
267 
269 template<class Scalar>
270 inline
271 RCP<DefaultAddedLinearOp<Scalar> >
272 defaultAddedLinearOp(const ArrayView<const RCP<LinearOpBase<Scalar> > > &Ops)
273 {
274  return Teuchos::rcp(new DefaultAddedLinearOp<Scalar>(Ops));
275 }
276 
277 
279 template<class Scalar>
280 inline
281 RCP<DefaultAddedLinearOp<Scalar> >
282 defaultAddedLinearOp(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops)
283 {
284  return Teuchos::rcp(new DefaultAddedLinearOp<Scalar>(Ops));
285 }
286 
287 
292 template<class Scalar>
293 RCP<LinearOpBase<Scalar> >
294 nonconstAdd(
295  const RCP<LinearOpBase<Scalar> > &A,
296  const RCP<LinearOpBase<Scalar> > &B,
297  const std::string &label = ""
298  );
299 
300 
305 template<class Scalar>
306 RCP<const LinearOpBase<Scalar> >
307 add(
308  const RCP<const LinearOpBase<Scalar> > &A,
309  const RCP<const LinearOpBase<Scalar> > &B,
310  const std::string &label = ""
311  );
312 
313 
318 template<class Scalar>
319 RCP<LinearOpBase<Scalar> >
320 nonconstSubtract(
321  const RCP<LinearOpBase<Scalar> > &A,
322  const RCP<LinearOpBase<Scalar> > &B,
323  const std::string &label = ""
324  );
325 
326 
331 template<class Scalar>
332 RCP<const LinearOpBase<Scalar> >
333 subtract(
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
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...
RCP< const LinearOpBase< Scalar > > getOp(const int k) const