Support Software for Vector Reduction/Transformation Operators  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | List of all members
RTOpPack::SparseSubVectorT< Scalar > Class Template Reference

Class for a (sparse or dense) sub-vector. More...

#include <RTOpPack_SparseSubVectorT.hpp>

Public Member Functions

 SparseSubVectorT ()
 
 SparseSubVectorT (Teuchos_Ordinal globalOffset_in, Teuchos_Ordinal subDim_in, Teuchos_Ordinal subNz_in, const ArrayRCP< const Scalar > &values_in, ptrdiff_t valuesStride_in, const ArrayRCP< const Teuchos_Ordinal > &indices_in, ptrdiff_t indicesStride_in, ptrdiff_t localOffset_in, bool isSorted_in)
 
 SparseSubVectorT (Teuchos_Ordinal globalOffset_in, Teuchos_Ordinal subDim_in, const ArrayRCP< const Scalar > &values_in, ptrdiff_t valuesStride_in)
 
 SparseSubVectorT (const ConstSubVectorView< Scalar > &sv)
 
void initialize (Teuchos_Ordinal globalOffset_in, Teuchos_Ordinal subDim_in, Teuchos_Ordinal subNz_in, const ArrayRCP< const Scalar > &values_in, ptrdiff_t valuesStride_in, const ArrayRCP< const Teuchos_Ordinal > &indices_in, ptrdiff_t indicesStride_in, ptrdiff_t localOffset_in, bool isSorted_in)
 
void initialize (Teuchos_Ordinal globalOffset_in, Teuchos_Ordinal subDim_in, const ArrayRCP< const Scalar > &values_in, ptrdiff_t valuesStride_in)
 
void uninitialize ()
 
void setGlobalOffset (Teuchos_Ordinal globalOffset_in)
 
Teuchos_Ordinal globalOffset () const
 Offset for the sub-vector into the global vector. More...
 
Teuchos_Ordinal subDim () const
 Dimension of the sub-vector. More...
 
Teuchos_Ordinal subNz () const
 Number of nonzero elements (subNz == subDim for dense vectors). More...
 
const ArrayRCP< const Scalar > values () const
 Array (size min{|valueStride*subNz|,1}) for the values in the vector. More...
 
ptrdiff_t valuesStride () const
 Stride between elements in values[]. More...
 
const ArrayRCP< const
Teuchos_Ordinal > 
indices () const
 Array (size indicesStride*subNz) if not Teuchos::null) for the indices of the nonzero elements in the vector (sparse vectors only). More...
 
ptrdiff_t indicesStride () const
 Stride between indices in indices[] (sparse vectors only). More...
 
ptrdiff_t localOffset () const
 Offset of indices[] into local sub-vector (sparse vectors only). More...
 
bool isSorted () const
 If isSorted == false then the vector is not sorted, otherwise it is sorted (sparse vectors only). More...
 

Detailed Description

template<class Scalar>
class RTOpPack::SparseSubVectorT< Scalar >

Class for a (sparse or dense) sub-vector.

Warning! This class is really nothing more than a dumb data container!

Sparse and dense local vectors are supported as follows:

A dense vector vec is identified by vec.subDim() == vec.subNz() and vec.indices() == Teuchos::null in which case vec.indicesStride(), vec.localOffset() and vec.isSorted() are ignored. For a dense sub-vector vec, the corresponding entries in the global vector x(j) (zero-based) are as follows:

x(vec.globalOffset() + k) == vec.values()[vec.valueStride() * k],

    for k = 0,...,vec.subDim()-1

The stride member vec.valueStride() may be positive (>0) or negative (<0) but not zero (0). A negative stride vec.valueStride() < 0 allows a reverse traversal of the elements in vec.values().

A sparse vector is identified by vec.subDim() > vec.subNz() or vec.indices() != Teuchos::null in which case all the fields in the structure are meaningful. The corresponding elements in the global vector x(j) defined as:

x( vec.globalOffset() + vec.localOffset() + vec.indices()[vec.indicesStride()*k] )
== vec.values[vec.valueStride()*k],

    for k = 0,...,vec.subNz()-1

If vec.subNz() == 0 then vec.indices() == Teuchos::null. If vec.subDim() > vec.subNz() > 0, then vec.indices() != Teuchos::null must be true.

A sparse sub-vector may be sorted (vec.isSorted()!=0) or unsorted (vec.isSorted()==0) but the indices vec.indices()[k] must be unique. A sorted vector (vec.isSorted()!=0) means that the indices are in ascending order:

vec.indices()[vec.indicesStride()*k] < vec.indices()[vec.indicesStride()*k],

    for k = 0,...,vec.subNz()-1

The member vec.localOffset() is used to shift the values in vec.indices()[] to be in range of the local sub-vector. In other words:

0 <= vec.localOffset() + vec.indices()[vec.indicesStride()*k] < vec.subDim(),

    for k = 0...vec.subNz()-1

