Lattices in Sage
I have the following Magma code, and I want to rewrite it in Sage.
L:=Lattice(Matrix(Rationals(),2,2,[N2t,0,tau,1]), Matrix(Rationals(),2,2,[1,0,0,D]));
"Lattice:\n",L;
"\nBasis matrix:\n",LLLBasisMatrix(L);
In Sage I have something like this:
M = Matrix(QQ, [(N2t,0,tau,1), (1,0,0,D)])
M.LLL()
Whose output is not exactly the same thing produced by the above Magma code. I think the main problem is that I use a matrix and just apply the LLL algorithm to it in the Sage part. Whereas, in Magma there a lattice created, and then the LLLBasisMatrix
function (https://magma.maths.usyd.edu.au/magma...) called. Roughly speaking that function does this:
Given a lattice L with basis matrix B, return the LLL basis matrix B' of L, together with the transformation matrix T such that B'=TB. The LLL basis matrix B' is simply defined to be a LLL-reduced form of B; it is stored in L when computed and subsequently used internally by many lattice functions. The LLL basis matrix will be created automatically internally as needed with δ=0.999 by default (note that this is different from the usual default of 0.75); by the use of parameters to this function one can ensure that the LLL basis matrix is created in a way which is different to the default.
How does one create a lattice in Sage? And does Sage have a function similar to LLLBasisMatrix
above? If not, how can I achieve the same functionality in Sage?
As for numeric example, I have the following values:
N2t = 1136868377216160297393798828125
D = 53364935730486508893809772233249725927747397616650814998641
tau = 954690521650617175389887577728
and if I call the above Magma code with these values, I get the following result for the basis matrix:
[-182177855565543122003911250397 1]
[ 772512666085074053385976327331 2]
whereas if I call the above Sage code with the above values, I get the following result:
[1136868377216160297393798828125 0 954690521650617175389887577728 1]
[1 0 0 53364935730486508893809772233249725927747397616650814998641]
Please describe mathematically what is Magma doing here:
The answer to this question may bring us closer...
What is $L$ exactly as a mathematical object?
Also, could it be please still possible to get numbers in a normal range, so that a potential helper does not have edit a lot in order to get for example that
for the "Basis matrix" (given in Magma, edited with bare hands to work in sage - no magma here).
Since the above cannot be purely incidental, some mathematical background is really welcome...
@dan_fulea $L$ is supposed to be a lattice generated by two vectors $(N_2,0)$ and $(\tau,1)$. The Magma code is not written by me, I'm just trying to convert it to Sage, that's why I also don't know exactly the need of the second matrix in the lattice generation.