Let A
and B
be sparse matrices with integer coefficients between 0
and p-1
, with p
prime. Which is the fastest way to compute their product mod p and obtain another sparse matrix? I'm mainly interested in p = 2
.
The code Mod[A.B, p]
returns a sparse matrix, but it may not be "optimal" in the sense that elements that are non-zero in A.B
but zero in Mod[A.B, p]
are stored. The code SparseArray[Mod[A.B, p]]
yields the correct result, but there should be a much faster way.
Inner[]
does not giveSparseArray[]
results, so that alternative's out. Are your actual matrices large enough thatSparseArray[Mod[A.B, p]]
is unfeasible? $\endgroup$ – J. M.'s ennui♦ Jul 2 '16 at 10:48SparseArray[Mod[A.B, p]]
and it's taking too long. $\endgroup$ – Oliver Miller Jul 2 '16 at 11:01