Thyra::DefaultProductVectorSpace< Scalar > Class Template Reference
[Development of linear Abstract Numerical Algorithms (ANAs)]

Standard concrete implementation of a product vector space. More...

#include <Thyra_DefaultProductVectorSpaceDecl.hpp>

Inheritance diagram for Thyra::DefaultProductVectorSpace< Scalar >:

[legend]
List of all members.

Constructors/initializers/accessors

 DefaultProductVectorSpace (const int numBlocks, const Teuchos::RefCountPtr< const VectorSpaceBase< Scalar > > vecSpaces[])
 Construct to an initialized state (calls initialize).
virtual void initialize (const int numBlocks, const Teuchos::RefCountPtr< const VectorSpaceBase< Scalar > > vecSpaces[])
 Initialize with a list of constituent vector spaces.
bool hasBeenCloned () const
 Return if this vector space was cloned.
virtual void uninitialize (int *numBlocks=NULL, Teuchos::RefCountPtr< const VectorSpaceBase< Scalar > > vecSpaces[]=NULL)
 Uninitialize.
virtual const Teuchos::RefCountPtr<
const VectorSpaceBase< Scalar > > * 
vecSpaces () const
 Returns a pointer to an array (of length this->numBlocks()) to the constituent vector spaces.
virtual const IndexvecSpacesOffsets () const
 Returns a pointer to an array (of length this->numBlocks()+1) of offset into each constituent vector space.
void getVecSpcPoss (Index i, int *kth_vector_space, Index *kth_global_offset) const
 Get the position of the vector space object and its offset into a composite vector that owns the ith index in the composite vector.

Overridden from DefaultProductVectorSpace

int numBlocks () const
 
Teuchos::RefCountPtr< const
VectorSpaceBase< Scalar > > 
getBlock (const int k) const
 

Overridden from VectorSpaceBase

Index dim () const
 Returns the summation of the constituent vector spaces.
bool isCompatible (const VectorSpaceBase< Scalar > &vecSpc) const
 Returns true only if also a product vector space and all constituent vectors are compatible.
Teuchos::RefCountPtr< VectorBase<
Scalar > > 
createMember () const
 Returns a DefaultProductVector object.
Scalar scalarProd (const VectorBase< Scalar > &x, const VectorBase< Scalar > &y) const
 Returns the sum of the scalar products of the constituent vectors.
void scalarProds (const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, Scalar scalar_prods[]) const
 Returns the sum of the scalar products of each of the columns of the constituent multi-vectors.
bool hasInCoreView (const Range1D &rng, const EViewType viewType, const EStrideType strideType) const
 Returns true if all of the constituent vector spaces return true.
Teuchos::RefCountPtr< const
VectorSpaceFactoryBase< Scalar > > 
smallVecSpcFcty () const
 Returns getBlock(0)->smallVecSpcFcty().
Teuchos::RefCountPtr< MultiVectorBase<
Scalar > > 
createMembers (int numMembers) const
 Returns a DefaultProductMultiVector object.
Teuchos::RefCountPtr< const
VectorSpaceBase< Scalar > > 
clone () const
 Clones the object as promised.

Protected Member Functions

 DefaultProductVectorSpace ()
 Added to allow TSFExtended DefaultProductVectorSpace to derive from this.

Detailed Description

template<class Scalar>
class Thyra::DefaultProductVectorSpace< Scalar >

Standard concrete implementation of a product vector space.

This subclass allows VectorSpaceBase objects to be built out of one or more other vector space objects to form a product space. The specific type of vector created by this->createMember() is of type DefaultProductVector but the client need not ever know this or deal with this type directly. However, a client may want to dynamic_cast to access the ProductVectorBase interface.

To demonstrate how to use this class, suppose one has p vector spaces V[k] for k = 0...p-1 and one wants to form a concatenated vector space Z containing all of these vector spaces stacked on top of each other to form:


     [ V[0]   ]
 Z = [ V[1]   ]
     [ .      ]
     [ V[p-1] ]
 

Such a vector space can be constructed out of an array of p constituent VectorSpaceBase objects as shown in the following function:

 void constructProductSpace(
   const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > V[], int p
   ,Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > *Z
   )
 {
   *Z = Teuchos::rcp(new DefaultProductVectorSpace<Scalar>(V,p));
 }

