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} -> 999, {100, 5} -> 999}] // InputForm
SparseArray[Automatic, {100,
5}, 0, {1, {{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2}, {{1}, {5}}}, {999, 999}}]
shows that some limited data is stored for every row in the array.
Therefore your expression will take up much less space if it is entered as:
num = 999999;
idSparse = SparseArray[{{1, 1} -> num, {10, 100000000} -> num}];
ByteCount[idSparse]
784
Of course your program will need to account for the changed orientation.