CSR/CSC format on Wikipedia for example, but the example is “bad” since they have 4 non-zeros and a 4x4 matrix.
Right, it can probably be explained better, but note that it says
Tiis the integer type for storing column pointers and row indices
so this is not column indices and row indices, it is column pointers and row indices.
Here is a concrete example:
julia> S = sparse([1 0 0;
3 0 4;
0 5 6.]);
julia> S.rowval
5-element Vector{Int64}:
1
2
3
2
3
julia> S.colptr
4-element Vector{Int64}:
1
3
4
6
julia> S.rowval
5-element Vector{Int64}:
1
2
3
2
3
where S.colptr[col] is the index into S.rowval for the first value in column col:
julia> S.colptr[2]
3
julia> S.nzval[S.colptr[2]]
5.0
so values in S.colptr must be able to point to the last element in S.nzval, ie it must be able to represent the number of non-zeros (+1).
For the COO format it would indeed be enough to represent up to max(N,M) where for a matrix with size NxM.