Handle large index values in SparseMatrix.