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 //
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_PRODUCT_VECTOR_DECL_HPP
43 #define THYRA_MULTI_VECTOR_PRODUCT_VECTOR_DECL_HPP
44 
45 
46 #include "Thyra_ProductVectorBase.hpp" // Interface
47 #include "Thyra_VectorDefaultBase.hpp" // Implementation
48 #include "Thyra_DefaultProductVector.hpp"
49 #include "Teuchos_ConstNonconstObjectContainer.hpp"
50 
51 
52 namespace Thyra {
53 
54 
55 template<class Scalar> class DefaultMultiVectorProductVectorSpace;
56 
57 
69 template<class Scalar>
71  : virtual public ProductVectorBase<Scalar>,
72  virtual protected VectorDefaultBase<Scalar>
73 {
74 public:
75 
78 
81 
83  void initialize(
85  const RCP<MultiVectorBase<Scalar> > &multiVec
86  );
87 
89  void initialize(
91  const RCP<const MultiVectorBase<Scalar> > &multiVec
92  );
93 
94  // ToDo: Add const version of above function also when needed!
95 
99 
102  getMultiVector() const;
103 
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  getNonconstVectorBlock(const int k);
131  getVectorBlock(const int k) const;
132 
134 
137 
140  productSpace() const;
142  bool blockIsConst(const int k) const;
145  getNonconstMultiVectorBlock(const int k);
148  getMultiVectorBlock(const int k) const;
149 
151 
154 
157 
159 
160 protected:
161 
164 
166  virtual void randomizeImpl(Scalar l, Scalar u);
168  virtual void absImpl(const VectorBase<Scalar>& x);
170  virtual void reciprocalImpl(const VectorBase<Scalar>& x);
172  virtual void eleWiseScaleImpl(const VectorBase<Scalar>& x);
175  norm2WeightedImpl(const VectorBase<Scalar>& x) const;
177  void applyOpImpl(
178  const RTOpPack::RTOpT<Scalar> &op,
179  const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
180  const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
181  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
182  const Ordinal global_offset
183  ) const;
186  const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
187  ) const;
191  ) const;
194  const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
195  );
199  );
201  void setSubVectorImpl(
203  );
204 
206 
209 
211  virtual void assignImpl(Scalar alpha);
213  virtual void assignMultiVecImpl(const MultiVectorBase<Scalar>& mv);
215  virtual void scaleImpl(Scalar alpha);
217  virtual void updateImpl(
218  Scalar alpha,
219  const MultiVectorBase<Scalar>& mv
220  );
222  virtual void linearCombinationImpl(
223  const ArrayView<const Scalar>& alpha,
224  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > >& mv,
225  const Scalar& beta
226  );
228  virtual void dotsImpl(
229  const MultiVectorBase<Scalar>& mv,
230  const ArrayView<Scalar>& prods
231  ) const;
233  virtual void norms1Impl(
235  ) const;
237  virtual void norms2Impl(
239  ) const;
241  virtual void normsInfImpl(
243  ) const;
244 
246 
247 private:
248 
249  // //////////////////////////////
250  // Private types
251 
253 
254  // //////////////////////////////
255  // Private data members
256 
257  int numBlocks_;
259  CNMVC multiVec_;
260 
261  // //////////////////////////////
262  // Private member functions
263 
265  getDefaultProductVector() const;
266 
267 };
268 
269 
275 template<class Scalar>
276 inline
279  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
280  const RCP<MultiVectorBase<Scalar> > &multiVec
281  )
282 {
285  multiVecProdVec->initialize(productSpace,multiVec);
286  return multiVecProdVec;
287 }
288 
289 
295 template<class Scalar>
296 inline
299  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
300  const RCP<const MultiVectorBase<Scalar> > &multiVec
301  )
302 {
305  multiVecProdVec->initialize(productSpace,multiVec);
306  return multiVecProdVec;
307 }
308 
309 
310 // ToDo: Add non-const and const versions of the nonmember constructor
311 // functions to wrap already created multi-vectors once needed!
312 
313 
319 template<class Scalar>
320 inline
323  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace
324  )
325 {
326 #ifdef TEUCHOS_DEBUG
327  TEUCHOS_TEST_FOR_EXCEPT(is_null(productSpace));
328 #endif
329  return multiVectorProductVector(
330  productSpace,
331  createMembers(productSpace->getBlock(0),productSpace->numBlocks())
332  );
333 }
334 
335 
336 } // namespace Thyra
337 
338 
339 #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)