Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In order to get the bug in some code, a good way to proceed is to reproduce the error using alternative, explicit, minimal code. This also applies for a question, if the answer does not show after the own try, it will pop up in a second when the question gets the point.

(There is no need to import the random package, there is no need to use a matrix space in between, then lift a matrix from characteristic seven, masked by Q = 7, then extend this matrix by seven times the identity matrix. You certainly had that matrix in your hand, so print it and use it as it is.)

I did the following to reproduce the error:

from sage.modules.free_module_integer import IntegerLattice

A = matrix(ZZ, [[1, 2], [4, 5], [3, 6], [5, 2]])
C = A.augment(7 * identity_matrix(4))
L = IntegerLattice(C)
print(L)

The print shows the following object, and shortly after the print i also wanted to see the basis, to confirm my suspicion:

Free module of degree 6 and rank 4 over Integer Ring
User basis matrix:
[1 2 7 0 0 0]
[5 2 0 0 0 7]
[4 5 0 7 0 0]
[3 6 0 0 7 0]
sage: L.basis()
[
(1, 2, 7, 0, 0, 0),
(5, 2, 0, 0, 0, 7),
(4, 5, 0, 7, 0, 0),
(3, 6, 0, 0, 7, 0)
]

So we do not have an object of vectors inside $\Bbb Z^4$, but rather inside $\Bbb Z^6$, and some vector with four components will be incompatible to this. Instead, let us try the transposed of the above $C$:

from sage.modules.free_module_integer import IntegerLattice

A = matrix(ZZ, [[1, 2], [4, 5], [3, 6], [5, 2]])
C = A.augment(7 * identity_matrix(4))
L = IntegerLattice(C.transpose())

u = [1, 2, 3, 4]
print(L.closest_vector(u))

This gives:

(1, 1, 3, 4)

In order to get the bug in some code, a good way to proceed is to reproduce the error using alternative, explicit, minimal code. This also applies for a question, written to go to the point without contorsions, and if the answer does not show after the own try, try to find it - which is the best way to improve the own path through structure and coding - , it will pop up in a second when the question gets the point. on this site (or elsewhere in a similar situation).

(There is no need to import the random package, there is no need to use a matrix space in between, then lift a matrix from characteristic seven, masked by Q = 7, then extend this matrix by seven times the identity matrix. You certainly had that matrix in your hand, so print it and use it as it is.)

I did the following to reproduce the error:

from sage.modules.free_module_integer import IntegerLattice

A = matrix(ZZ, [[1, 2], [4, 5], [3, 6], [5, 2]])
C = A.augment(7 * identity_matrix(4))
L = IntegerLattice(C)
print(L)

The print shows the following object, and shortly after the print i also wanted to see the basis, to confirm my suspicion:

Free module of degree 6 and rank 4 over Integer Ring
User basis matrix:
[1 2 7 0 0 0]
[5 2 0 0 0 7]
[4 5 0 7 0 0]
[3 6 0 0 7 0]
sage: L.basis()
[
(1, 2, 7, 0, 0, 0),
(5, 2, 0, 0, 0, 7),
(4, 5, 0, 7, 0, 0),
(3, 6, 0, 0, 7, 0)
]

So we do not have an object of vectors inside $\Bbb Z^4$, but rather inside $\Bbb Z^6$, and some vector with four components will be incompatible to this. Instead, let us try the transposed of the above $C$:

from sage.modules.free_module_integer import IntegerLattice

A = matrix(ZZ, [[1, 2], [4, 5], [3, 6], [5, 2]])
C = A.augment(7 * identity_matrix(4))
L = IntegerLattice(C.transpose())

u = [1, 2, 3, 4]
print(L.closest_vector(u))

This gives:

(1, 1, 3, 4)

In order to get the bug in some code, a good way to proceed is to reproduce the error using alternative, explicit, minimal code. This also applies for a question, written to go to the point without contorsions, and if the answer does not show after the own try to find it - which is the best way to improve the own path through structure and coding - , it will pop up in a second on this site (or elsewhere in a similar situation).

(There is no need to import the random package, there is no need to use a matrix space in between, then lift a matrix from characteristic seven, masked by Q = 7, then extend this matrix by seven times the identity matrix. You certainly had that matrix in your hand, so print it and use it as it is.)

I did the following to reproduce the error:

from sage.modules.free_module_integer import IntegerLattice

IntegerLattice

A = matrix(ZZ, [[1, 2], [4, 5], [3, 6], [5, 2]])
C = A.augment(7 * identity_matrix(4))
L = IntegerLattice(C)
print(L)

The print shows the following object, and shortly after the print i also wanted to see the basis, to confirm my suspicion:

Free module of degree 6 and rank 4 over Integer Ring
User basis matrix:
[1 2 7 0 0 0]
[5 2 0 0 0 7]
[4 5 0 7 0 0]
[3 6 0 0 7 0]
sage: L.basis()
[
(1, 2, 7, 0, 0, 0),
(5, 2, 0, 0, 0, 7),
(4, 5, 0, 7, 0, 0),
(3, 6, 0, 0, 7, 0)
]

So we do not have an object of vectors inside $\Bbb Z^4$, but rather inside $\Bbb Z^6$, and some vector with four components will be incompatible to this. Instead, let us try the transposed of the above $C$:

from sage.modules.free_module_integer import IntegerLattice

A = matrix(ZZ, [[1, 2], [4, 5], [3, 6], [5, 2]])
C = A.augment(7 * identity_matrix(4))
L = IntegerLattice(C.transpose())

u = [1, 2, 3, 4]
print(L.closest_vector(u))

This gives:

(1, 1, 3, 4)