Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultMultiVectorProductVectorSpace_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_MULTI_VECTOR_PRODUCT_VECTOR_SPACE_DECL_HPP
43 #define THYRA_DEFAULT_MULTI_VECTOR_PRODUCT_VECTOR_SPACE_DECL_HPP
44 
45 #include "Thyra_ProductVectorSpaceBase.hpp" // Interface
46 #include "Thyra_DefaultProductVectorSpace.hpp" // Implementation
47 #include "Thyra_VectorSpaceDefaultBase.hpp"
48 
49 
50 namespace Thyra {
51 
52 
64 template<class Scalar>
65 class DefaultMultiVectorProductVectorSpace
66  : virtual public ProductVectorSpaceBase<Scalar>
67  , virtual protected VectorSpaceDefaultBase<Scalar>
68 {
69 public:
70 
73 
76 
96  void initialize(
97  const RCP<const VectorSpaceBase<Scalar> > &space,
98  const int numColumns
99  );
100 
102  RCP<const DefaultProductVectorSpace<Scalar> >
104 
125  void uninitialize(
126  RCP<const VectorSpaceBase<Scalar> > *space = 0,
127  int *numColumns = 0
128  );
129 
131 
134 
136  int numBlocks() const;
138  RCP<const VectorSpaceBase<Scalar> > getBlock(const int k) const;
139 
141 
144 
146  Ordinal dim() const;
148  bool isCompatible( const VectorSpaceBase<Scalar>& vecSpc ) const;
150  RCP< VectorBase<Scalar> > createMember() const;
152  Scalar scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) const;
156  void scalarProdsImpl(
157  const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y,
158  const ArrayView<Scalar> &scalarProds ) const;
162  bool hasInCoreView( const Range1D& rng, const EViewType viewType,
163  const EStrideType strideType ) const;
165  RCP< const VectorSpaceFactoryBase<Scalar> > smallVecSpcFcty() const;
174  RCP< MultiVectorBase<Scalar> > createMembers(int numMembers) const;
176  RCP< const VectorSpaceBase<Scalar> > clone() const;
177 
179 
182 
186  std::string description() const;
187 
195  void describe(
197  const Teuchos::EVerbosityLevel verbLevel
198  ) const;
199 
201 
202 private:
203 
204  // ///////////////////////////////////
205  // Private data members
206 
207  RCP<const VectorSpaceBase<Scalar> > space_;
208  int numColumns_;
209  RCP<const DefaultProductVectorSpace<Scalar> > defaultProdVecSpc_;
210 
211  // ///////////////////////////////////
212  // Private member functions
213 
214  void assertInitialized() const;
215 
216 };
217 
218 
223 template<class Scalar>
224 inline
225 RCP<DefaultMultiVectorProductVectorSpace<Scalar> >
227 {
229 }
230 
231 
236 template<class Scalar>
237 inline
240  const RCP<const VectorSpaceBase<Scalar> > &space,
241  const int numColumns
242  )
243 {
244  RCP<DefaultMultiVectorProductVectorSpace<Scalar> > multiVecProdVecSpace =
245  multiVectorProductVectorSpace<Scalar>();
246  multiVecProdVecSpace->initialize(space,numColumns);
247  return multiVecProdVecSpace;
248 }
249 
250 
251 // /////////////////////////////////
252 // Inline members
253 
254 
255 template<class Scalar>
256 inline
259 {
260  return defaultProdVecSpc_;
261 }
262 
263 
264 template<class Scalar>
265 inline
267 {
268 #ifdef TEUCHOS_DEBUG
269  TEUCHOS_TEST_FOR_EXCEPT( is_null(space_) );
270 #endif
271 }
272 
273 
274 } // namespace Thyra
275 
276 
277 #endif // THYRA_DEFAULT_MULTI_VECTOR_PRODUCT_VECTOR_SPACE_DECL_HPP
void uninitialize(RCP< const VectorSpaceBase< Scalar > > *space=0, int *numColumns=0)
Uninitialize.
RCP< const VectorSpaceBase< Scalar > > clone() const
Clones the object as promised.
bool is_null(const boost::shared_ptr< T > &p)
RCP< DefaultMultiVectorProductVectorSpace< Scalar > > multiVectorProductVectorSpace(const RCP< const VectorSpaceBase< Scalar > > &space, const int numColumns)
Nonmember constructor function.
Scalar scalarProd(const VectorBase< Scalar > &x, const VectorBase< Scalar > &y) const
Returns the sum of the scalar products of the constituent vectors.
void initialize(const RCP< const VectorSpaceBase< Scalar > > &space, const int numColumns)
Initialize with a list of constituent vector spaces.
RCP< DefaultMultiVectorProductVectorSpace< Scalar > > multiVectorProductVectorSpace()
Nonmember constructor function.
Abstract interface for objects that represent a space for vectors.
EViewType
Determines if a view is a direct view of data or a detached copy of data.
bool isCompatible(const VectorSpaceBase< Scalar > &vecSpc) const
RCP< const VectorSpaceFactoryBase< Scalar > > smallVecSpcFcty() const
Returns getBlock(0)-&gt;smallVecSpcFcty().
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Prints the details about the constituent vector space.
void scalarProdsImpl(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds) const
Returns the sum of the scalar products of each of the columns of the constituent multi-vectors.
RCP< const DefaultProductVectorSpace< Scalar > > getDefaultProductVectorSpace() const
bool hasInCoreView(const Range1D &rng, const EViewType viewType, const EStrideType strideType) const
Returns true if all of the constituent vector spaces return true.
Standard concrete implementation of a product vector space that creates product vectors fromed implic...
RCP< VectorBase< Scalar > > createMember() const
Returns a DefaultMultiVectorProductVector object.
RCP< const VectorSpaceBase< Scalar > > getBlock(const int k) const
EStrideType
Determine if data is unit stride or non-unit stride.
void scalarProds(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds_out) const
Return the scalar product of each column in two multi-vectors in the vector space.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
RCP< MultiVectorBase< Scalar > > createMembers(int numMembers) const
Returns a DefaultColumnwiseMultiVector object.
std::string description() const
Prints just the name DefaultMultiVectorProductVectorSpace along with the overall dimension and the nu...
Teuchos::Range1D Range1D