Is there a way to select the type of indices Ti with sprand()?

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?

I could probably use the similar() function as posted 3 hours ago here. Thanks @gdalle.

I am still wondering wether a sprand() method taking two types in parameters would be useful though :thinking: