Sagemath: Closest_vector not working on mxn matrix when m!=n?
I want to solve the following closest vector problem: Given an mxn matrix A where A \in Z_q^n and a vector u, find the closest vector to u in the q-ary lattice spanned by A, that is in the lattice that contains all points y=(Az mod q) for some z \in Z_q^n. Do to do this, I implemented the following sage code.
import random
from sage.modules.free_module_integer import IntegerLattice
Q = 7
B = [[1,2],[4,5],[3,6],[5,2]]
R = Integers(Q)
MS = MatrixSpace(R, 4, 2)
A= MS(B)
N = A.change_ring(ZZ)
N = N.augment(Q * identity_matrix(4)) # To enforce calculation modulo q
L = IntegerLattice(N)
u = [1,2,3,4]
print(L.closest_vector(u))
From my understanding, this should work even though m!=n, because the vectors in the lattice spanned by the Basis N are still 4-dimensional. However, I am getting the following error:
TypeError: unsupported operand parent(s) for *: 'Full MatrixSpace of 6 by 6 dense matrices over Rational Field' and 'Ambient free module of rank 4 over the principal ideal domain Integer Ring'
What am I doing wrong?