Thyra  Version of the Day
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  void assignImpl(Scalar alpha);
98 
100  RCP<const MultiVectorBase<Scalar> >
101  contigSubViewImpl( const Range1D& colRng ) const;
102 
104  RCP<MultiVectorBase<Scalar> >
105  nonconstContigSubViewImpl( const Range1D& colRng );
106 
108  RCP<const MultiVectorBase<Scalar> >
109  nonContigSubViewImpl( const ArrayView<const int> &cols ) const;
110 
112  RCP<MultiVectorBase<Scalar> >
113  nonconstNonContigSubViewImpl( const ArrayView<const int> &cols );
114 
120  virtual void mvMultiReductApplyOpImpl(
121  const RTOpPack::RTOpT<Scalar> &primary_op,
122  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
123  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
124  const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
125  const Ordinal primary_global_offset
126  ) const;
127 
133  virtual void mvSingleReductApplyOpImpl(
134  const RTOpPack::RTOpT<Scalar> &primary_op,
135  const RTOpPack::RTOpT<Scalar> &secondary_op,
136  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
137  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
138  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
139  const Ordinal primary_global_offset
140  ) const;
141 
158  const Range1D &rowRng,
159  const Range1D &colRng,
161  ) const;
162 
171  ) const;
172 
189  const Range1D &rowRng,
190  const Range1D &colRng,
192  );
193 
202  );
203 
205 
206 };
207 
208 
209 } // namespace Thyra
210 
211 
212 #define THYRA_ASSERT_MV_COLS(FUNCNAME, cols) \
213  do { \
214  const int numCols = cols.size(); \
215  const Thyra::Ordinal dimDomain = this->domain()->dim(); \
216  const std::string msgErr = this->description()+"::"+FUNCNAME; \
217  TEUCHOS_TEST_FOR_EXCEPTION( !( 1 <= numCols && numCols <= dimDomain ), \
218  std::invalid_argument, msgErr<<"Error!"); \
219  for (int k = 0; k < numCols; ++k) { \
220  const int col_k = cols[k]; \
221  TEUCHOS_TEST_FOR_EXCEPTION( \
222  !( 0<= col_k && col_k < dimDomain ), std::out_of_range, \
223  msgErr<<": col["<<k<<"] = " << col_k \
224  << " is not in the range [0,"<<(dimDomain-1)<<"]!" \
225  ); \
226  } \
227  } while (false)
228 
229 #ifdef THYRA_DEBUG
230 # define THYRA_DEBUG_ASSERT_MV_COLS(FUNCNAME, cols) \
231  THYRA_ASSERT_MV_COLS(FUNCNAME, cols)
232 #else
233 # define THYRA_DEBUG_ASSERT_MV_COLS(FUNCNAME, cols)
234 #endif
235 
236 #endif // THYRA_MULTI_VECTOR_DEFAULT_BASE_DECL_HPP
RCP< MultiVectorBase< Scalar > > nonconstContigSubViewImpl(const Range1D &colRng)
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
RCP< const MultiVectorBase< Scalar > > contigSubViewImpl(const Range1D &colRng) const
virtual void acquireNonconstDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
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
Node subclass that provides a good default implementation for the describe() function.
Node subclass that uses a default MultiVectorBase implementation to provide default implementations f...
virtual void releaseDetachedMultiVectorViewImpl(RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) 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 acquireDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
virtual RCP< MultiVectorBase< Scalar > > clone_mv() const
virtual void commitNonconstDetachedMultiVectorViewImpl(RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
RCP< MultiVectorBase< Scalar > > nonconstNonContigSubViewImpl(const ArrayView< const int > &cols)
RCP< const MultiVectorBase< Scalar > > nonContigSubViewImpl(const ArrayView< const int > &cols) const
Teuchos::Range1D Range1D