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 //
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_MULTI_VECTOR_DEFAULT_BASE_DECL_HPP
43 #define THYRA_MULTI_VECTOR_DEFAULT_BASE_DECL_HPP
44 
45 #include "Thyra_MultiVectorBase.hpp"
46 #include "Thyra_LinearOpDefaultBase_decl.hpp"
47 
48 
49 namespace Thyra {
50 
51 
69 template<class Scalar>
71  : virtual public MultiVectorBase<Scalar>
72  , virtual protected LinearOpDefaultBase<Scalar>
73 {
74 public:
75 
78 
87  virtual RCP<MultiVectorBase<Scalar> > clone_mv() const;
88 
90 
91 protected:
92 
95 
97  virtual void assignImpl(Scalar alpha);
98 
100  virtual void assignMultiVecImpl(const MultiVectorBase<Scalar>& mv);
101 
103  virtual void scaleImpl(Scalar alpha);
104 
106  virtual void updateImpl(
107  Scalar alpha,
108  const MultiVectorBase<Scalar>& mv
109  );
110 
112  virtual void linearCombinationImpl(
113  const ArrayView<const Scalar>& alpha,
114  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > >& mv,
115  const Scalar& beta
116  );
117 
119  virtual void dotsImpl(
120  const MultiVectorBase<Scalar>& mv,
121  const ArrayView<Scalar>& prods
122  ) const;
123 
125  virtual void norms1Impl(
127  ) const;
128 
130  virtual void norms2Impl(
132  ) const;
133 
135  virtual void normsInfImpl(
137  ) const;
138 
141  contigSubViewImpl( const Range1D& colRng ) const;
142 
145  nonconstContigSubViewImpl( const Range1D& colRng );
146 
149  nonContigSubViewImpl( const ArrayView<const int> &cols ) const;
150 
154 
160  virtual void mvMultiReductApplyOpImpl(
161  const RTOpPack::RTOpT<Scalar> &primary_op,
162  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
163  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
164  const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
165  const Ordinal primary_global_offset
166  ) const;
167 
173  virtual void mvSingleReductApplyOpImpl(
174  const RTOpPack::RTOpT<Scalar> &primary_op,
175  const RTOpPack::RTOpT<Scalar> &secondary_op,
176  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
177  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
178  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
179  const Ordinal primary_global_offset
180  ) const;
181 
198  const Range1D &rowRng,
199  const Range1D &colRng,
201  ) const;
202 
211  ) const;
212 
229  const Range1D &rowRng,
230  const Range1D &colRng,
232  );
233 
242  );
243 
245 
246 };
247 
248 
249 } // namespace Thyra
250 
251 
252 #define THYRA_ASSERT_MV_COLS(FUNCNAME, cols) \
253  do { \
254  const int numCols = cols.size(); \
255  const Thyra::Ordinal dimDomain = this->domain()->dim(); \
256  const std::string msgErr = this->description()+"::"+FUNCNAME; \
257  TEUCHOS_TEST_FOR_EXCEPTION( !( 1 <= numCols && numCols <= dimDomain ), \
258  std::invalid_argument, msgErr<<"Error!"); \
259  for (int k = 0; k < numCols; ++k) { \
260  const int col_k = cols[k]; \
261  TEUCHOS_TEST_FOR_EXCEPTION( \
262  !( 0<= col_k && col_k < dimDomain ), std::out_of_range, \
263  msgErr<<": col["<<k<<"] = " << col_k \
264  << " is not in the range [0,"<<(dimDomain-1)<<"]!" \
265  ); \
266  } \
267  } while (false)
268 
269 #ifdef THYRA_DEBUG
270 # define THYRA_DEBUG_ASSERT_MV_COLS(FUNCNAME, cols) \
271  THYRA_ASSERT_MV_COLS(FUNCNAME, cols)
272 #else
273 # define THYRA_DEBUG_ASSERT_MV_COLS(FUNCNAME, cols)
274 #endif
275 
276 #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.