Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_MultiVectorDefaultBase_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_MULTI_VECTOR_DEFAULT_BASE_DECL_HPP
11 #define THYRA_MULTI_VECTOR_DEFAULT_BASE_DECL_HPP
12 
13 #include "Thyra_MultiVectorBase.hpp"
14 #include "Thyra_LinearOpDefaultBase_decl.hpp"
15 
16 
17 namespace Thyra {
18 
19 
37 template<class Scalar>
39  : virtual public MultiVectorBase<Scalar>
40  , virtual protected LinearOpDefaultBase<Scalar>
41 {
42 public:
43 
46 
55  virtual RCP<MultiVectorBase<Scalar> > clone_mv() const;
56 
58 
59 protected:
60 
63 
65  virtual void assignImpl(Scalar alpha);
66 
68  virtual void assignMultiVecImpl(const MultiVectorBase<Scalar>& mv);
69 
71  virtual void scaleImpl(Scalar alpha);
72 
74  virtual void updateImpl(
75  Scalar alpha,
76  const MultiVectorBase<Scalar>& mv
77  );
78 
80  virtual void linearCombinationImpl(
81  const ArrayView<const Scalar>& alpha,
82  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > >& mv,
83  const Scalar& beta
84  );
85 
87  virtual void dotsImpl(
88  const MultiVectorBase<Scalar>& mv,
89  const ArrayView<Scalar>& prods
90  ) const;
91 
93  virtual void norms1Impl(
95  ) const;
96 
98  virtual void norms2Impl(
100  ) const;
101 
103  virtual void normsInfImpl(
105  ) const;
106 
109  contigSubViewImpl( const Range1D& colRng ) const;
110 
113  nonconstContigSubViewImpl( const Range1D& colRng );
114 
117  nonContigSubViewImpl( const ArrayView<const int> &cols ) const;
118 
122 
128  virtual void mvMultiReductApplyOpImpl(
129  const RTOpPack::RTOpT<Scalar> &primary_op,
130  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
131  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
132  const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
133  const Ordinal primary_global_offset
134  ) const;
135 
141  virtual void mvSingleReductApplyOpImpl(
142  const RTOpPack::RTOpT<Scalar> &primary_op,
143  const RTOpPack::RTOpT<Scalar> &secondary_op,
144  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
145  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
146  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
147  const Ordinal primary_global_offset
148  ) const;
149 
166  const Range1D &rowRng,
167  const Range1D &colRng,
169  ) const;
170 
179  ) const;
180 
197  const Range1D &rowRng,
198  const Range1D &colRng,
200  );
201 
210  );
211 
213 
214 };
215 
216 
217 } // namespace Thyra
218 
219 
220 #define THYRA_ASSERT_MV_COLS(FUNCNAME, cols) \
221  do { \
222  const int numCols = cols.size(); \
223  const Thyra::Ordinal dimDomain = this->domain()->dim(); \
224  const std::string msgErr = this->description()+"::"+FUNCNAME; \
225  TEUCHOS_TEST_FOR_EXCEPTION( !( 1 <= numCols && numCols <= dimDomain ), \
226  std::invalid_argument, msgErr<<"Error!"); \
227  for (int k = 0; k < numCols; ++k) { \
228  const int col_k = cols[k]; \
229  TEUCHOS_TEST_FOR_EXCEPTION( \
230  !( 0<= col_k && col_k < dimDomain ), std::out_of_range, \
231  msgErr<<": col["<<k<<"] = " << col_k \
232  << " is not in the range [0,"<<(dimDomain-1)<<"]!" \
233  ); \
234  } \
235  } while (false)
236 
237 #ifdef THYRA_DEBUG
238 # define THYRA_DEBUG_ASSERT_MV_COLS(FUNCNAME, cols) \
239  THYRA_ASSERT_MV_COLS(FUNCNAME, cols)
240 #else
241 # define THYRA_DEBUG_ASSERT_MV_COLS(FUNCNAME, cols)
242 #endif
243 
244 #endif // THYRA_MULTI_VECTOR_DEFAULT_BASE_DECL_HPP
virtual RCP< MultiVectorBase< Scalar > > clone_mv() const
RCP< MultiVectorBase< Scalar > > nonconstContigSubViewImpl(const Range1D &colRng)
virtual void releaseDetachedMultiVectorViewImpl(RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
virtual void acquireNonconstDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
virtual void assignMultiVecImpl(const MultiVectorBase< Scalar > &mv)
Default implementation of assign(MV) using RTOps.
RCP< const MultiVectorBase< Scalar > > contigSubViewImpl(const Range1D &colRng) const
Node subclass that provides a good default implementation for the describe() function.
virtual void mvMultiReductApplyOpImpl(const RTOpPack::RTOpT< Scalar > &primary_op, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &multi_vecs, const ArrayView< const Ptr< MultiVectorBase< Scalar > > > &targ_multi_vecs, const ArrayView< const Ptr< RTOpPack::ReductTarget > > &reduct_objs, const Ordinal primary_global_offset) const
virtual void linearCombinationImpl(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &mv, const Scalar &beta)
Default implementation of linear_combination using RTOps.
virtual void assignImpl(Scalar alpha)
Default implementation of assign(scalar) using RTOps.
Node subclass that uses a default MultiVectorBase implementation to provide default implementations f...
RCP< const MultiVectorBase< Scalar > > nonContigSubViewImpl(const ArrayView< const int > &cols) const
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
virtual void mvSingleReductApplyOpImpl(const RTOpPack::RTOpT< Scalar > &primary_op, const RTOpPack::RTOpT< Scalar > &secondary_op, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &multi_vecs, const ArrayView< const Ptr< MultiVectorBase< Scalar > > > &targ_multi_vecs, const Ptr< RTOpPack::ReductTarget > &reduct_obj, const Ordinal primary_global_offset) const
void norms(const MultiVectorBase< Scalar > &V, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector natural norm.
virtual void commitNonconstDetachedMultiVectorViewImpl(RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
virtual void norms1Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
Default implementation of norms_1 using RTOps.
RCP< MultiVectorBase< Scalar > > nonconstNonContigSubViewImpl(const ArrayView< const int > &cols)
virtual void scaleImpl(Scalar alpha)
Default implementation of scale using RTOps.
virtual void acquireDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
virtual void norms2Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
Default implementation of norms_2 using RTOps.
virtual void dotsImpl(const MultiVectorBase< Scalar > &mv, const ArrayView< Scalar > &prods) const
Default implementation of dots using RTOps.
virtual void normsInfImpl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
Default implementation of norms_inf using RTOps.
virtual void updateImpl(Scalar alpha, const MultiVectorBase< Scalar > &mv)
Default implementation of update using RTOps.