RTOpPack::SparseSubVectorT< Scalar > Class Template Reference

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

#include <RTOpPack_Types.hpp>

List of all members.

Public Member Functions

 SparseSubVectorT ()
 
 SparseSubVectorT (Teuchos_Index globalOffset, Teuchos_Index subDim, Teuchos_Index subNz, const Scalar values[], ptrdiff_t valuesStride, const Teuchos_Index indices[], ptrdiff_t indicesStride, ptrdiff_t localOffset, int isSorted)
 
 SparseSubVectorT (Teuchos_Index globalOffset, Teuchos_Index subDim, const Scalar values[], ptrdiff_t valuesStride)
 
 SparseSubVectorT (const ConstSubVectorView< Scalar > &sv)
 
void initialize (Teuchos_Index globalOffset, Teuchos_Index subDim, Teuchos_Index subNz, const Scalar values[], ptrdiff_t valuesStride, const Teuchos_Index indices[], ptrdiff_t indicesStride, ptrdiff_t localOffset, int isSorted)
 
void initialize (Teuchos_Index globalOffset, Teuchos_Index subDim, const Scalar values[], ptrdiff_t valuesStride)
 
void set_uninitialized ()
 
void setGlobalOffset (Teuchos_Index globalOffset)
 
Teuchos_Index globalOffset () const
 Offset for the sub-vector into the global vector.
Teuchos_Index subDim () const
 Dimension of the sub-vector.
Teuchos_Index subNz () const
 Number of nonzero elements (subNz == subDim for dense vectors).
const Scalar * values () const
 Array (size min{|valueStride*subNz|,1}) for the values in the vector.
ptrdiff_t valuesStride () const
 Stride between elements in values[].
const Teuchos_Index * indices () const
 Array (size min{|indicesStride*subNz|,1} if not NULL) for the indices of the nonzero elements in the vector (sparse vectors only).
ptrdiff_t indicesStride () const
 Stride between indices in indices[] (sparse vectors only).
ptrdiff_t localOffset () const
 Offset of indices[] into local sub-vector (sparse vectors only).
int isSorted () const
 If isSorted == 0 then the vector is not sorted, otherwise it is sorted (sparse vectors only).

Private Attributes

Teuchos_Index globalOffset_
Teuchos_Index subDim_
Teuchos_Index subNz_
const Scalar * values_
ptrdiff_t valuesStride_
const Teuchos_Index * indices_
ptrdiff_t indicesStride_
ptrdiff_t localOffset_
int isSorted_


Detailed Description

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

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

Sparse and dense local vectors are supported as follows:

A dense vector vec is identified by vec.subDim() == vec.subNz() and vec.indices() == 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) (one 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), negative (<0) or even zero (0). A negative stride vec.valueStride() < 0 allows a reverse traversal of the elements in vec.values()[]. A zero stride vec.valueStride() == 0 allows a vector with all the elements the same.

A sparse vector is identified by vec.subDim() > vec.subNz() or vec.indices() != 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 it is allowed for vec.indices() == NULL. If vec.subDim() > vec.subNz() > 0 then vec.indices() != 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.subNz()

  for k = 0...vec.subNz()-1
 
The member vec.valueStride() may be positive (>0), negative (<0) or zero (0). However, the member vec.indicesStride() may be may be positive (>0) or negative (<0) but not zero (0). Allowing vec.indicesStride() == 0 would mean that a vector would have vec.subNz() nonzero elements with all the same value and all the same indexes and non-unique indices are not allowed. Allowing non-unique indexes would make some operations (e.g. dot product) very difficult to implement and therefore can not be allowed. A sparse vector where vec.valueStride() == 0 is one where all of the non-zeros have the value vec.values[0]. If vec.subNz() == 0 for a sparse vector then it is allowed for vec.values == NULL and vec.indices() == 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.

To avoid making mistakes in setting the members of this struct use one of the helper functions RTOp_sparse_sub_vector_from_dense(), RTOp_sparse_sub_vector() or RTOp_sub_vector_null().

Definition at line 258 of file RTOpPack_Types.hpp.


Constructor & Destructor Documentation

template<class Scalar>
RTOpPack::SparseSubVectorT< Scalar >::SparseSubVectorT  )  [inline]
 

Definition at line 261 of file RTOpPack_Types.hpp.

template<class Scalar>
RTOpPack::SparseSubVectorT< Scalar >::SparseSubVectorT Teuchos_Index  globalOffset,
Teuchos_Index  subDim,
Teuchos_Index  subNz,
const Scalar  values[],
ptrdiff_t  valuesStride,
const Teuchos_Index  indices[],
ptrdiff_t  indicesStride,
ptrdiff_t  localOffset,
int  isSorted
[inline]
 

Definition at line 267 of file RTOpPack_Types.hpp.

template<class Scalar>
RTOpPack::SparseSubVectorT< Scalar >::SparseSubVectorT Teuchos_Index  globalOffset,
Teuchos_Index  subDim,
const Scalar  values[],
ptrdiff_t  valuesStride
[inline]
 

