The function sprand()
has methods to specify the type of the generated elements {Tv}
. But a SparseArray has two type parameters, the second being the type used to stores the indices {Ti}
. Does anyone have a magic trick to generate a random sparse matrix using Int32 (or others) instead of Int64?
The best way I found is to generate the matrix using A = sprand(Tv, m, n, fill)
and then type cast the internal arrays A.rowptr
and A.colval
, but it doesn’t feel right.
Would a new method of sprand taking two types in parameter make sense? Is there a reason it doesn’t exist yet?