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 //
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_VECTOR_DECL_HPP
43 #define THYRA_DEFAULT_PRODUCT_VECTOR_DECL_HPP
44 
45 #include "Thyra_ProductVectorBase.hpp"
46 #include "Thyra_VectorDefaultBase.hpp"
47 #include "Teuchos_ConstNonconstObjectContainer.hpp"
48 #include "Teuchos_as.hpp"
49 
50 
51 namespace Thyra {
52 
53 
55 template <class Scalar> class DefaultProductVectorSpace;
56 
57 
71 template<class Scalar>
73  : virtual public ProductVectorBase<Scalar>,
74  virtual protected VectorDefaultBase<Scalar>
75 {
76 public:
77 
80 
83 
87  );
88 
93  void initialize(
95  );
96 
101  void initialize(
103  const ArrayView<const RCP<VectorBase<Scalar> > > &vecs
104  );
105 
110  void initialize(
112  const ArrayView<const RCP<const VectorBase<Scalar> > > &vecs
113  );
114 
119  void uninitialize();
120 
122 
125 
127  std::string description() const;
128 
130  void describe(
132  const Teuchos::EVerbosityLevel verbLevel
133  ) const;
134 
136 
139 
141  void setBlock(int i, const RCP<const VectorBase<Scalar> >& b);
143  void setNonconstBlock(int i, const RCP<VectorBase<Scalar> >& b);
145 
148 
152  RCP<const VectorBase<Scalar> > getVectorBlock(const int k) const;
153 
155 
158 
162  bool blockIsConst(const int k) const;
165  getNonconstMultiVectorBlock(const int k);
168  getMultiVectorBlock(const int k) const;
169 
171 
174 
177 
179 
180 protected:
181 
184 
186  //virtual void randomizeImpl(Scalar l, Scalar u);
188  virtual void absImpl(const VectorBase<Scalar>& x);
190  virtual void reciprocalImpl(const VectorBase<Scalar>& x);
192  virtual void eleWiseScaleImpl(const VectorBase<Scalar>& x);
195  norm2WeightedImpl(const VectorBase<Scalar>& x) const;
197  void applyOpImpl(
198  const RTOpPack::RTOpT<Scalar> &op,
199  const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
200  const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
201  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
202  const Ordinal global_offset
203  ) const;
206  const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
207  ) const;
211  ) const;
214  const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
215  );
219  );
221  void setSubVectorImpl(
223  );
224 
226 
229 
231  virtual void assignImpl(Scalar alpha);
233  virtual void assignMultiVecImpl(const MultiVectorBase<Scalar>& mv);
235  virtual void scaleImpl(Scalar alpha);
237  virtual void updateImpl(
238  Scalar alpha,
239  const MultiVectorBase<Scalar>& mv
240  );
242  virtual void linearCombinationImpl(
243  const ArrayView<const Scalar>& alpha,
244  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > >& mv,
245  const Scalar& beta
246  );
248  virtual void dotsImpl(
249  const MultiVectorBase<Scalar>& mv,
250  const ArrayView<Scalar>& prods
251  ) const;
253  virtual void norms1Impl(
255  ) const;
257  virtual void norms2Impl(
259  ) const;
261  virtual void normsInfImpl(
263  ) const;
264 
265  //#}
266 
267 public:
268 
269 private:
270 
271  // //////////////////////////////
272  // Private types
273 
275 
276  // //////////////////////////////
277  // Private data members
278 
280  Array<CNVC> vecs_;
281  // cache
282  int numBlocks_;
283 
284 };
285 
286 
291 template<class Scalar>
292 inline
295 {
297 }
298 
299 
304 template<class Scalar>
305 inline
308  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace
309  )
310 {
311  return Teuchos::rcp(
312  new DefaultProductVector<Scalar>(productSpace)
313  );
314 }
315 
316 
321 template<class Scalar>
324  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
325  const ArrayView<const RCP<VectorBase<Scalar> > > &vecs
326  )
327 {
328  RCP<DefaultProductVector<Scalar> > pv = defaultProductVector<Scalar>();
329  pv->initialize(productSpace, vecs);
330  return pv;
331 }
332 
333 
338 template<class Scalar>
341  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
342  const ArrayView<const RCP<const VectorBase<Scalar> > > &vecs
343  )
344 {
345  RCP<DefaultProductVector<Scalar> > pv = defaultProductVector<Scalar>();
346  pv->initialize(productSpace, vecs);
347  return pv;
348 }
349 
350 
356 template<class Scalar>
358 castOrCreateNonconstProductVectorBase(const RCP<VectorBase<Scalar> > v);
359 
360 
366 template<class Scalar>
368 castOrCreateProductVectorBase(const RCP<const VectorBase<Scalar> > v);
369 
370 
371 } // namespace Thyra
372 
373 
374 #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