template<typename IndexType, typename ValueType, class MemorySpace>
class cusp::csr_matrix< IndexType, ValueType, MemorySpace >
Compressed sparse row (CSR) representation a sparse matrix.
- Template Parameters
-
| IndexType | Type used for matrix indices (e.g. int). |
| ValueType | Type used for matrix values (e.g. float). |
| MemorySpace | A memory space (e.g. cusp::host_memory or cusp::device_memory) |
- Overview
- A
csr_matrix is a sparse matrix container that stores an offset to the first entry of each row in matrix and one column entry per nonzero. The matrix may reside in either "host" or "device" memory depending on the MemorySpace. All entries in the csr_matrix are sorted according to row and internally sorted within each row by column index.
- Note
- The matrix entries within the same row must be sorted by column index.
-
The matrix should not contain duplicate entries.
- Example
- The following code snippet demonstrates how to create a 4-by-3
csr_matrix on the host with 6 nonzeros and then copies the matrix to the device.
int main()
{
A.row_offsets[0] = 0;
A.row_offsets[1] = 2;
A.row_offsets[2] = 2;
A.row_offsets[3] = 3;
A.row_offsets[4] = 6;
A.column_indices[0] = 0; A.values[0] = 10;
A.column_indices[1] = 2; A.values[1] = 20;
A.column_indices[2] = 2; A.values[2] = 30;
A.column_indices[3] = 0; A.values[3] = 40;
A.column_indices[4] = 1; A.values[4] = 50;
A.column_indices[5] = 2; A.values[5] = 60;
}
Compressed sparse row (CSR) representation a sparse matrix.
Compressed Sparse Row matrix format.
void print(const Printable &p)
print a textual representation of an object
Print textual representation of an object.
Definition at line 107 of file csr_matrix.h.