The member vec.valueStride() may be positive (>0) or negative (<0) but not zero (0). Also, the member vec.indicesStride() may be may be positive (>0) or negative (<0) but not zero (0). If vec.subNz() == 0 for a sparse vector then vec.values == Teuchos::null and vec.indices() == Teuchos::null.

This specification allows a lot of flexibility in determining how the vectors are laid out in memory. However, allowing vectors to be sparse and unsorted may make many user defined operations considerably harder and expensive to implement.

Definition at line 135 of file RTOpPack_SparseSubVectorT.hpp.

Constructor & Destructor Documentation

template<class Scalar >
RTOpPack::SparseSubVectorT< Scalar >::SparseSubVectorT ( )
inline

Definition at line 138 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
RTOpPack::SparseSubVectorT< Scalar >::SparseSubVectorT ( Teuchos_Ordinal  globalOffset_in,
Teuchos_Ordinal  subDim_in,
Teuchos_Ordinal  subNz_in,
const ArrayRCP< const Scalar > &  values_in,
ptrdiff_t  valuesStride_in,
const ArrayRCP< const Teuchos_Ordinal > &  indices_in,
ptrdiff_t  indicesStride_in,
ptrdiff_t  localOffset_in,
bool  isSorted_in 
)
inline

Definition at line 144 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
RTOpPack::SparseSubVectorT< Scalar >::SparseSubVectorT ( Teuchos_Ordinal  globalOffset_in,
Teuchos_Ordinal  subDim_in,
const ArrayRCP< const Scalar > &  values_in,
ptrdiff_t  valuesStride_in 
)
inline

Definition at line 161 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
RTOpPack::SparseSubVectorT< Scalar >::SparseSubVectorT ( const ConstSubVectorView< Scalar > &  sv)
inline

Definition at line 175 of file RTOpPack_SparseSubVectorT.hpp.

Member Function Documentation

template<class Scalar >
void RTOpPack::SparseSubVectorT< Scalar >::initialize ( Teuchos_Ordinal  globalOffset_in,
Teuchos_Ordinal  subDim_in,
Teuchos_Ordinal  subNz_in,
const ArrayRCP< const Scalar > &  values_in,
ptrdiff_t  valuesStride_in,
const ArrayRCP< const Teuchos_Ordinal > &  indices_in,
ptrdiff_t  indicesStride_in,
ptrdiff_t  localOffset_in,
bool  isSorted_in 
)
inline

Definition at line 181 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
void RTOpPack::SparseSubVectorT< Scalar >::initialize ( Teuchos_Ordinal  globalOffset_in,
Teuchos_Ordinal  subDim_in,
const ArrayRCP< const Scalar > &  values_in,
ptrdiff_t  valuesStride_in 
)
inline

Definition at line 224 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
void RTOpPack::SparseSubVectorT< Scalar >::uninitialize ( )
inline

Definition at line 233 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
void RTOpPack::SparseSubVectorT< Scalar >::setGlobalOffset ( Teuchos_Ordinal  globalOffset_in)
inline

Definition at line 240 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
Teuchos_Ordinal RTOpPack::SparseSubVectorT< Scalar >::globalOffset ( ) const
inline

Offset for the sub-vector into the global vector.

Definition at line 242 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
Teuchos_Ordinal RTOpPack::SparseSubVectorT< Scalar >::subDim ( ) const
inline

Dimension of the sub-vector.

Definition at line 244 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
Teuchos_Ordinal RTOpPack::SparseSubVectorT< Scalar >::subNz ( ) const
inline

Number of nonzero elements (subNz == subDim for dense vectors).

Definition at line 247 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
const ArrayRCP<const Scalar> RTOpPack::SparseSubVectorT< Scalar >::values ( ) const
inline

Array (size min{|valueStride*subNz|,1}) for the values in the vector.

Definition at line 250 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
ptrdiff_t RTOpPack::SparseSubVectorT< Scalar >::valuesStride ( ) const
inline

Stride between elements in values[].

Definition at line 252 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
const ArrayRCP<const Teuchos_Ordinal> RTOpPack::SparseSubVectorT< Scalar >::indices ( ) const
inline

Array (size indicesStride*subNz) if not Teuchos::null) for the indices of the nonzero elements in the vector (sparse vectors only).

Definition at line 257 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
ptrdiff_t RTOpPack::SparseSubVectorT< Scalar >::indicesStride ( ) const
inline

Stride between indices in indices[] (sparse vectors only).

Definition at line 259 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
ptrdiff_t RTOpPack::SparseSubVectorT< Scalar >::localOffset ( ) const
inline

Offset of indices[] into local sub-vector (sparse vectors only).

Definition at line 262 of file RTOpPack_SparseSubVectorT.hpp.

template<class Scalar >
bool RTOpPack::SparseSubVectorT< Scalar >::isSorted ( ) const
inline

If isSorted == false then the vector is not sorted, otherwise it is sorted (sparse vectors only).

Definition at line 265 of file RTOpPack_SparseSubVectorT.hpp.


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