Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in NullspaceModQ #3614

Closed
fingolfin opened this issue Aug 21, 2019 · 2 comments · Fixed by #3690
Closed

Bug in NullspaceModQ #3614

fingolfin opened this issue Aug 21, 2019 · 2 comments · Fixed by #3690
Labels
good first issue Issues that can be understood and addressed by newcomers to GAP development kind: bug: wrong result Issues describing bugs that result in mathematically or otherwise wrong results, and PRs fixing them kind: bug Issues describing general bugs, and PRs fixing them

Comments

@fingolfin
Copy link
Member

The following was reported on https://math.stackexchange.com/questions/3329100:

gap> NullspaceModQ([[2]],8);
[ [ 0 ] ]

But it really should return the list [ [0], [4] ].

@fingolfin fingolfin added kind: bug Issues describing general bugs, and PRs fixing them kind: bug: wrong result Issues describing bugs that result in mathematically or otherwise wrong results, and PRs fixing them labels Aug 21, 2019
@fingolfin
Copy link
Member Author

One option would be to just ditch the current implementation and use this code instead (which then also works for arbitrary moduli):

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;

Alas, perhaps NullspaceModQ is faster in some cases? One would have to conduct experiments to find out (although fast but incorrect code is not that useful...).

Of course one could also instead improve BasisNullspaceModN and perhaps even make a BasisNullspaceModQ, which strikes me as more useful than NullspaceModQ anyway, at least for most purposes.

@hulpke
Copy link
Contributor

hulpke commented Aug 24, 2019

I am not sure whether NullspaceModQ is used anywhere. I would be happy with ditching the function completely (or replace it with the proposed code and move it on the way to obsolescence.

@fingolfin fingolfin added the good first issue Issues that can be understood and addressed by newcomers to GAP development label Aug 27, 2019
fingolfin added a commit to fingolfin/gap that referenced this issue Oct 6, 2019
Fixes gap-system#3614 and adds a manual example demonstrating the fixed behavior.
The old name NullspaceModQ is kept as an alias for backwards compatibility.
Also updated the documentation for NullspaceModN and BasisNullspaceModN.
fingolfin added a commit that referenced this issue Oct 10, 2019
Fixes #3614 and adds a manual example demonstrating the fixed behavior.
The old name NullspaceModQ is kept as an alias for backwards compatibility.
Also updated the documentation for NullspaceModN and BasisNullspaceModN.
fingolfin added a commit that referenced this issue Oct 18, 2019
Fixes #3614 and adds a manual example demonstrating the fixed behavior.
The old name NullspaceModQ is kept as an alias for backwards compatibility.
Also updated the documentation for NullspaceModN and BasisNullspaceModN.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues that can be understood and addressed by newcomers to GAP development kind: bug: wrong result Issues describing bugs that result in mathematically or otherwise wrong results, and PRs fixing them kind: bug Issues describing general bugs, and PRs fixing them
Projects
None yet
2 participants