1
$\begingroup$

I have a list bdrs of SparseArrays, 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: enter image description here enter image description here

$\endgroup$
6
  • 1
    $\begingroup$ I think that's a bug you should report to Support. Here is a sketch of a workaround: use ArrayRules[] to extract your matrix entries, map PolynomialMod[] over all these entries, and reconstruct your SparseArray[] from this data. $\endgroup$ May 14, 2020 at 12:58
  • $\begingroup$ @J.M. Running ArrayRules and SparseArray on a large matrix is very inefficient. But still, thank you. $\endgroup$
    – Leo
    May 14, 2020 at 13:37
  • $\begingroup$ How "large" are we talking? $\endgroup$ May 14, 2020 at 13:43
  • $\begingroup$ "low density" - if it's not too much trouble, can you post the result of MatrixPlot[mat], where mat is your $10^7\times 10^7$ matrix? $\endgroup$ May 14, 2020 at 13:57
  • 1
    $\begingroup$ Could try Map[PolynomialMod[#, 2] &, bdrs, {2}] though I'd experiment with a smaller example to make sure it does not invoke Normal under the hood. Also I doubt the method suggested by @J.M. will be inefficient compared to what would result if SparseArray did thread the PolynomialMod in the way a List would do. $\endgroup$ May 14, 2020 at 15:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.