Sparse Storage Formats¶
Compressed Sparse Row (CSR)
There are a variety of matrix storage formats available for representing
the sparse matrix. One of the most popular is the CSR format that is
represented by three arrays: row_ptr
, col_ind
and val
, and
the index parameter.
CSR Matrix Elements |
Description |
---|---|
|
Number of rows in the sparse matrix. |
|
Number of columns in the sparse matrix. |
|
Parameter that is used to specify whether the matrix has zero or one-based indexing. |
|
An array that contains the non-zero elements of the sparse matrix stored row by row. |
|
An integer array of column indices for non-zero elements stored in the |
|
An integer array of size equal to |
A sparse matrix can be represented in a CSR format in the following way (assuming zero-based indexing):
|
3 |
||||
---|---|---|---|---|---|
|
3 |
||||
|
0 |
||||
|
1 |
2 |
-1 |
4 |
3 |
|
0 |
2 |
1 |
2 |
0 |
|
0 |
2 |
4 |
5 |