My goal is to find such properties of a sparse matrix as the maximum/average number of non-zero elements per row.
The brute-force way of doing this is via converting the sparse array into a regular one:
MaxSpar[matr_] := Module[{curr, ms = 0},
Do[
curr = Length[Cases[matr[[k]], 0]];
If[curr > ms, ms = curr];
, {k, 1, Length[matr]}
];
Return[ms];
];
MaxSpar[Normal[SomeSparseMatrix]]
How can we do the same without using Normal[]
?