Skip to content

IntegerLattice.closest_vector() not finding a vector already in the lattice #38052

@marcvinyals

Description

@marcvinyals

Steps To Reproduce

IntegerLattice.closest_vector() sometimes gives answers that seem off, even when the input vector is already in the lattice. The following code triggers the issue:

from sage.modules.free_module_integer import IntegerLattice
v = vector(ZZ, [1,1,1,-1])
L = IntegerLattice([v])
print (v in L)
print (L.closest_vector(v))

Expected Behavior

Since $v\in L$, I would expect the output to be

True
(1,1,1,-1)

Actual Behavior

However, the actual output is

True
(0,0,0,0)

Additional Information

Fist asked in https://ask.sagemath.org/question/77550/integerlatticeclosest_vector-not-finding-a-vector-already-in-the-lattice/.

A different input such as v = vector(ZZ, [1,1,-1]) results in the expected behaviour. So does the method used by fpylll.

Environment

- **OS**: Gentoo and Manjaro
- **Sage Version**: 10.3

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions