AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | List of all members
AbstractLinAlgPack::VectorSpaceBlocked Class Reference

VectorSpace subclass for the composite of one or more VectorSpace objects. More...

#include <AbstractLinAlgPack_VectorSpaceBlocked.hpp>

Inheritance diagram for AbstractLinAlgPack::VectorSpaceBlocked:
Inheritance graph
[legend]

Public Member Functions

 VectorSpaceBlocked (const VectorSpace::space_ptr_t vector_spaces[], int num_vector_spaces, const VectorSpace::space_fcty_ptr_t &small_vec_spc_fcty=Teuchos::null)
 Construct the vector space object. More...
 
void initialize (const VectorSpace::space_ptr_t vec_spaces[], int num_vector_spaces, const VectorSpace::space_fcty_ptr_t &small_vec_spc_fcty=Teuchos::null)
 Initialize with a set of vector space objects. More...
 
int num_vector_spaces () const
 Return the value of num_vec_spaces passed to this->initialize(). More...
 
const VectorSpace::space_ptr_tvector_spaces () const
 
const index_type * vector_spaces_offsets () const
 Returns array (length this->num_vector_spaces() + 1) of offsets for each constitient vector space in the composite vector. More...
 
void get_vector_space_position (index_type i, int *kth_vector_space, index_type *kth_global_offset) const
 Get the position of the vector space object and its offset into the composite vector of the vector space object that owns the ith index in the composite vector. More...
 
- Public Member Functions inherited from AbstractLinAlgPack::VectorSpace
space_ptr_t sub_space (const index_type il, const index_type iu) const
 Inlined to call this->sub_space(Range1D(il,iu)). More...
 
virtual space_ptr_t space (const GenPermMatrixSlice &P, BLAS_Cpp::Transp P_trans) const
 Create a vector space for vector to gather the elements into. More...
 
 VectorSpace (const inner_prod_ptr_t &inner_prod=Teuchos::null)
 Calls inner_prod() More...
 
virtual void inner_prod (const inner_prod_ptr_t &inner_prod)
 Initialize with an inner product object. More...
 
virtual const inner_prod_ptr_t inner_prod () const
 Return the smart pointer to the inner product strategy object. More...
 
virtual bool is_in_core () const
 Returns true if the vectors are in core. More...
 
virtual vec_mut_ptr_t create_member (const value_type &alpha) const
 Create a vector member from the vector space initialized to a scalar. More...
 
obj_ptr_t create () const
 Just calls this->create_member() by default! More...
 

Overridden from VectorSpace

bool is_compatible (const VectorSpace &vec_space) const
 Returns true if same type and has compatible vector spaces. More...
 
index_type dim () const
 
space_fcty_ptr_t small_vec_spc_fcty () const
 
vec_mut_ptr_t create_member () const
 
multi_vec_mut_ptr_t create_members (size_type num_vecs) const
 
space_ptr_t clone () const
 
space_ptr_t sub_space (const Range1D &rng) const
 

Additional Inherited Members

- Public Types inherited from AbstractLinAlgPack::VectorSpace
typedef Teuchos::RCP< const
InnerProduct
inner_prod_ptr_t
 
typedef Teuchos::RCP< const
VectorSpace
space_ptr_t
 
typedef Teuchos::RCP< const
VectorSpaceFactory
space_fcty_ptr_t
 
typedef Teuchos::RCP
< VectorMutable
vec_mut_ptr_t
 
typedef Teuchos::RCP
< MultiVectorMutable
multi_vec_mut_ptr_t
 

Detailed Description

VectorSpace subclass for the composite of one or more VectorSpace objects.

This subclass allows VectorSpace objects to be built out of one or more other vector space objects. This is essentially the product of vector spaces. The specific type of vector created by a VectorSpaceBlocked object is of type VectorMutableBlocked but the client need not ever know this or deal with this type directly.

For example, suppose you have p vector spaces V[k] for k = 0...p-1 and want 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 as shown if the following function:

void f( const VectorSpace::space_ptr_t V[], int p, VectorSpaceBlocked* Z )
{
Z->initialize( V, p );
}

Once a VectorSpaceBlocked object is initialized, it can be used just like any other VectorSpace object. The method create_member() will create VectorWithOpMutableCompoisteStd objects containing members from the constitient vector spaces.

There are several methods that can be used by clients that need to work with the individual constituent vector spaces. The method num_vector_spaces() give the number of constitient vector spaces while vector_spaces() returns an array of the constitient vector spaces passed to initialize(). Some other useful utility methods are also defined. The method vector_spaces_offsets() returns an array that gives the offset of each constitient vector in the overall composite vector. For example, the ith (zero based) vector space this->vector_spaces()[i] owns the element indexes this->vector_spaces_offsets()[i]+1 to this->vector_spaces_offsets()[i+1]. Determining which constitient vector space owns a element index can be determined by calling get_vector_space_position().

The default assignment operator is allowed since it has the correct semantics. 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.

Definition at line 99 of file AbstractLinAlgPack_VectorSpaceBlocked.hpp.

Constructor & Destructor Documentation

AbstractLinAlgPack::VectorSpaceBlocked::VectorSpaceBlocked ( const VectorSpace::space_ptr_t  vector_spaces[],
int  num_vector_spaces,
const VectorSpace::space_fcty_ptr_t small_vec_spc_fcty = Teuchos::null 
)

