Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultProductMultiVector_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_PRODUCT_MULTI_VECTOR_DECL_HPP
43 #define THYRA_DEFAULT_PRODUCT_MULTI_VECTOR_DECL_HPP
44 
45 #include "Thyra_ProductMultiVectorBase.hpp"
46 #include "Thyra_MultiVectorDefaultBase.hpp"
47 #include "Teuchos_ConstNonconstObjectContainer.hpp"
48 
49 
50 namespace Thyra {
51 
52 
54 template <class Scalar> class DefaultProductVectorSpace;
55 
56 
70 template<class Scalar>
72  : virtual public ProductMultiVectorBase<Scalar>,
73  virtual protected MultiVectorDefaultBase<Scalar>
74 {
75 public:
76 
79 
82 
84  void initialize(
86  const int numMembers
87  );
88 
90  void initialize(
92  const ArrayView<const RCP<MultiVectorBase<Scalar> > > &multiVecs
93  );
94 
96  void initialize(
98  const ArrayView<const RCP<const MultiVectorBase<Scalar> > > &multiVecs
99  );
100 
105  void uninitialize();
106 
108 
111 
113  std::string description() const;
114 
116  void describe(
118  const Teuchos::EVerbosityLevel verbLevel
119  ) const;
120 
122 
125 
128  productSpace() const;
130  bool blockIsConst(const int k) const;
133  getNonconstMultiVectorBlock(const int k);
136  getMultiVectorBlock(const int k) const;
137 
139 
144 
146 
149 
152  range() const;
155  domain() const;
156 
158 
159 protected:
160 
163 
165  virtual void assignImpl(Scalar alpha);
167  virtual void assignMultiVecImpl(const MultiVectorBase<Scalar>& mv);
169  virtual void scaleImpl(Scalar alpha);
171  virtual void updateImpl(
172  Scalar alpha,
173  const MultiVectorBase<Scalar>& mv
174  );
176  virtual void linearCombinationImpl(
177  const ArrayView<const Scalar>& alpha,
178  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > >& mv,
179  const Scalar& beta
180  );
182  virtual void dotsImpl(
183  const MultiVectorBase<Scalar>& mv,
184  const ArrayView<Scalar>& prods
185  ) const;
187  virtual void norms1Impl(
189  ) const;
191  virtual void norms2Impl(
193  ) const;
195  virtual void normsInfImpl(
197  ) const;
204  contigSubViewImpl( const Range1D& colRng ) const;
207  nonconstContigSubViewImpl( const Range1D& colRng );
210  nonContigSubViewImpl( const ArrayView<const int> &cols ) const;
216  const RTOpPack::RTOpT<Scalar> &primary_op,
217  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
218  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
219  const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
220  const Ordinal primary_global_offset
221  ) const;
224  const Range1D &rowRng,
225  const Range1D &colRng,
227  ) const;
231  ) const;
234  const Range1D &rowRng,
235  const Range1D &colRng,
237  );
241  );
242 
244 
247 
249  bool opSupportedImpl(EOpTransp M_trans) const;
250 
252  void applyImpl(
253  const EOpTransp M_trans,
254  const MultiVectorBase<Scalar> &X,
255  const Ptr<MultiVectorBase<Scalar> > &Y,
256  const Scalar alpha,
257  const Scalar beta
258  ) const;
259 
261 
262 public:
263 
264 private:
265 
266  // //////////////////////////////
267  // Private types
268 
270 
271  // //////////////////////////////
272  // Private data members
273 
275  Teuchos::Array<CNMVC> multiVecs_;
276  // cache
277  int numBlocks_;
278 
279  // //////////////////////////////
280  // Private member functions
281 
282  template<class MultiVectorType>
283  void initializeImpl(
284  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
285  const ArrayView<const RCP<MultiVectorType> > &multiVecs
286  );
287 
288  void assertInitialized() const;
289 
290  void validateColIndex(const int j) const;
291 
292 };
293 
294 
299 template<class Scalar>
301 defaultProductMultiVector();
302 
303 
308 template<class Scalar>
310 defaultProductMultiVector(
311  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
312  const int numMembers
313  );
314 
315 
320 template<class Scalar>
322 defaultProductMultiVector(
323  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
324  const ArrayView<const RCP<MultiVectorBase<Scalar> > > &multiVecs
325  );
326 
327 
332 template<class Scalar>
334 defaultProductMultiVector(
335  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
336  const ArrayView<const RCP<const MultiVectorBase<Scalar> > > &multiVecs
337  );
338 
339 
346 template<class Scalar>
348 castOrCreateSingleBlockProductMultiVector(
349  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
350  const RCP<const MultiVectorBase<Scalar> > &mv
351  );
352 
353 
360 template<class Scalar>
362 nonconstCastOrCreateSingleBlockProductMultiVector(
363  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
364  const RCP<MultiVectorBase<Scalar> > &mv
365  );
366 
367 
368 // /////////////////////////
369 // Inline members
370 
371 
372 #ifndef TEUCHOS_DEBUG
373 
374 
375 template<class Scalar>
376 inline
378 {}
379 
380 
381 template<class Scalar>
382 inline
383 void DefaultProductMultiVector<Scalar>::validateColIndex(const int /* j */) const
384 {}
385 
386 
387 #endif // TEUCHOS_DEBUG
388 
389 
390 } // namespace Thyra
391 
392 
393 #endif // THYRA_DEFAULT_PRODUCT_MULTI_VECTOR_DECL_HPP
Base interface for product multi-vectors.
virtual void updateImpl(Scalar alpha, const MultiVectorBase< Scalar > &mv)
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
void acquireDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
RCP< VectorBase< Scalar > > nonconstColImpl(Ordinal j)
virtual void norms1Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
virtual void dotsImpl(const MultiVectorBase< Scalar > &mv, const ArrayView< Scalar > &prods) const
RCP< const VectorSpaceBase< Scalar > > range() const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual void norms2Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
Node subclass that uses a default MultiVectorBase implementation to provide default implementations f...
RCP< const MultiVectorBase< Scalar > > nonContigSubViewImpl(const ArrayView< const int > &cols) const
void releaseDetachedMultiVectorViewImpl(RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
RCP< MultiVectorBase< Scalar > > getNonconstMultiVectorBlock(const int k)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
void acquireNonconstDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
Interface for a collection of column vectors called a multi-vector.
RCP< MultiVectorBase< Scalar > > nonconstContigSubViewImpl(const Range1D &colRng)
Concrete implementation of a product multi-vector.
virtual void linearCombinationImpl(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &mv, const Scalar &beta)
virtual void assignMultiVecImpl(const MultiVectorBase< Scalar > &mv)
RCP< MultiVectorBase< Scalar > > clone_mv() const
void norms(const MultiVectorBase< Scalar > &V, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector natural norm.
virtual void normsInfImpl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
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 VectorSpaceBase< Scalar > > domain() const
void commitNonconstDetachedMultiVectorViewImpl(RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
void initialize(const RCP< const DefaultProductVectorSpace< Scalar > > &productSpace, const int numMembers)
RCP< const MultiVectorBase< Scalar > > getMultiVectorBlock(const int k) const
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
RCP< const ProductVectorSpaceBase< Scalar > > productSpace() const
RCP< MultiVectorBase< Scalar > > nonconstNonContigSubViewImpl(const ArrayView< const int > &cols)
RCP< const MultiVectorBase< Scalar > > contigSubViewImpl(const Range1D &colRng) const
RCP< const VectorBase< Scalar > > colImpl(Ordinal j) const