New answers tagged sparse-arrays
6
Looking at the InputForm or FullForm of the expression which, while not equivalent to the internal data format, shows something of the structure and what is stored:
SparseArray[{{1, 1} -> 999, {5, 100} -> 999}] // InputForm
SparseArray[Automatic, {5, 100}, 0, {1, {{0, 1, 1, 1, 1, 2}, {{1}, {100}}}, {999, 999}}]
versus:
SparseArray[{{1, 1} -> ...
3
It may not be highly time-efficient (read this) but you can make Part assignments to a SparseArray object just as you would a conventional array, therefore you merely need to replace your ConstantArray with:
SparseArray[{}, {n*n, n*n}]
You can also specify a different background for the array with the third argument:
SparseArray[{}, {n*n, n*n}, 5]
...
6
The two file formats I am familiar with, with respect to sparse matrices, are the Harwell-Boeing format, and the Matrix Market format. I have linked to the docs on how you can Import[]/Export[] matrices in those formats, and you'll do well by reading up on them.
Sparse arrays are very much different from lists. For instance, consider these two ...
Top 50 recent answers are included
