M2
M2 copied to clipboard
smithNormalForm bug
found by @mahrud in the discussion of #1273
i1 : debugLevel=101; R=QQ[x]
o2 = R
o2 : PolynomialRing
i3 : smithNormalForm matrix{{x^3+1},{x^2+1}}
-- count = 0
-- lead terms in columns (gb ) : | 0 |
| x2 |
-- lead terms in rows (not gb) : | x3 |
| x2 |
-- count = 1
-- lead terms in rows (gb ) : {0, 3} | 2 |
-- lead terms in columns (not gb) : {0, 3} | 2 |
-- count = 2
-- lead terms in columns (gb ) : {0, 3} | 2 |
-- lead terms in rows (not gb) : {0, 3} | 2 |
o3 = (| 2 |, | x+1 -x2-x+1 |, {3} | 1 |)
| 0 | | x2+1 -x3-1 |
| 0 | | x3+x2+x+1 -x4-x3-x-1 |
o3 : Sequence
the problem seems to be at the level of the GB computation:
i4 : syz gb (transpose matrix{{x^3+1},{x^2+1}},Syzygies=>true)
o4 = | x2+1 x3+x2+x+1 |
| -x3-1 -x4-x3-x-1 |
which finds 2 syzygies (?) which confuses the Smith normal form algorithm.
might as well mention the other issue that I found while investigating this: the first matrix of the output of smithNormalForm depends on the value of ChangeMatrix (even though it probably shouldn't). The reason is pretty simple: when ChangeMatrix is turned on (either for rows or columns), it will add extra zero rows/columns, but not if turned off. The obvious fix is to always add those extra zero rows/columns (which means always calling gb with Syzygies=>true).