Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error in finding the closest vector in a sublattice of Z^n

I'm trying to use the Sage package for discrete subgroups of Z^n.

But the "closest_vector()" function seems to be behaving incorrectly.

Here are some examples: The input

from sage.modules.free_module_integer import IntegerLattice

L = IntegerLattice([[2,0,0],[0,1,0]])
L
u=[0,0,0]
L.closest_vector(u)

yields the output

Free module of degree 3 and rank 2 over Integer Ring
User basis matrix:
[0 1 0]
[2 0 0]
(0, 0, 0)

as expected.

But the input

from sage.modules.free_module_integer import IntegerLattice

L = IntegerLattice([[2,0,0],[1,1,0]])
L
u=[0,0,0]
L.closest_vector(u)

yields the output

Free module of degree 3 and rank 2 over Integer Ring
User basis matrix:
[ 1  1  0]
[ 1 -1  0]
Error in lines 5-5
Traceback (most recent call last):
  File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
    flags=compile_flags) in namespace, locals
  File "", line 1, in <module>
  File "/ext/sage/sage-8.4_1804/local/lib/python2.7/site-packages/sage/modules/free_module_integer.py", line 787, in closest_vector
    voronoi_cell = self.voronoi_cell()
  File "sage/misc/cachefunc.pyx", line 1953, in sage.misc.cachefunc.CachedMethodCaller.__call__ (build/cythonized/sage/misc/cachefunc.c:10824)
    w = self._instance_call(*args, **kwds)
  File "sage/misc/cachefunc.pyx", line 1829, in sage.misc.cachefunc.CachedMethodCaller._instance_call (build/cythonized/sage/misc/cachefunc.c:10280)
    return self.f(self._instance, *args, **kwds)
  File "/ext/sage/sage-8.4_1804/local/lib/python2.7/site-packages/sage/modules/free_module_integer.py", line 724, in voronoi_cell
    return calculate_voronoi_cell(B, radius=radius)
  File "/ext/sage/sage-8.4_1804/local/lib/python2.7/site-packages/sage/modules/diamond_cutting.py", line 263, in calculate_voronoi_cell
    artificial_length = max(abs(v) for v in basis).ceil() * 2
  File "sage/structure/element.pyx", line 493, in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4550)
    return self.getattr_from_category(name)
  File "sage/structure/element.pyx", line 506, in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4659)
    return getattr_from_other_class(self, cls, name)
  File "sage/cpython/getattr.pyx", line 394, in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2536)
    raise AttributeError(dummy_error_message)
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'ceil'

What am I doing wrong?