Definition at line 278 of file RTOpPack_Types.hpp.

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

Definition at line 287 of file RTOpPack_Types.hpp.


Member Function Documentation

template<class Scalar>
void RTOpPack::SparseSubVectorT< Scalar >::initialize Teuchos_Index  globalOffset,
Teuchos_Index  subDim,
Teuchos_Index  subNz,
const Scalar  values[],
ptrdiff_t  valuesStride,
const Teuchos_Index  indices[],
ptrdiff_t  indicesStride,
ptrdiff_t  localOffset,
int  isSorted
[inline]
 

Definition at line 292 of file RTOpPack_Types.hpp.

template<class Scalar>
void RTOpPack::SparseSubVectorT< Scalar >::initialize Teuchos_Index  globalOffset,
Teuchos_Index  subDim,
const Scalar  values[],
ptrdiff_t  valuesStride
[inline]
 

Definition at line 304 of file RTOpPack_Types.hpp.

template<class Scalar>
void RTOpPack::SparseSubVectorT< Scalar >::set_uninitialized  )  [inline]
 

Definition at line 314 of file RTOpPack_Types.hpp.

template<class Scalar>
void RTOpPack::SparseSubVectorT< Scalar >::setGlobalOffset Teuchos_Index  globalOffset  )  [inline]
 

Definition at line 321 of file RTOpPack_Types.hpp.

template<class Scalar>
Teuchos_Index RTOpPack::SparseSubVectorT< Scalar >::globalOffset  )  const [inline]
 

Offset for the sub-vector into the global vector.

Definition at line 323 of file RTOpPack_Types.hpp.

template<class Scalar>
Teuchos_Index RTOpPack::SparseSubVectorT< Scalar >::subDim  )  const [inline]
 

Dimension of the sub-vector.

Definition at line 325 of file RTOpPack_Types.hpp.

template<class Scalar>
Teuchos_Index RTOpPack::SparseSubVectorT< Scalar >::subNz  )  const [inline]
 

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

Definition at line 327 of file RTOpPack_Types.hpp.

template<class Scalar>
const Scalar* RTOpPack::SparseSubVectorT< Scalar >::values  )  const [inline]
 

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

Definition at line 329 of file RTOpPack_Types.hpp.

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

Stride between elements in values[].

Definition at line 331 of file RTOpPack_Types.hpp.

template<class Scalar>
const Teuchos_Index* RTOpPack::SparseSubVectorT< Scalar >::indices  )  const [inline]
 

Array (size min{|indicesStride*subNz|,1} if not NULL) for the indices of the nonzero elements in the vector (sparse vectors only).

Definition at line 335 of file RTOpPack_Types.hpp.

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

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

Definition at line 337 of file RTOpPack_Types.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 339 of file RTOpPack_Types.hpp.

template<class Scalar>
int RTOpPack::SparseSubVectorT< Scalar >::isSorted  )  const [inline]
 

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

Definition at line 341 of file RTOpPack_Types.hpp.


Member Data Documentation

template<class Scalar>
Teuchos_Index RTOpPack::SparseSubVectorT< Scalar >::globalOffset_ [private]
 

Definition at line 343 of file RTOpPack_Types.hpp.

template<class Scalar>
Teuchos_Index RTOpPack::SparseSubVectorT< Scalar >::subDim_ [private]
 

Definition at line 344 of file RTOpPack_Types.hpp.

template<class Scalar>
Teuchos_Index RTOpPack::SparseSubVectorT< Scalar >::subNz_ [private]
 

Definition at line 345 of file RTOpPack_Types.hpp.

template<class Scalar>
const Scalar* RTOpPack::SparseSubVectorT< Scalar >::values_ [private]
 

Definition at line 346 of file RTOpPack_Types.hpp.

template<class Scalar>
ptrdiff_t RTOpPack::SparseSubVectorT< Scalar >::valuesStride_ [private]
 

Definition at line 347 of file RTOpPack_Types.hpp.

template<class Scalar>
const Teuchos_Index* RTOpPack::SparseSubVectorT< Scalar >::indices_ [private]
 

Definition at line 348 of file RTOpPack_Types.hpp.

template<class Scalar>
ptrdiff_t RTOpPack::SparseSubVectorT< Scalar >::indicesStride_ [private]
 

Definition at line 349 of file RTOpPack_Types.hpp.

template<class Scalar>
ptrdiff_t RTOpPack::SparseSubVectorT< Scalar >::localOffset_ [private]
 

Definition at line 350 of file RTOpPack_Types.hpp.

template<class Scalar>
int RTOpPack::SparseSubVectorT< Scalar >::isSorted_ [private]
 

Definition at line 351 of file RTOpPack_Types.hpp.


The documentation for this class was generated from the following file:
Generated on Thu Sep 18 12:30:43 2008 for RTOp Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1