Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
Public Methods | Public Members | List of all members
cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace > Class Template Reference

Detailed description

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType, typename ValueType, typename MemorySpace>
class cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >

View of a csr_matrix.

Template Parameters
ArrayType1Type of row_offsets array view
ArrayType2Type of column_indices array view
ArrayType3Type of values array view
IndexTypeType used for matrix indices (e.g. int).
ValueTypeType used for matrix values (e.g. float).
MemorySpaceA memory space (e.g. cusp::host_memory or cusp::device_memory)
Overview
A csr_matrix_view is a sparse matrix view of a matrix in CSR format constructed from existing data or iterators. All entries in the csr_matrix are sorted according to rows and internally within each row sorted by column indices.
Note
The matrix entries must be sorted by row index.
The matrix should not contain duplicate entries.
Example
The following code snippet demonstrates how to create a 4-by-3 csr_matrix_view on the host with 6 nonzeros.
// include csr_matrix header file
#include <cusp/print.h>
int main()
{
typedef typename IndexArray::view IndexArrayView;
typedef typename ValueArray::view ValueArrayView;
// initialize rows, columns, and values
IndexArray row_offsets(6);
IndexArray column_indices(6);
ValueArray values(6);
// initialize matrix entries on host
row_offsets[0] = 0; // first offset is always zero
row_offsets[1] = 2;
row_offsets[2] = 2;
row_offsets[3] = 3;
row_offsets[4] = 6; // last offset is always num_entries
column_indices[0] = 0; values[0] = 10;
column_indices[1] = 2; values[1] = 20;
column_indices[2] = 2; values[2] = 30;
column_indices[3] = 0; values[3] = 40;
column_indices[4] = 1; values[4] = 50;
column_indices[5] = 2; values[5] = 60;
// allocate storage for (4,3) matrix with 6 nonzeros
4,3,6,
// A now represents the following matrix
// [10 0 20]
// [ 0 0 0]
// [ 0 0 30]
// [40 50 60]
// print the constructed csr_matrix
// change first entry in values array
values[0] = -1;
// print the updated matrix view
}
Examples:
csr_raw.cu, and csr_view.cu.

Definition at line 34 of file csr_matrix.h.

#include <csr_matrix.h>

Inheritance diagram for cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >:

Public Methods

 csr_matrix_view (void)
 
 csr_matrix_view (const size_t num_rows, const size_t num_cols, const size_t num_entries, ArrayType1 row_offsets, ArrayType2 column_indices, ArrayType3 values)
 
 csr_matrix_view (csr_matrix< IndexType, ValueType, MemorySpace > &matrix)
 
 csr_matrix_view (const csr_matrix< IndexType, ValueType, MemorySpace > &matrix)
 
 csr_matrix_view (csr_matrix_view &matrix)
 
 csr_matrix_view (const csr_matrix_view &matrix)
 
void resize (const size_t num_rows, const size_t num_cols, const size_t num_entries)
 

Public Members

row_offsets_array_type row_offsets
 
column_indices_array_type column_indices
 
values_array_type values
 

Constructor & Destructor Documentation

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType, typename ValueType, typename MemorySpace>
cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::csr_matrix_view ( void  )
inline

Construct an empty csr_matrix_view.

Definition at line 338 of file csr_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType, typename ValueType, typename MemorySpace>
cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::csr_matrix_view ( const size_t  num_rows,
const size_t  num_cols,
const size_t  num_entries,
ArrayType1  row_offsets,
ArrayType2  column_indices,
ArrayType3  values 
)
inline

Construct a csr_matrix_view with a specific shape and number of nonzero entries from existing arrays denoting the row offsets, column indices, and values.

Parameters
num_rowsNumber of rows.
num_colsNumber of columns.
num_entriesNumber of nonzero matrix entries.
row_offsetsArray containing the row offsets.
column_indicesArray containing the column indices.
valuesArray containing the values.

Definition at line 352 of file csr_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType, typename ValueType, typename MemorySpace>
cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::csr_matrix_view ( csr_matrix< IndexType, ValueType, MemorySpace > &  matrix)
inline

Construct a csr_matrix_view from a existing csr_matrix.

Parameters
matrixcsr_matrix used to create view.

Definition at line 367 of file csr_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType, typename ValueType, typename MemorySpace>
cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::csr_matrix_view ( const csr_matrix< IndexType, ValueType, MemorySpace > &  matrix)
inline

Construct a csr_matrix_view from a existing const csr_matrix.

Parameters
matrixcsr_matrix used to create view.

Definition at line 377 of file csr_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType, typename ValueType, typename MemorySpace>
cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::csr_matrix_view ( csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace > &  matrix)
inline

Construct a csr_matrix_view from a existing csr_matrix_view.

Parameters
matrixcsr_matrix_view used to create view.

Definition at line 387 of file csr_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType, typename ValueType, typename MemorySpace>
cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::csr_matrix_view ( const csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace > &  matrix)
inline

Construct a csr_matrix_view from a existing const csr_matrix_view.

Parameters
matrixcsr_matrix_view used to create view.

Definition at line 397 of file csr_matrix.h.

Member Function Documentation

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType, typename ValueType, typename MemorySpace>
void cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::resize ( const size_t  num_rows,
const size_t  num_cols,
const size_t  num_entries 
)

Resize matrix dimensions and underlying storage

Parameters
num_rowsNumber of rows.
num_colsNumber of columns.
num_entriesNumber of nonzero matrix entries.

Member Data Documentation

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType, typename ValueType, typename MemorySpace>
column_indices_array_type cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::column_indices

View of the column indices of the CSR data structure.

Definition at line 328 of file csr_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType, typename ValueType, typename MemorySpace>
row_offsets_array_type cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::row_offsets

View of the row_offsets of the CSR data structure.

Definition at line 323 of file csr_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType, typename ValueType, typename MemorySpace>
values_array_type cusp::csr_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::values

View for the nonzero entries of the CSR data structure.

Definition at line 333 of file csr_matrix.h.