Construct the vector space object.

Calls this->initialize().

Definition at line 56 of file AbstractLinAlgPack_VectorSpaceBlocked.cpp.

Member Function Documentation

void AbstractLinAlgPack::VectorSpaceBlocked::initialize ( const VectorSpace::space_ptr_t  vec_spaces[],
int  num_vector_spaces,
const VectorSpace::space_fcty_ptr_t small_vec_spc_fcty = Teuchos::null 
)

Initialize with a set of vector space objects.

Postconditions:

  • this->num_vector_spaces() == num_vector_spaces
  • this->vector_spaces()[i].get() == vector_spaces[i].get(), i = 0...num_vector_spaces-1
  • this->dim() == sum{ vector_spaces[i]->dim(), i = 0...num_vector_spaces-1 }
  • this->sub_space(rng[i]).get() == vector_spaces[i].get(), this->vector_spaces_offsets()[i] = rng[i].lbound()-1, for i = 0...num_vector_spaces-1, rng[0] = Range1D(1,vector_spaces[0]->dim()); rng[i] = Range1D(1,vector_spaces[i]->dim()) + rng[i-1].ubound(), i = 0...num_vector_spaces-1
  • this->dim() == this->vector_spaces_offsets()[num_vector_spaces]
  • this->small_vec_spc_fcty().get() == small_vec_spc_fcty.get()
Parameters
vector_spaces[in] Array (length num_vector_spaces) that give the vector space objects that compose this composite vector space. The quantity vector_spaces[i].get(), for i = 0...num_vector_spaces-1 gives the ith vector_space object. vector_spaces an be NULL if num_vector_spaces == 0.
num_vector_spaces[in] Number of constitient vector spaces. Can be zero (empty vector space).
small_vec_spc_fcty[in] Defines the vector space factory returned by this->small_vec_spc_fcty()

Definition at line 65 of file AbstractLinAlgPack_VectorSpaceBlocked.cpp.

int AbstractLinAlgPack::VectorSpaceBlocked::num_vector_spaces ( ) const
inline

Return the value of num_vec_spaces passed to this->initialize().

Definition at line 244 of file AbstractLinAlgPack_VectorSpaceBlocked.hpp.

const VectorSpace::space_ptr_t* AbstractLinAlgPack::VectorSpaceBlocked::vector_spaces ( ) const

const index_type * AbstractLinAlgPack::VectorSpaceBlocked::vector_spaces_offsets ( ) const
inline

Returns array (length this->num_vector_spaces() + 1) of offsets for each constitient vector space in the composite vector.

Definition at line 257 of file AbstractLinAlgPack_VectorSpaceBlocked.hpp.

void AbstractLinAlgPack::VectorSpaceBlocked::get_vector_space_position ( index_type  i,
int *  kth_vector_space,
index_type *  kth_global_offset 
) const

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

Preconditions:

  • 1 <= i <= this->dim() (throw std::out_of_range)

Postconditions:

  • kth_global_offset + 1 <= i <= kth_global_offset + this->vector_spaces()[kth_vector_space]->dim()
Parameters
i[in] The index of the element to find the vector space object for.
kth_vector_space[out] The index for this->vector_spaces()[kth_vector_space] that owns the element i.
kth_global_offset[out] The global offset for this->vector_spaces()[kth_vector_space] in the composite vector.

Definition at line 80 of file AbstractLinAlgPack_VectorSpaceBlocked.cpp.

bool AbstractLinAlgPack::VectorSpaceBlocked::is_compatible ( const VectorSpace vec_space) const
virtual

Returns true if same type and has compatible vector spaces.

This method will only return true if all of the following are true:

  • (vs = dynamic_cast<const VectorSpaceCompoisteStd*>(&vec_space)) != NULL
  • this->num_num_vector_spaces() == vs->num_vector_spaces()
  • this->vector_spaces()[k]->is_compatible(*vs->vector_spaces()[k] , for k = 0 ... this->num_vector_spaces()-1

Otherwise, this method will return false.

Implements AbstractLinAlgPack::VectorSpace.

Definition at line 108 of file AbstractLinAlgPack_VectorSpaceBlocked.cpp.

index_type AbstractLinAlgPack::VectorSpaceBlocked::dim ( ) const
virtual
space_fcty_ptr_t AbstractLinAlgPack::VectorSpaceBlocked::small_vec_spc_fcty ( ) const
virtual

Reimplemented from AbstractLinAlgPack::VectorSpace.

VectorSpace::vec_mut_ptr_t AbstractLinAlgPack::VectorSpaceBlocked::create_member ( ) const
virtual
VectorSpace::multi_vec_mut_ptr_t AbstractLinAlgPack::VectorSpaceBlocked::create_members ( size_type  num_vecs) const
virtual

Reimplemented from AbstractLinAlgPack::VectorSpace.

Definition at line 156 of file AbstractLinAlgPack_VectorSpaceBlocked.cpp.

VectorSpace::space_ptr_t AbstractLinAlgPack::VectorSpaceBlocked::clone ( ) const
virtual
VectorSpace::space_ptr_t AbstractLinAlgPack::VectorSpaceBlocked::sub_space ( const Range1D rng) const
virtual

Reimplemented from AbstractLinAlgPack::VectorSpace.

Definition at line 169 of file AbstractLinAlgPack_VectorSpaceBlocked.cpp.


The documentation for this class was generated from the following files: