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

Detailed description

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

View of a dia_matrix.

Template Parameters
ArrayType1Type of diagonal_offsets
ArrayType2Type 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 dia_matrix_view is a sparse matrix view of a matrix in DIA format constructed from existing data or iterators. All entries in the dia_matrix are sorted according to row indices and internally within each row sorted by column indices.
Note
The diagonal offsets should not contain duplicate entries.
Example
The following code snippet demonstrates how to create a 4-by-3 dia_matrix_view on the host with 3 diagonals and 6 nonzeros.
// include dia_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 diagonal_offsets(3);
ValueArray values(4,3);
// initialize diagonal offsets
// initialize diagonal values
// first diagonal
values(0,2) = 0; // outside matrix
values(1,2) = 0; // outside matrix
values(2,0) = 40;
values(3,0) = 60;
// second diagonal
values(0,1) = 10;
values(1,1) = 0;
values(2,1) = 50;
values(3,1) = 50; // outside matrix
// third diagonal
values(0,2) = 20;
values(1,2) = 30;
values(2,2) = 0; // outside matrix
values(3,2) = 0; // outside matrix
// allocate storage for (4,3) matrix with 6 nonzeros
4,3,6,
// A now represents the following matrix
// [10 20 0]
// [ 0 0 30]
// [40 0 50]
// [ 0 60 0]
// print the constructed coo_matrix
// change first entry in values array
values(0,1) = -1;
// print the updated matrix view
}

Definition at line 35 of file dia_matrix.h.

#include <dia_matrix.h>

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

Public Methods

 dia_matrix_view (void)
 
template<typename OtherArrayType1 , typename OtherArrayType2 >
 dia_matrix_view (size_t num_rows, size_t num_cols, size_t num_entries, OtherArrayType1 &diagonal_offsets, OtherArrayType2 &values)
 
template<typename OtherArrayType1 , typename OtherArrayType2 >
 dia_matrix_view (size_t num_rows, size_t num_cols, size_t num_entries, const OtherArrayType1 &diagonal_offsets, const OtherArrayType2 &values)
 
 dia_matrix_view (dia_matrix< IndexType, ValueType, MemorySpace > &matrix)
 
 dia_matrix_view (const dia_matrix< IndexType, ValueType, MemorySpace > &matrix)
 
 dia_matrix_view (dia_matrix_view &matrix)
 
 dia_matrix_view (const dia_matrix_view &matrix)
 
void resize (const size_t num_rows, const size_t num_cols, const size_t num_entries, const size_t num_diagonals)
 
void resize (const size_t num_rows, const size_t num_cols, const size_t num_entries, const size_t num_diagonals, const size_t alignment)
 

Public Members

diagonal_offsets_array_type diagonal_offsets
 
values_array_type values
 

Constructor & Destructor Documentation

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

Construct an empty dia_matrix_view.

Definition at line 349 of file dia_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename IndexType, typename ValueType, typename MemorySpace>
template<typename OtherArrayType1 , typename OtherArrayType2 >
cusp::dia_matrix_view< ArrayType1, ArrayType2, IndexType, ValueType, MemorySpace >::dia_matrix_view ( size_t  num_rows,
size_t  num_cols,
size_t  num_entries,
OtherArrayType1 &  diagonal_offsets,
OtherArrayType2 &  values 
)
inline

Construct a dia_matrix_view with a specific shape and number of nonzero entries from existing arrays denoting the diagonal offsets and values.

Parameters
num_rowsNumber of rows.
num_colsNumber of columns.
num_entriesNumber of nonzero matrix entries.
diagonal_offsetsArray containing the diagonal offsets.
valuesArray containing the values.

Definition at line 361 of file dia_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename IndexType, typename ValueType, typename MemorySpace>
template<typename OtherArrayType1 , typename OtherArrayType2 >
cusp::dia_matrix_view< ArrayType1, ArrayType2, IndexType, ValueType, MemorySpace >::dia_matrix_view ( size_t  num_rows,
size_t  num_cols,
size_t  num_entries,
const OtherArrayType1 &  diagonal_offsets,
const OtherArrayType2 &  values 
)
inline

Construct a dia_matrix_view with a specific shape and number of nonzero entries from existing const arrays denoting the diagonal offsets and values.

Parameters
num_rowsNumber of rows.
num_colsNumber of columns.
num_entriesNumber of nonzero matrix entries.
diagonal_offsetsArray containing the diagonal offsets.
valuesArray containing the values.

Definition at line 377 of file dia_matrix.h.

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

Construct a dia_matrix_view from a existing dia_matrix.

Parameters
matrixdia_matrix used to create view.

Definition at line 387 of file dia_matrix.h.

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

Construct a dia_matrix_view from a existing const dia_matrix.

Parameters
matrixdia_matrix used to create view.

Definition at line 396 of file dia_matrix.h.

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

Construct a dia_matrix_view from a existing dia_matrix_view.

Parameters
matrixdia_matrix_view used to create view.

Definition at line 405 of file dia_matrix.h.

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

Construct a dia_matrix_view from a existing const dia_matrix_view.

Parameters
matrixdia_matrix_view used to create view.

Definition at line 414 of file dia_matrix.h.

Member Function Documentation

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

Resize matrix dimensions and underlying storage

Parameters
num_rowsNumber of rows.
num_colsNumber of columns.
num_entriesNumber of nonzero matrix entries.
num_diagonalsNumber of occupied diagonals.
template<typename ArrayType1, typename ArrayType2, typename IndexType, typename ValueType, typename MemorySpace>
void cusp::dia_matrix_view< ArrayType1, ArrayType2, IndexType, ValueType, MemorySpace >::resize ( const size_t  num_rows,
const size_t  num_cols,
const size_t  num_entries,
const size_t  num_diagonals,
const size_t  alignment 
)

Resize matrix dimensions and underlying storage

Parameters
num_rowsNumber of rows.
num_colsNumber of columns.
num_entriesNumber of nonzero matrix entries.
num_diagonalsNumber of occupied diagonals.
alignmentAmount of padding used to align the data structure (default 32).

Member Data Documentation

template<typename ArrayType1, typename ArrayType2, typename IndexType, typename ValueType, typename MemorySpace>
diagonal_offsets_array_type cusp::dia_matrix_view< ArrayType1, ArrayType2, IndexType, ValueType, MemorySpace >::diagonal_offsets

View of the diagonal_offsets of the DIA data structure.

Definition at line 339 of file dia_matrix.h.

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

View for the nonzero entries of the DIA data structure.

Definition at line 344 of file dia_matrix.h.