With the Compressed Row Storage method, sparse matrices can be stored efficiently.
After reading different sources I could not find out how the number of columns of a n x m matrix is stored.
Although the maximum of col_ind suggests to be the number of columns, there seems to be no way to ensure that the last column(s) of the matrix is/are not empty.
How to store an n x m matrix if the last column consist entirely of zeros? (empty rows can be stored by a repeating value in rowPtr.)
Example 2 x 3 matrix:
(1 2 0)
(2 1 0)
Encoded CRS:
col_ind = [1,2,1,2]
val = [1,2,2,1]
row_ptr = [1, 3]
Decoded again:
(1 2) // 3rd column lost
(2 1)