Or, a product space can be constructed out of p copies of the same VectorSpaceBase object as follows:

 void constructProductSpace(
   const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > V, int p
   ,Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > *Z
   )
 {
   std::vector<Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > > vecSpaces(p);
   for( int k = 0; k < p; ++k ) vecSpaces[k] = V;
   *Z = Teuchos::rcp(new DefaultProductVectorSpace<Scalar>(&vecSpaces[0],p);
 }

Once a DefaultProductVectorSpace object is initialized, it can be used just like any other VectorSpaceBase object. The method createMember() will create DefaultProductVector objects containing vector members from the constituent vector spaces. The method createMembers() will create ProductMultiVector objects containing multi-vector members from the constituent vector spaces.

There are several methods that can be used by clients that need to work with the individual constituent vector spaces. The method numBlocks() give the number of constituent vector spaces while vecSpaces() returns a pointer to a copy of the array of the constituent vector spaces passed to initialize(). Some other useful utility methods are also defined. The method vecSpacesOffsets() returns a pointer to an array that gives the offset of each constituent vector in the overall composite product vector. For example, the (zero-based) kth vector space this->vecSpaces()[k] owns the element indexes this->vecSpacesOffsets()[k] to this->vecSpacesOffsets()[k+1]-1. Determining which constituent vector space owns a particular element index can be found out by calling getVecSpcPoss().

The default assignment operator is allowed since it has the correct semantics for shallow copy. The default copy constructor is also allowed but only performs a shallow copy of the constituent vector space objects. If you want to copy the constituent vector space objects also you need to use the clone() method. The default constructor is not allowed (declared private) to avoid accidents.

Examples:

test_product_space.cpp, and test_std_ops.cpp.

Definition at line 123 of file Thyra_DefaultProductVectorSpaceDecl.hpp.


Constructor & Destructor Documentation

template<class Scalar>
Thyra::DefaultProductVectorSpace< Scalar >::DefaultProductVectorSpace const int  numBlocks,
const Teuchos::RefCountPtr< const VectorSpaceBase< Scalar > >  vecSpaces[]
 

Construct to an initialized state (calls initialize).

Definition at line 42 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
Thyra::DefaultProductVectorSpace< Scalar >::DefaultProductVectorSpace  )  [inline, protected]
 

Added to allow TSFExtended DefaultProductVectorSpace to derive from this.

Definition at line 305 of file Thyra_DefaultProductVectorSpaceDecl.hpp.


Member Function Documentation

template<class Scalar>
void Thyra::DefaultProductVectorSpace< Scalar >::initialize const int  numBlocks,
const Teuchos::RefCountPtr< const VectorSpaceBase< Scalar > >  vecSpaces[]
[virtual]
 

Initialize with a list of constituent vector spaces.

Parameters:
numBlocks [in] The number of constituent vector spaces.
vecSpaces [in] If vecSpaces!=NULL then vecSpaces must point to an array of length this->numBlocks and on output vecSpace[i] will be set to this->vecSpaces()[i] for i=0,..,this->numBlocks()-1.
Preconditions:
  • numBlocks > 0
  • vecSpaces != NULL
  • vecSpaces[i].get() != NULL, i=0,...,numBlocks
  • The vector space create by vecSpace[i]->smallVecSpcFcty()->createVecSpc(k) must be compatible. In other words, vecSpace[i]->smallVecSpcFcty()->createVecSpc(k)->isCompatible( *vecSpace[j]->smallVecSpcFcty()->createVecSpc(k) ) == true for all i=[0,numBlocks], j=[0,numBlocks] and valid k > 0. This is required to insure that product multi-vectors can be created with constituent multi-vector blocks that have compatible domain() vector spaces.

Postconditions:

  • this->dim() == sum( vecSpaces[i]->dim(), i=0,...,numBlocks-1 )
  • this->numBlocks()==numBlocks
  • getBlock(i).get() == vecSpaces[i].get(), i=0,...,numBlocks-1
  • vecSpaces()[i].get() == vecSpaces[i].get(), i=0,...,numBlocks-1

Definition at line 51 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
bool Thyra::DefaultProductVectorSpace< Scalar >::hasBeenCloned  )  const [inline]
 

Return if this vector space was cloned.

If this function returns true then the client needs to be careful about how the constituent vector spaces returned from uninitialize() will be used.

Definition at line 326 of file Thyra_DefaultProductVectorSpaceDecl.hpp.

template<class Scalar>
void Thyra::DefaultProductVectorSpace< Scalar >::uninitialize int *  numBlocks = NULL,
Teuchos::RefCountPtr< const VectorSpaceBase< Scalar > >  vecSpaces[] = NULL
[virtual]
 

Uninitialize.

Parameters:
numBlocks [out] If numBlocks!=NULL then on output *numBlocks will be set to this->numBlocks().
vecSpaces [out] If vecSpaces!=NULL then vecSpaces must point to an array of length this->numBlocks and on output vecSpace[i] will be set to this->vecSpaces()[i] for i=0,..,this->numBlocks()-1.
Postconditions:

Warning! If this->hasBeenCloned()==true then the client had better not mess with the constituent vector spaces returned in vecSpaces[] since another DefaultProductVectorSpace object is still using them.

Definition at line 87 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
const Teuchos::RefCountPtr< const VectorSpaceBase< Scalar > > * Thyra::DefaultProductVectorSpace< Scalar >::vecSpaces  )  const [inline, virtual]
 

Returns a pointer to an array (of length this->numBlocks()) to the constituent vector spaces.

Postconditions:

