GAP — NullspaceModQ not working

92 Views Asked by At

I am using the GAP (Groups, Algorithms and Programming) system. For some reason the function NullspaceModQ (which is supposed to give a left kernel of matrix modulo a prime power $Q$) works incorrectly. While

NullspaceModQ([[4]],8)

correctly gives

[[0],[2],[4],[6]]

as an aswer, when I try

NullspaceModQ([[2]],8)

I get

[[0]]

Does anyone have any idea about what is wrong?

1

There are 1 best solutions below

0
On BEST ANSWER

This seems to be a long-standing bug in GAP (I just verified that it already occurs in GAP 4.4). I logged it in our issue tracker (see here), and hopefully this will be fixed in a future GAP version.

In the meantime, you can BasisNullspaceModN instead, which is undocumented, but is still perfectly safe to use; it is also likely to be more efficient if there are many solutions, as it only returns a $\mathbb{Z}$-basis of the null space, not all its elements. And from the basis, it's a an easy exercise to get all solutions. As a bonus, it supports arbitrary moduli, not just prime powers.

Indeed, here is a function which does the same as NullspaceModQ but for all moduli (it could be optimized, but for huge problems you are better of working with the basis instead anyway).

NullspaceModN := function(M, n)
  local B, coeffs;
  B := BasisNullspaceModN(M, n);
  coeffs := Cartesian(ListWithIdenticalEntries(Length(B), [0..n-1]));
  return Set(coeffs, c -> c * B mod n);
end;