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

Detailed description

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
class cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >

View of a coo_matrix.

Template Parameters
ArrayType1Type of row_indices 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
Note
The matrix entries must be sorted by row index.
The matrix should not contain duplicate entries.

A coo_matrix_view is a sparse matrix view of a matrix in COO format constructed from existing data or iterators. All entries in the coo_matrix are sorted according to row indices and internally within each row sorted by column indices.

Example
The following code snippet demonstrates how to create a 4-by-3 coo_matrix_view on the host with 6 nonzeros.
// include coo_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_indices(6);
IndexArray column_indices(6);
ValueArray values(6);
row_indices[0] = 0; column_indices[0] = 0; values[0] = 10;
row_indices[1] = 0; column_indices[1] = 2; values[1] = 20;
row_indices[2] = 2; column_indices[2] = 2; values[2] = 30;
row_indices[3] = 3; column_indices[3] = 0; values[3] = 40;
row_indices[4] = 3; column_indices[4] = 1; values[4] = 50;
row_indices[5] = 3; 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 coo_matrix
// change first entry in values array
values[0] = -1;
// print the updated matrix view
}
Examples:
cg_raw.cu.

Definition at line 306 of file coo_matrix.h.

#include <coo_matrix.h>

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

Public Methods

 coo_matrix_view (void)
 
 coo_matrix_view (const size_t num_rows, const size_t num_cols, const size_t num_entries, ArrayType1 row_indices, ArrayType2 column_indices, ArrayType3 values)
 
 coo_matrix_view (coo_matrix< IndexType, ValueType, MemorySpace > &matrix)
 
 coo_matrix_view (const coo_matrix< IndexType, ValueType, MemorySpace > &matrix)
 
 coo_matrix_view (view &matrix)
 
 coo_matrix_view (const view &matrix)
 
template<typename MatrixType >
 coo_matrix_view (MatrixType &matrix)
 
template<typename MatrixType >
 coo_matrix_view (const MatrixType &matrix)
 
void resize (const size_t num_rows, const size_t num_cols, const size_t num_entries)
 
void sort_by_row (void)
 
void sort_by_row_and_column (void)
 
bool is_sorted_by_row (void)
 
bool is_sorted_by_row_and_column (void)
 

Public Members

row_indices_array_type row_indices
 
column_indices_array_type column_indices
 
values_array_type values
 
cusp::array1d< typename
thrust::detail::remove_const
< IndexType >::type,
MemorySpace > 
indices
 

Proteced Methods

template<typename MatrixType >
void construct_from (MatrixType &matrix, csr_format)
 
template<typename MatrixType >
void construct_from (MatrixType &matrix, dia_format)
 
template<typename MatrixType >
void construct_from (MatrixType &matrix, ell_format)
 
template<typename MatrixType >
void construct_from (MatrixType &matrix, hyb_format)
 

Constructor & Destructor Documentation

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::coo_matrix_view ( void  )
inline

Construct an empty coo_matrix_view.

Definition at line 350 of file coo_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::coo_matrix_view ( const size_t  num_rows,
const size_t  num_cols,
const size_t  num_entries,
ArrayType1  row_indices,
ArrayType2  column_indices,
ArrayType3  values 
)
inline

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

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

Definition at line 364 of file coo_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::coo_matrix_view ( coo_matrix< IndexType, ValueType, MemorySpace > &  matrix)
inline

Construct a coo_matrix_view from a existing coo_matrix.

Parameters
matrixcoo_matrix used to create view.

Definition at line 379 of file coo_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::coo_matrix_view ( const coo_matrix< IndexType, ValueType, MemorySpace > &  matrix)
inline

Construct a coo_matrix_view from a existing const coo_matrix.

Parameters
matrixcoo_matrix used to create view.

Definition at line 389 of file coo_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::coo_matrix_view ( view &  matrix)
inline

Construct a coo_matrix_view from a existing coo_matrix_view.

Parameters
matrixcoo_matrix_view used to create view.

Definition at line 399 of file coo_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::coo_matrix_view ( const view &  matrix)
inline

Construct a coo_matrix_view from a existing const coo_matrix.

Parameters
matrixcoo_matrix used to create view.

Definition at line 410 of file coo_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
template<typename MatrixType >
cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::coo_matrix_view ( MatrixType &  matrix)

Construct a coo_matrix_view from a existing matrix in another format.

Parameters
matrixused to create view.
template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
template<typename MatrixType >
cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::coo_matrix_view ( const MatrixType &  matrix)

Construct a coo_matrix_view from a existing const matrix in another format.

Parameters
matrixused to create view.

Member Function Documentation

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
template<typename MatrixType >
void cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::construct_from ( MatrixType &  matrix,
csr_format   
)
protected

Initialize coo_matrix_view from csr_matrix.

Parameters
matrixAnother matrix in csr_format.
template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
template<typename MatrixType >
void cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::construct_from ( MatrixType &  matrix,
dia_format   
)
protected

Construct coo_matrix_view from dia_matrix.

Parameters
matrixAnother matrix in dia_format.
template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
template<typename MatrixType >
void cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::construct_from ( MatrixType &  matrix,
ell_format   
)
protected

Construct coo_matrix_view from ell_matrix.

Parameters
matrixAnother matrix in ell_format.
template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
template<typename MatrixType >
void cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::construct_from ( MatrixType &  matrix,
hyb_format   
)
protected

Construct coo_matrix_view from hyb_matrix.

Parameters
matrixAnother matrix in hyb_format.
template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
bool cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::is_sorted_by_row ( void  )

Determine whether matrix elements are sorted by row index

Returns
false, if the row indices are unsorted; true, otherwise.
template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
bool cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::is_sorted_by_row_and_column ( void  )

Determine whether matrix elements are sorted by row and column index

Returns
false, if the row and column indices are unsorted; true, otherwise.
template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
void cusp::coo_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.
template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
void cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::sort_by_row ( void  )

Sort matrix elements by row index

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
void cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::sort_by_row_and_column ( void  )

Sort matrix elements by row and column index

Member Data Documentation

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
column_indices_array_type cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::column_indices

View of the column indices of the COO data structure.

Definition at line 335 of file coo_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
cusp::array1d<typename thrust::detail::remove_const<IndexType>::type,MemorySpace> cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::indices

Storage for indices used to generate COO view.

Definition at line 345 of file coo_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
row_indices_array_type cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::row_indices

View of the row indices of the COO data structure. Also called the "row pointer" array.

Definition at line 330 of file coo_matrix.h.

template<typename ArrayType1, typename ArrayType2, typename ArrayType3, typename IndexType = typename ArrayType2::value_type, typename ValueType = typename ArrayType3::value_type, typename MemorySpace = typename cusp::minimum_space< typename ArrayType1::memory_space, typename ArrayType2::memory_space, typename ArrayType3::memory_space>::type>
values_array_type cusp::coo_matrix_view< ArrayType1, ArrayType2, ArrayType3, IndexType, ValueType, MemorySpace >::values

View for the nonzero entries of the COO data structure.

Definition at line 340 of file coo_matrix.h.