I have a list bdrs
of SparseArray
s, whose entries are polynomials in the variable t
with integer coefficients. I would like to mod out all coefficients with an integer m
. A toy example:
bdrs={SparseArray[{{1,2}->1+2t+3t^2},{2,4}],SparseArray[{{4,3}->1+5t+7t^3},{4,3}]}
When I apply bdrs=PolynomialMod[bdrs,2]
, the matrices remain unchanged. How can I fix that?
For comparison, if the matrices contain only integers, then applying bdrs=Mod[bdrs,2]
works.
First running SetAttributes[PolynomialMod,Listable];
doesn't help. Also, bdrs=Thread@PolynomialMod[bdrs,2];
and bdrs=MapThread[PolynomialMod[#,2]&,bdrs,3];
return errors.
My matrices are very large and sparse (coming from cohomology theories), for example:
ArrayRules[]
to extract your matrix entries, mapPolynomialMod[]
over all these entries, and reconstruct yourSparseArray[]
from this data. $\endgroup$ArrayRules
andSparseArray
on a large matrix is very inefficient. But still, thank you. $\endgroup$MatrixPlot[mat]
, wheremat
is your $10^7\times 10^7$ matrix? $\endgroup$Map[PolynomialMod[#, 2] &, bdrs, {2}]
though I'd experiment with a smaller example to make sure it does not invokeNormal
under the hood. Also I doubt the method suggested by @J.M. will be inefficient compared to what would result ifSparseArray
did thread thePolynomialMod
in the way aList
would do. $\endgroup$