Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultMultiVectorProductVector_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_PRODUCT_VECTOR_DECL_HPP
11 #define THYRA_MULTI_VECTOR_PRODUCT_VECTOR_DECL_HPP
12 
13 
14 #include "Thyra_ProductVectorBase.hpp" // Interface
15 #include "Thyra_VectorDefaultBase.hpp" // Implementation
16 #include "Thyra_DefaultProductVector.hpp"
17 #include "Teuchos_ConstNonconstObjectContainer.hpp"
18 
19 
20 namespace Thyra {
21 
22 
23 template<class Scalar> class DefaultMultiVectorProductVectorSpace;
24 
25 
37 template<class Scalar>
39  : virtual public ProductVectorBase<Scalar>,
40  virtual protected VectorDefaultBase<Scalar>
41 {
42 public:
43 
46 
49 
51  void initialize(
53  const RCP<MultiVectorBase<Scalar> > &multiVec
54  );
55 
57  void initialize(
59  const RCP<const MultiVectorBase<Scalar> > &multiVec
60  );
61 
62  // ToDo: Add const version of above function also when needed!
63 
67 
70  getMultiVector() const;
71 
73  void uninitialize();
74 
76 
79 
81  std::string description() const;
82 
84  void describe(
86  const Teuchos::EVerbosityLevel verbLevel
87  ) const;
88 
90 
93 
96  getNonconstVectorBlock(const int k);
99  getVectorBlock(const int k) const;
100 
102 
105 
108  productSpace() const;
110  bool blockIsConst(const int k) const;
113  getNonconstMultiVectorBlock(const int k);
116  getMultiVectorBlock(const int k) const;
117 
119 
122 
125 
127 
128 protected:
129 
132 
134  virtual void randomizeImpl(Scalar l, Scalar u);
136  virtual void absImpl(const VectorBase<Scalar>& x);
138  virtual void reciprocalImpl(const VectorBase<Scalar>& x);
140  virtual void eleWiseScaleImpl(const VectorBase<Scalar>& x);
143  norm2WeightedImpl(const VectorBase<Scalar>& x) const;
145  void applyOpImpl(
146  const RTOpPack::RTOpT<Scalar> &op,
147  const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
148  const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
149  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
150  const Ordinal global_offset
151  ) const;
154  const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
155  ) const;
159  ) const;
162  const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
163  );
167  );
169  void setSubVectorImpl(
171  );
172 
174 
177 
179  virtual void assignImpl(Scalar alpha);
181  virtual void assignMultiVecImpl(const MultiVectorBase<Scalar>& mv);
183  virtual void scaleImpl(Scalar alpha);
185  virtual void updateImpl(
186  Scalar alpha,
187  const MultiVectorBase<Scalar>& mv
188  );
190  virtual void linearCombinationImpl(
191  const ArrayView<const Scalar>& alpha,
192  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > >& mv,
193  const Scalar& beta
194  );
196  virtual void dotsImpl(
197  const MultiVectorBase<Scalar>& mv,
198  const ArrayView<Scalar>& prods
199  ) const;
201  virtual void norms1Impl(
203  ) const;
205  virtual void norms2Impl(
207  ) const;
209  virtual void normsInfImpl(
211  ) const;
212 
214 
215 private:
216 
217  // //////////////////////////////
218  // Private types
219 
221 
222  // //////////////////////////////
223  // Private data members
224 
225  int numBlocks_;
227  CNMVC multiVec_;
228 
229  // //////////////////////////////
230  // Private member functions
231 
233  getDefaultProductVector() const;
234 
235 };
236 
237 
243 template<class Scalar>
244 inline
247  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
248  const RCP<MultiVectorBase<Scalar> > &multiVec
249  )
250 {
253  multiVecProdVec->initialize(productSpace,multiVec);
254  return multiVecProdVec;
255 }
256 
257 
263 template<class Scalar>
264 inline
267  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
268  const RCP<const MultiVectorBase<Scalar> > &multiVec
269  )
270 {
273  multiVecProdVec->initialize(productSpace,multiVec);
274  return multiVecProdVec;
275 }
276 
277 
278 // ToDo: Add non-const and const versions of the nonmember constructor
279 // functions to wrap already created multi-vectors once needed!
280 
281 
287 template<class Scalar>
288 inline
291  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace
292  )
293 {
294 #ifdef TEUCHOS_DEBUG
295  TEUCHOS_TEST_FOR_EXCEPT(is_null(productSpace));
296 #endif
297  return multiVectorProductVector(
298  productSpace,
299  createMembers(productSpace->getBlock(0),productSpace->numBlocks())
300  );
301 }
302 
303 
304 } // namespace Thyra
305 
306 
307 #endif // THYRA_MULTI_VECTOR_PRODUCT_VECTOR_DECL_HPP
virtual void normsInfImpl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
bool is_null(const boost::shared_ptr< T > &p)
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Base interface for product vectors.
virtual void norms2Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
RCP< const VectorBase< Scalar > > getVectorBlock(const int k) const
void releaseDetachedVectorViewImpl(RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
virtual void eleWiseScaleImpl(const VectorBase< Scalar > &x)
Concrete implementation of a product vector which is really composed out of the columns of a multi-ve...
RCP< const MultiVectorBase< Scalar > > getMultiVectorBlock(const int k) const
void commitNonconstDetachedVectorViewImpl(RTOpPack::SubVectorView< Scalar > *sub_vec)
RCP< const ProductVectorSpaceBase< Scalar > > productSpace() const
Convenient node subclass for concrete VectorBase subclasses that relies on a default MultiVectorBase ...
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.
RCP< DefaultMultiVectorProductVector< Scalar > > multiVectorProductVector(const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &productSpace)
Nonmember constructor that creates a new uninitialized product vector represented underneath as a mul...
void acquireNonconstDetachedVectorViewImpl(const Range1D &rng, RTOpPack::SubVectorView< Scalar > *sub_vec)
void acquireDetachedVectorViewImpl(const Range1D &rng, RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
Abstract interface for finite-dimensional dense vectors.
RCP< const MultiVectorBase< Scalar > > getMultiVector() const
void norms(const MultiVectorBase< Scalar > &V, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector natural norm.
Standard concrete implementation of a product vector space that creates product vectors fromed implic...
virtual void norms1Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
void initialize(const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &productSpace, const RCP< MultiVectorBase< Scalar > > &multiVec)
Initialize with a non-const multi-vector.
virtual void updateImpl(Scalar alpha, const MultiVectorBase< Scalar > &mv)
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2WeightedImpl(const VectorBase< Scalar > &x) const
virtual void dotsImpl(const MultiVectorBase< Scalar > &mv, const ArrayView< Scalar > &prods) const
RCP< const DefaultMultiVectorProductVector< Scalar > > multiVectorProductVector(const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &productSpace, const RCP< const MultiVectorBase< Scalar > > &multiVec)
Nonmember constructor that just wraps an existing const MultiVector as a const product vector...
virtual void assignMultiVecImpl(const MultiVectorBase< Scalar > &mv)
void applyOpImpl(const RTOpPack::RTOpT< Scalar > &op, const ArrayView< const Ptr< const VectorBase< Scalar > > > &vecs, const ArrayView< const Ptr< VectorBase< Scalar > > > &targ_vecs, const Ptr< RTOpPack::ReductTarget > &reduct_obj, const Ordinal global_offset) const
RCP< MultiVectorBase< Scalar > > getNonconstMultiVectorBlock(const int k)
RCP< const VectorSpaceBase< Scalar > > space() const
RCP< DefaultMultiVectorProductVector< Scalar > > multiVectorProductVector(const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &productSpace, const RCP< MultiVectorBase< Scalar > > &multiVec)
Nonmember constructor that just wraps an existing non-const MultiVector as a non-const product vector...
RCP< VectorBase< Scalar > > getNonconstVectorBlock(const int k)
virtual void linearCombinationImpl(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &mv, const Scalar &beta)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
virtual void reciprocalImpl(const VectorBase< Scalar > &x)
void setSubVectorImpl(const RTOpPack::SparseSubVectorT< Scalar > &sub_vec)