ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 03 Oct 2019 17:13:20 +0200Matrix transformation of a LLL reduced basishttps://ask.sagemath.org/question/48163/matrix-transformation-of-a-lll-reduced-basis/Dear Sage Community,
I am trying the way to obtain the matrix transformation of a LLL reduced basis, that is a matrix that gives the expression of the new lattice basis in terms of the old.
In particular, I have a matrix X and the LLL reduced base Y (obtain by the LLL function of Sage: Y=X.LLL()) and I want a matrix T such that TX=Y.
I try to solve the problem using solve.left() but the result is different from Magma.
With a matrix X=[5 2]
[1 4]
[2 3],
the T matrix in Sage is [ 0 0 0]
[ 2/9 -1/9 0]
[ 1/18 -5/18 0] while in Magma is [ -3 -6 10]
[ -3 -7 11]
[ -5 -11 18]
Please could anyone help me to understand a way to have in SAGE the same result of Magma?Thu, 03 Oct 2019 11:39:10 +0200https://ask.sagemath.org/question/48163/matrix-transformation-of-a-lll-reduced-basis/Answer by tmonteil for <p>Dear Sage Community,</p>
<p>I am trying the way to obtain the matrix transformation of a LLL reduced basis, that is a matrix that gives the expression of the new lattice basis in terms of the old. </p>
<p>In particular, I have a matrix X and the LLL reduced base Y (obtain by the LLL function of Sage: Y=X.LLL()) and I want a matrix T such that TX=Y.</p>
<p>I try to solve the problem using solve.left() but the result is different from Magma.
With a matrix X=[5 2]
[1 4]
[2 3],</p>
<p>the T matrix in Sage is [ 0 0 0]
[ 2/9 -1/9 0]
[ 1/18 -5/18 0] while in Magma is [ -3 -6 10]
[ -3 -7 11]
[ -5 -11 18]</p>
<p>Please could anyone help me to understand a way to have in SAGE the same result of Magma?</p>
https://ask.sagemath.org/question/48163/matrix-transformation-of-a-lll-reduced-basis/?answer=48168#post-id-48168Because you matrices are not square (hence not invertible), there may be many solutions, and given each propositions, you can actually check that the wanted equality holds. I am not sure about you actual problems, but you can have a look at the `pseudoinverse` method:
sage: X = matrix(ZZ, [[5,2],[1,4],[2,3]]) ; X
[5 2]
[1 4]
[2 3]
sage: Y = X.LLL() ; Y
[ 0 0]
[ 1 0]
[ 0 -1]
sage: T = Y*X.pseudoinverse() ; T
[ 0 0 0]
[ 21/94 -51/470 -1/235]
[ 4/47 -10/47 -5/47]
You can check:
sage: T*X == Y
TrueThu, 03 Oct 2019 17:13:20 +0200https://ask.sagemath.org/question/48163/matrix-transformation-of-a-lll-reduced-basis/?answer=48168#post-id-48168