compressed sparse row representation
[[concept]]
Compressed Sparse Row (CSR) representation
Instead of writing out the row index for each element, we can collect the column indices for each row, put each of these collections together, and then have a pointer
tell us where to start reading.
If
- the
column
tensor containsentries. Each entry contains the column index for one of the non-zero elements, sorted by ascending row index. row
orpointer
tensor containsentries - the first
entries contain the starting index for where the row's elements start in the column
tensor - the last entry is
- the first
value
tensor containsentries and contains the non-zero elements sorted by row then column index.
Example
Pointer = [0 2 4 6]
Column = [0 2 2 3 0 1 1 3]
Value = [12 16 19 14 26 19 14 7]