Definition at line 314 of file Thyra_DefaultProductVectorSpaceDecl.hpp.

template<class Scalar>
const Index * Thyra::DefaultProductVectorSpace< Scalar >::vecSpacesOffsets  )  const [inline, virtual]
 

Returns a pointer to an array (of length this->numBlocks()+1) of offset into each constituent vector space.

Postconditions:

Definition at line 320 of file Thyra_DefaultProductVectorSpaceDecl.hpp.

template<class Scalar>
void Thyra::DefaultProductVectorSpace< Scalar >::getVecSpcPoss Index  i,
int *  kth_vector_space,
Index kth_global_offset
const
 

Get the position of the vector space object and its offset into a composite vector that owns the ith index in the composite vector.

Preconditions:

Postconditions:

  • kth_global_offset == this->vecSpacesoffsets()[kth_vector-space]
  • kth_global_offset <= i <= kth_global_offset + this->vecSpaces()[kth_vector_space]->dim() - 1

Parameters:
i [in] The index offset of the element to find the vector space object for.
kth_vector_space [out] The index for this->vectorSpaces()[kth_vector_space] that owns the element i.
kth_global_offset [out] The global offset for this->vectorSpaces()[kth_vector_space] in the composite vector.

Definition at line 99 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
int Thyra::DefaultProductVectorSpace< Scalar >::numBlocks  )  const [virtual]
 

Implements Thyra::ProductVectorSpaceBase< Scalar >.

Definition at line 127 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
Teuchos::RefCountPtr< const VectorSpaceBase< Scalar > > Thyra::DefaultProductVectorSpace< Scalar >::getBlock const int  k  )  const [virtual]
 

Implements Thyra::ProductVectorSpaceBase< Scalar >.

Definition at line 134 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
Index Thyra::DefaultProductVectorSpace< Scalar >::dim  )  const [virtual]
 

Returns the summation of the constituent vector spaces.

Implements Thyra::VectorSpaceBase< Scalar >.

Definition at line 143 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
bool Thyra::DefaultProductVectorSpace< Scalar >::isCompatible const VectorSpaceBase< Scalar > &  vecSpc  )  const [virtual]
 

Returns true only if also a product vector space and all constituent vectors are compatible.

Implements Thyra::VectorSpaceBase< Scalar >.

Definition at line 149 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
Teuchos::RefCountPtr< VectorBase< Scalar > > Thyra::DefaultProductVectorSpace< Scalar >::createMember  )  const [virtual]
 

Returns a DefaultProductVector object.

Implements Thyra::VectorSpaceBase< Scalar >.

Definition at line 171 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
Scalar Thyra::DefaultProductVectorSpace< Scalar >::scalarProd const VectorBase< Scalar > &  x,
const VectorBase< Scalar > &  y
const [virtual]
 

Returns the sum of the scalar products of the constituent vectors.

Implements Thyra::VectorSpaceBase< Scalar >.

Definition at line 179 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
void Thyra::DefaultProductVectorSpace< Scalar >::scalarProds const MultiVectorBase< Scalar > &  X,
const MultiVectorBase< Scalar > &  Y,
Scalar  scalar_prods[]
const [virtual]
 

Returns the sum of the scalar products of each of the columns of the constituent multi-vectors.

Implements Thyra::VectorSpaceBase< Scalar >.

Definition at line 203 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
bool Thyra::DefaultProductVectorSpace< Scalar >::hasInCoreView const Range1D rng,
const EViewType  viewType,
const EStrideType  strideType
const [virtual]
 

Returns true if all of the constituent vector spaces return true.

Reimplemented from Thyra::VectorSpaceBase< Scalar >.

Definition at line 238 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
Teuchos::RefCountPtr< const VectorSpaceFactoryBase< Scalar > > Thyra::DefaultProductVectorSpace< Scalar >::smallVecSpcFcty  )  const [virtual]
 

Returns getBlock(0)->smallVecSpcFcty().

Implements Thyra::VectorSpaceBase< Scalar >.

Definition at line 274 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
Teuchos::RefCountPtr< MultiVectorBase< Scalar > > Thyra::DefaultProductVectorSpace< Scalar >::createMembers int  numMembers  )  const [virtual]
 

Returns a DefaultProductMultiVector object.

Reimplemented from Thyra::VectorSpaceDefaultBase< Scalar >.

Definition at line 282 of file Thyra_DefaultProductVectorSpace.hpp.

template<class Scalar>
Teuchos::RefCountPtr< const VectorSpaceBase< Scalar > > Thyra::DefaultProductVectorSpace< Scalar >::clone  )  const [virtual]
 

Clones the object as promised.

Reimplemented from Thyra::VectorSpaceBase< Scalar >.

Definition at line 292 of file Thyra_DefaultProductVectorSpace.hpp.


The documentation for this class was generated from the following files:
Generated on Thu Sep 18 12:32:33 2008 for Thyra Operator/Vector Support by doxygen 1.3.9.1