Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultProductVector_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_DEFAULT_PRODUCT_VECTOR_DECL_HPP
11 #define THYRA_DEFAULT_PRODUCT_VECTOR_DECL_HPP
12 
13 #include "Thyra_ProductVectorBase.hpp"
14 #include "Thyra_VectorDefaultBase.hpp"
15 #include "Teuchos_ConstNonconstObjectContainer.hpp"
16 #include "Teuchos_as.hpp"
17 
18 
19 namespace Thyra {
20 
21 
23 template <class Scalar> class DefaultProductVectorSpace;
24 
25 
39 template<class Scalar>
41  : virtual public ProductVectorBase<Scalar>,
42  virtual protected VectorDefaultBase<Scalar>
43 {
44 public:
45 
48 
51 
55  );
56 
61  void initialize(
63  );
64 
69  void initialize(
71  const ArrayView<const RCP<VectorBase<Scalar> > > &vecs
72  );
73 
78  void initialize(
80  const ArrayView<const RCP<const VectorBase<Scalar> > > &vecs
81  );
82 
87  void uninitialize();
88 
90 
93 
95  std::string description() const;
96 
98  void describe(
100  const Teuchos::EVerbosityLevel verbLevel
101  ) const;
102 
104 
107 
109  void setBlock(int i, const RCP<const VectorBase<Scalar> >& b);
111  void setNonconstBlock(int i, const RCP<VectorBase<Scalar> >& b);
113 
116 
120  RCP<const VectorBase<Scalar> > getVectorBlock(const int k) const;
121 
123 
126 
130  bool blockIsConst(const int k) const;
133  getNonconstMultiVectorBlock(const int k);
136  getMultiVectorBlock(const int k) const;
137 
139 
142 
145 
147 
148 protected:
149 
152 
154  //virtual void randomizeImpl(Scalar l, Scalar u);
156  virtual void absImpl(const VectorBase<Scalar>& x);
158  virtual void reciprocalImpl(const VectorBase<Scalar>& x);
160  virtual void eleWiseScaleImpl(const VectorBase<Scalar>& x);
163  norm2WeightedImpl(const VectorBase<Scalar>& x) const;
165  void applyOpImpl(
166  const RTOpPack::RTOpT<Scalar> &op,
167  const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
168  const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
169  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
170  const Ordinal global_offset
171  ) const;
174  const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
175  ) const;
179  ) const;
182  const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
183  );
187  );
189  void setSubVectorImpl(
191  );
192 
194 
197 
199  virtual void assignImpl(Scalar alpha);
201  virtual void assignMultiVecImpl(const MultiVectorBase<Scalar>& mv);
203  virtual void scaleImpl(Scalar alpha);
205  virtual void updateImpl(
206  Scalar alpha,
207  const MultiVectorBase<Scalar>& mv
208  );
210  virtual void linearCombinationImpl(
211  const ArrayView<const Scalar>& alpha,
212  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > >& mv,
213  const Scalar& beta
214  );
216  virtual void dotsImpl(
217  const MultiVectorBase<Scalar>& mv,
218  const ArrayView<Scalar>& prods
219  ) const;
221  virtual void norms1Impl(
223  ) const;
225  virtual void norms2Impl(
227  ) const;
229  virtual void normsInfImpl(
231  ) const;
232 
233  //#}
234 
235 public:
236 
237 private:
238 
239  // //////////////////////////////
240  // Private types
241 
243 
244  // //////////////////////////////
245  // Private data members
246 
248  Array<CNVC> vecs_;
249  // cache
250  int numBlocks_;
251 
252 };
253 
254 
259 template<class Scalar>
260 inline
263 {
265 }
266 
267 
272 template<class Scalar>
273 inline
276  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace
277  )
278 {
279  return Teuchos::rcp(
280  new DefaultProductVector<Scalar>(productSpace)
281  );
282 }
283 
284 
289 template<class Scalar>
292  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
293  const ArrayView<const RCP<VectorBase<Scalar> > > &vecs
294  )
295 {
296  RCP<DefaultProductVector<Scalar> > pv = defaultProductVector<Scalar>();
297  pv->initialize(productSpace, vecs);
298  return pv;
299 }
300 
301 
306 template<class Scalar>
309  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
310  const ArrayView<const RCP<const VectorBase<Scalar> > > &vecs
311  )
312 {
313  RCP<DefaultProductVector<Scalar> > pv = defaultProductVector<Scalar>();
314  pv->initialize(productSpace, vecs);
315  return pv;
316 }
317 
318 
324 template<class Scalar>
326 castOrCreateNonconstProductVectorBase(const RCP<VectorBase<Scalar> > v);
327 
328 
334 template<class Scalar>
336 castOrCreateProductVectorBase(const RCP<const VectorBase<Scalar> > v);
337 
338 
339 } // namespace Thyra
340 
341 
342 #endif // THYRA_DEFAULT_PRODUCT_VECTOR_DECL_HPP
virtual void norms2Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
virtual void normsInfImpl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
void setSubVectorImpl(const RTOpPack::SparseSubVectorT< Scalar > &sub_vec)
void commitNonconstDetachedVectorViewImpl(RTOpPack::SubVectorView< Scalar > *sub_vec)
Base interface for product vectors.
RCP< DefaultProductVector< Scalar > > defaultProductVector(const RCP< const DefaultProductVectorSpace< Scalar > > &productSpace)
Nonmember constructor.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual void updateImpl(Scalar alpha, const MultiVectorBase< Scalar > &mv)
RCP< const VectorBase< Scalar > > getVectorBlock(const int k) const
virtual void linearCombinationImpl(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &mv, const Scalar &beta)
void releaseDetachedVectorViewImpl(RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
RCP< DefaultProductVector< Scalar > > defaultProductVector()
Nonmember constructor.
virtual void absImpl(const VectorBase< Scalar > &x)
virtual void reciprocalImpl(const VectorBase< Scalar > &x)
virtual void assignMultiVecImpl(const MultiVectorBase< Scalar > &mv)
void setNonconstBlock(int i, const RCP< VectorBase< Scalar > > &b)
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)
virtual void dotsImpl(const MultiVectorBase< Scalar > &mv, const ArrayView< Scalar > &prods) const
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
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
DefaultProductVector()
Construct to uninitialized.
RCP< const VectorSpaceBase< Scalar > > space() const
void acquireNonconstDetachedVectorViewImpl(const Range1D &rng, RTOpPack::SubVectorView< Scalar > *sub_vec)
Abstract interface for finite-dimensional dense vectors.
void norms(const MultiVectorBase< Scalar > &V, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector natural norm.
virtual void eleWiseScaleImpl(const VectorBase< Scalar > &x)
Concrete implementation of a product vector.
RCP< VectorBase< Scalar > > getNonconstVectorBlock(const int k)
RCP< MultiVectorBase< Scalar > > getNonconstMultiVectorBlock(const int k)
RCP< DefaultProductVector< Scalar > > defaultProductVector(const RCP< const DefaultProductVectorSpace< Scalar > > &productSpace, const ArrayView< const RCP< const VectorBase< Scalar > > > &vecs)
Nonmember constructor.
RCP< DefaultProductVector< Scalar > > defaultProductVector(const RCP< const DefaultProductVectorSpace< Scalar > > &productSpace, const ArrayView< const RCP< VectorBase< Scalar > > > &vecs)
Nonmember constructor.
void acquireDetachedVectorViewImpl(const Range1D &rng, RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
RCP< const ProductVectorSpaceBase< Scalar > > productSpace() const
void setBlock(int i, const RCP< const VectorBase< Scalar > > &b)
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2WeightedImpl(const VectorBase< Scalar > &x) const
void initialize(const RCP< const DefaultProductVectorSpace< Scalar > > &productSpace)
Initialize.
RCP< const MultiVectorBase< Scalar > > getMultiVectorBlock(const int k) const
virtual void norms1Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const