MOOCHO (Single Doxygen Collection) Version of the Day
Public Attributes
RTOp_SparseSubVector Struct Reference

#include <RTOp_SparseSubVector.h>

List of all members.

Public Attributes

RTOp_index_type global_offset
RTOp_index_type sub_dim
RTOp_index_type sub_nz
const RTOp_value_typevalues
ptrdiff_t values_stride
const RTOp_index_typeindices
ptrdiff_t indices_stride
ptrdiff_t local_offset
int is_sorted

Detailed Description

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

Sparse and dense local vectors are supported as follows:

A dense vector vec is identified by vec.sub_dim == vec.sub_nz and vec.indices == NULL in which case vec.indices_stride, vec.local_offset and vec.is_sorted are ignored. For a dense sub-vector vec, the corresponding entries in the global vector x(j) (one based) are as follows:


	x( vec.global_offset + k )
		= vec.values[ vec.value_stride * (k-1) ]

	for k = 1,...,vec.sub_dim
 

The stride member vec.value_stride may be positive (>0), negative (<0) or even zero (0). A negative stride vec.value_stride < 0 allows a reverse traversal of the elements in vec.values[]. A zero stride vec.value_stride == 0 allows a vector with all the elements the same.

A sparse vector is identified by vec.sub_dim > 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.global_offset + vec.local_offset + vec.indices[vec.indices_stride*(k-1)] )
		= vec.values[vec.value_stride*(k-1)]

	for k = 1,...,vec.sub_nz
 

If vec.sub_nz == 0 then it is allowed for vec.indices == NULL. If vec.sub_dim > vec.sub_nz > 0 then vec.indices != NULL must be true.

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


	vec.indices[vec.indices_stride*(k-1)] < vec.indices[vec.indices_stride*(k)]

	for k = 1,...,vec.sub_nz-1
 

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

	
	1 <= vec.local_offset + vec.indices[vec.indices_stride*(k-1)] <= vec.sub_nz

	for k = 1...vec.sub_nz
 

The member vec.value_stride may be positive (>0), negative (<0) or zero (0). However, the member vec.indices_stride may be may be positive (>0) or negative (<0) but not zero (0). Allowing vec.indices_stride == 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.value_stride == 0 is one where all of the nonzeros 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 131 of file RTOp_SparseSubVector.h.


Member Data Documentation

Definition at line 133 of file RTOp_SparseSubVector.h.

Definition at line 135 of file RTOp_SparseSubVector.h.

Definition at line 137 of file RTOp_SparseSubVector.h.

Definition at line 139 of file RTOp_SparseSubVector.h.

Definition at line 141 of file RTOp_SparseSubVector.h.

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

Definition at line 146 of file RTOp_SparseSubVector.h.

Definition at line 148 of file RTOp_SparseSubVector.h.

Definition at line 150 of file RTOp_SparseSubVector.h.

Definition at line 152 of file RTOp_SparseSubVector.h.


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines