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

Detailed description

template<typename IndexType, typename ValueType, typename MemorySpace>
class cusp::ell_matrix< IndexType, ValueType, MemorySpace >

Packed row (ELLPACK/ITPACK) representation of a sparse matrix.

Template Parameters
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
Note
The matrix entries must be sorted by column index.
The matrix entries within each row should be shifted to the left.
The matrix should not contain duplicate entries.
Example
The following code snippet demonstrates how to create a 4-by-3 ell_matrix on the host with 3 nonzeros per row (6 total nonzeros) and then copies the matrix to the device.
// include the ell_matrix header file
#include <cusp/print.h>
int main()
{
// allocate storage for (4,3) matrix with 6 nonzeros and at most 3 nonzeros per row.
// X is used to fill unused entries in the matrix
// initialize matrix entries on host
A.column_indices(0,0) = 0; A.values(0,0) = 10;
A.column_indices(0,1) = 2; A.values(0,1) = 20; // shifted to leftmost position
A.column_indices(0,2) = X; A.values(0,2) = 0; // padding
A.column_indices(1,0) = X; A.values(1,0) = 0; // padding
A.column_indices(1,1) = X; A.values(1,1) = 0; // padding
A.column_indices(1,2) = X; A.values(1,2) = 0; // padding
A.column_indices(2,0) = 2; A.values(2,0) = 30; // shifted to leftmost position
A.column_indices(2,1) = X; A.values(2,1) = 0; // padding
A.column_indices(2,2) = X; A.values(2,2) = 0; // padding
A.column_indices(3,0) = 0; A.values(3,0) = 40;
A.column_indices(3,1) = 1; A.values(3,1) = 50;
A.column_indices(3,2) = 2; A.values(3,2) = 60;
// A now represents the following matrix
// [10 0 20]
// [ 0 0 0]
// [ 0 0 30]
// [40 50 60]
// copy to the device
}
Examples:
ell.cu, and hyb.cu.

Definition at line 122 of file ell_matrix.h.

#include <ell_matrix.h>

Inheritance diagram for cusp::ell_matrix< IndexType, ValueType, MemorySpace >:

Public Methods

 ell_matrix (void)
 
 ell_matrix (const size_t num_rows, const size_t num_cols, const size_t num_entries, const size_t num_entries_per_row, const size_t alignment=32)
 
template<typename MatrixType >
 ell_matrix (const MatrixType &matrix)
 
void resize (const size_t num_rows, const size_t num_cols, const size_t num_entries, const size_t num_entries_per_row)
 
void resize (const size_t num_rows, const size_t num_cols, const size_t num_entries, const size_t num_entries_per_row, const size_t alignment)
 
void swap (ell_matrix &matrix)
 
template<typename MatrixType >
ell_matrixoperator= (const MatrixType &matrix)
 

Public Members

column_indices_array_type column_indices
 
values_array_type values
 

Static Public Members

static const IndexType invalid_index = static_cast<IndexType>(-1)
 

Constructor & Destructor Documentation

template<typename IndexType, typename ValueType, typename MemorySpace>
cusp::ell_matrix< IndexType, ValueType, MemorySpace >::ell_matrix ( void  )
inline

Construct an empty ell_matrix.

Definition at line 170 of file ell_matrix.h.

template<typename IndexType, typename ValueType, typename MemorySpace>
cusp::ell_matrix< IndexType, ValueType, MemorySpace >::ell_matrix ( const size_t  num_rows,
const size_t  num_cols,
const size_t  num_entries,
const size_t  num_entries_per_row,
const size_t  alignment = 32 
)

Construct an ell_matrix with a specific shape, number of nonzero entries, and maximum number of nonzero entries per row.

Parameters
num_rowsNumber of rows.
num_colsNumber of columns.
num_entriesNumber of nonzero matrix entries.
num_entries_per_rowMaximum number of nonzeros per row.
alignmentAmount of padding used to align the data structure (default 32).
template<typename IndexType, typename ValueType, typename MemorySpace>
template<typename MatrixType >
cusp::ell_matrix< IndexType, ValueType, MemorySpace >::ell_matrix ( const MatrixType &  matrix)

Construct an ell_matrix from another matrix.

Parameters
matrixAnother sparse or dense matrix.

Member Function Documentation

template<typename IndexType, typename ValueType, typename MemorySpace>
template<typename MatrixType >
ell_matrix& cusp::ell_matrix< IndexType, ValueType, MemorySpace >::operator= ( const MatrixType &  matrix)

Assignment from another matrix.

Template Parameters
MatrixTypeFormat type of input matrix.
Parameters
matrixAnother sparse or dense matrix.
template<typename IndexType, typename ValueType, typename MemorySpace>
void cusp::ell_matrix< IndexType, ValueType, MemorySpace >::resize ( const size_t  num_rows,
const size_t  num_cols,
const size_t  num_entries,
const size_t  num_entries_per_row 
)

Resize matrix dimensions and underlying storage

Parameters
num_rowsNumber of rows.
num_colsNumber of columns.
num_entriesNumber of nonzero matrix entries.
num_entries_per_rowMaximum number of nonzeros per row.
template<typename IndexType, typename ValueType, typename MemorySpace>
void cusp::ell_matrix< IndexType, ValueType, MemorySpace >::resize ( const size_t  num_rows,
const size_t  num_cols,
const size_t  num_entries,
const size_t  num_entries_per_row,
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_entries_per_rowMaximum number of nonzeros per row.
alignmentAmount of padding used to align the data structure (default 32).
template<typename IndexType, typename ValueType, typename MemorySpace>
void cusp::ell_matrix< IndexType, ValueType, MemorySpace >::swap ( ell_matrix< IndexType, ValueType, MemorySpace > &  matrix)

Swap the contents of two ell_matrix objects.

Parameters
matrixAnother ell_matrix with the same IndexType and ValueType.

Member Data Documentation

template<typename IndexType, typename ValueType, typename MemorySpace>
column_indices_array_type cusp::ell_matrix< IndexType, ValueType, MemorySpace >::column_indices

Storage for the column indices of the ELL data structure.

Definition at line 162 of file ell_matrix.h.

template<typename IndexType, typename ValueType, typename MemorySpace>
const IndexType cusp::ell_matrix< IndexType, ValueType, MemorySpace >::invalid_index = static_cast<IndexType>(-1)
static

Value used to pad the rows of the column_indices array.

Definition at line 132 of file ell_matrix.h.

template<typename IndexType, typename ValueType, typename MemorySpace>
values_array_type cusp::ell_matrix< IndexType, ValueType, MemorySpace >::values

Storage for the nonzero entries of the ELL data structure.

Definition at line 166 of file ell_matrix.h.