ViennaCL - The Vienna Computing Library
1.5.2
|
A sparse square matrix in compressed sparse rows format. More...
#include <compressed_matrix.hpp>
Public Types | |
typedef viennacl::backend::mem_handle | handle_type |
typedef scalar< typename viennacl::tools::CHECK_SCALAR_TEMPLATE_ARGUMENT < SCALARTYPE >::ResultType > | value_type |
typedef vcl_size_t | size_type |
Public Member Functions | |
compressed_matrix () | |
Default construction of a compressed matrix. No memory is allocated. | |
compressed_matrix (vcl_size_t rows, vcl_size_t cols, vcl_size_t nonzeros=0, viennacl::context ctx=viennacl::context()) | |
Construction of a compressed matrix with the supplied number of rows and columns. If the number of nonzeros is positive, memory is allocated. | |
compressed_matrix (vcl_size_t rows, vcl_size_t cols, viennacl::context ctx) | |
Construction of a compressed matrix with the supplied number of rows and columns. If the number of nonzeros is positive, memory is allocated. | |
compressed_matrix (viennacl::context ctx) | |
compressed_matrix & | operator= (compressed_matrix const &other) |
Assignment a compressed matrix from possibly another memory domain. | |
void | set (const void *row_jumper, const void *col_buffer, const SCALARTYPE *elements, vcl_size_t rows, vcl_size_t cols, vcl_size_t nonzeros) |
Sets the row, column and value arrays of the compressed matrix. | |
void | reserve (vcl_size_t new_nonzeros) |
Allocate memory for the supplied number of nonzeros in the matrix. Old values are preserved. | |
void | resize (vcl_size_t new_size1, vcl_size_t new_size2, bool preserve=true) |
Resize the matrix. | |
entry_proxy< SCALARTYPE > | operator() (vcl_size_t i, vcl_size_t j) |
Returns a reference to the (i,j)-th entry of the sparse matrix. If (i,j) does not exist (zero), it is inserted (slow!) | |
const vcl_size_t & | size1 () const |
Returns the number of rows. | |
const vcl_size_t & | size2 () const |
Returns the number of columns. | |
const vcl_size_t & | nnz () const |
Returns the number of nonzero entries. | |
const handle_type & | handle1 () const |
Returns the OpenCL handle to the row index array. | |
const handle_type & | handle2 () const |
Returns the OpenCL handle to the column index array. | |
const handle_type & | handle () const |
Returns the OpenCL handle to the matrix entry array. | |
handle_type & | handle1 () |
Returns the OpenCL handle to the row index array. | |
handle_type & | handle2 () |
Returns the OpenCL handle to the column index array. | |
handle_type & | handle () |
Returns the OpenCL handle to the matrix entry array. | |
void | switch_memory_context (viennacl::context new_ctx) |
viennacl::memory_types | memory_context () const |
A sparse square matrix in compressed sparse rows format.
SCALARTYPE | The floating point type (either float or double, checked at compile time) |
ALIGNMENT | The internal memory size for the entries in each row is given by (size()/ALIGNMENT + 1) * ALIGNMENT. ALIGNMENT must be a power of two. Best values or usually 4, 8 or 16, higher values are usually a waste of memory. |
typedef vcl_size_t size_type |
typedef scalar<typename viennacl::tools::CHECK_SCALAR_TEMPLATE_ARGUMENT<SCALARTYPE>::ResultType> value_type |
compressed_matrix | ( | ) | [inline] |
Default construction of a compressed matrix. No memory is allocated.
compressed_matrix | ( | vcl_size_t | rows, |
vcl_size_t | cols, | ||
vcl_size_t | nonzeros = 0 , |
||
viennacl::context | ctx = viennacl::context() |
||
) | [inline, explicit] |
Construction of a compressed matrix with the supplied number of rows and columns. If the number of nonzeros is positive, memory is allocated.
rows | Number of rows |
cols | Number of columns |
nonzeros | Optional number of nonzeros for memory preallocation |
ctx | Optional context in which the matrix is created (one out of multiple OpenCL contexts, CUDA, host) |
compressed_matrix | ( | vcl_size_t | rows, |
vcl_size_t | cols, | ||
viennacl::context | ctx | ||
) | [inline, explicit] |
Construction of a compressed matrix with the supplied number of rows and columns. If the number of nonzeros is positive, memory is allocated.
rows | Number of rows |
cols | Number of columns |
ctx | Context in which to create the matrix |
compressed_matrix | ( | viennacl::context | ctx | ) | [inline, explicit] |
const handle_type& handle | ( | ) | const [inline] |
Returns the OpenCL handle to the matrix entry array.
handle_type& handle | ( | ) | [inline] |
Returns the OpenCL handle to the matrix entry array.
const handle_type& handle1 | ( | ) | const [inline] |
Returns the OpenCL handle to the row index array.
handle_type& handle1 | ( | ) | [inline] |
Returns the OpenCL handle to the row index array.
const handle_type& handle2 | ( | ) | const [inline] |
Returns the OpenCL handle to the column index array.
handle_type& handle2 | ( | ) | [inline] |
Returns the OpenCL handle to the column index array.
viennacl::memory_types memory_context | ( | ) | const [inline] |
const vcl_size_t& nnz | ( | ) | const [inline] |
Returns the number of nonzero entries.
entry_proxy<SCALARTYPE> operator() | ( | vcl_size_t | i, |
vcl_size_t | j | ||
) | [inline] |
Returns a reference to the (i,j)-th entry of the sparse matrix. If (i,j) does not exist (zero), it is inserted (slow!)
compressed_matrix& operator= | ( | compressed_matrix< SCALARTYPE, ALIGNMENT > const & | other | ) | [inline] |
Assignment a compressed matrix from possibly another memory domain.
void reserve | ( | vcl_size_t | new_nonzeros | ) | [inline] |
Allocate memory for the supplied number of nonzeros in the matrix. Old values are preserved.
void resize | ( | vcl_size_t | new_size1, |
vcl_size_t | new_size2, | ||
bool | preserve = true |
||
) | [inline] |
Resize the matrix.
new_size1 | New number of rows |
new_size2 | New number of columns |
preserve | If true, the old values are preserved. At present, old values are always discarded. |
void set | ( | const void * | row_jumper, |
const void * | col_buffer, | ||
const SCALARTYPE * | elements, | ||
vcl_size_t | rows, | ||
vcl_size_t | cols, | ||
vcl_size_t | nonzeros | ||
) | [inline] |
Sets the row, column and value arrays of the compressed matrix.
row_jumper | Pointer to an array holding the indices of the first element of each row (starting with zero). E.g. row_jumper[10] returns the index of the first entry of the 11th row. The array length is 'cols + 1' |
col_buffer | Pointer to an array holding the column index of each entry. The array length is 'nonzeros' |
elements | Pointer to an array holding the entries of the sparse matrix. The array length is 'elements' |
rows | Number of rows of the sparse matrix |
cols | Number of columns of the sparse matrix |
nonzeros | Number of nonzeros |
const vcl_size_t& size1 | ( | ) | const [inline] |
Returns the number of rows.
const vcl_size_t& size2 | ( | ) | const [inline] |
Returns the number of columns.
void switch_memory_context | ( | viennacl::context | new_ctx | ) | [inline] |