#include <RTOpPack_Types.hpp>
Public Member Functions | |
| SparseSubVectorT () | |
| | |
| SparseSubVectorT (RTOp_index_type globalOffset, RTOp_index_type subDim, RTOp_index_type subNz, const Scalar values[], ptrdiff_t valuesStride, const RTOp_index_type indices[], ptrdiff_t indicesStride, ptrdiff_t localOffset, int isSorted) | |
| | |
| SparseSubVectorT (RTOp_index_type globalOffset, RTOp_index_type subDim, const Scalar values[], ptrdiff_t valuesStride) | |
| | |
| SparseSubVectorT (const SubVectorT< Scalar > &sv) | |
| | |
| void | initialize (RTOp_index_type globalOffset, RTOp_index_type subDim, RTOp_index_type subNz, const Scalar values[], ptrdiff_t valuesStride, const RTOp_index_type indices[], ptrdiff_t indicesStride, ptrdiff_t localOffset, int isSorted) |
| | |
| void | initialize (RTOp_index_type globalOffset, RTOp_index_type subDim, const Scalar values[], ptrdiff_t valuesStride) |
| | |
| void | set_uninitialized () |
| | |
| void | setGlobalOffset (RTOp_index_type globalOffset) |
| | |
| RTOp_index_type | globalOffset () const |
| Offset for the sub-vector into the global vector. | |
| RTOp_index_type | subDim () const |
| Dimension of the sub-vector. | |
| RTOp_index_type | 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 RTOp_index_type * | 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). | |
Sparse and dense local vectors are supported as follows:
A dense vector vec is identified by vec.subDim() == vec.sub_nz 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-1) ]
for k = 1,...,vec.subDim()
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.sub_nz() 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-1)] )
= vec.values[vec.valueStride()*(k-1)]
for k = 1,...,vec.sub_nz
vec.sub_nz == 0 then it is allowed for vec.indices() == NULL. If vec.subDim() > vec.sub_nz > 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-1)] < vec.indices()[vec.indicesStride()*(k)] for k = 1,...,vec.sub_nz-1
vec.localOffset() is used to shift the values in vec.indices()[] to be in range of the local sub-vector. In other words: 1 <= vec.localOffset() + vec.indices()[vec.indicesStride()*(k-1)] <= vec.sub_nz for k = 1...vec.sub_nz
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.sub_nz 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.sub_nz == 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 249 of file RTOpPack_Types.hpp.
|
|||||||||
|
Definition at line 252 of file RTOpPack_Types.hpp. |
|
||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 258 of file RTOpPack_Types.hpp. |
|
||||||||||||||||||||||||
|
Definition at line 269 of file RTOpPack_Types.hpp. |
|
||||||||||
|
Definition at line 278 of file RTOpPack_Types.hpp. |
|
||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 283 of file RTOpPack_Types.hpp. |
|
||||||||||||||||||||||||
|
Definition at line 295 of file RTOpPack_Types.hpp. |
|
|||||||||
|
Definition at line 305 of file RTOpPack_Types.hpp. |
|
||||||||||
|
Definition at line 312 of file RTOpPack_Types.hpp. |
|
|||||||||
|
Offset for the sub-vector into the global vector.
Definition at line 314 of file RTOpPack_Types.hpp. |
|
|||||||||
|
Dimension of the sub-vector.
Definition at line 316 of file RTOpPack_Types.hpp. |
|
|||||||||
|
Number of nonzero elements (
Definition at line 318 of file RTOpPack_Types.hpp. |
|
|||||||||
|
Array (size min{|
Definition at line 320 of file RTOpPack_Types.hpp. |
|
|||||||||
|
Stride between elements in
Definition at line 322 of file RTOpPack_Types.hpp. |
|
|||||||||
|
Array (size min{|
Definition at line 326 of file RTOpPack_Types.hpp. |
|
|||||||||
|
Stride between indices in indices[] (sparse vectors only).
Definition at line 328 of file RTOpPack_Types.hpp. |
|
|||||||||
|
Offset of indices[] into local sub-vector (sparse vectors only).
Definition at line 330 of file RTOpPack_Types.hpp. |
|
|||||||||
|
If
Definition at line 332 of file RTOpPack_Types.hpp. |
1.3.9.1