Every once in a while, I get to manipulate a csr_matrix
but I always forget how the parameters indices
and indptr
work together to build a sparse matrix.
I am looking for a clear and intuitive explanation on how the indptr
interacts with both the data
and indices
parameters when defining a sparse matrix using the notation csr_matrix((data, indices, indptr), [shape=(M, N)])
.
I can see from the scipy documentation that the data
parameter contains all the non-zero data, and the indices
parameter contains the columns associated to that data (as such, indices
is equal to col
in the example given in the documentation). But how can we explain in clear terms the indptr
parameter?