LLL reduced basis

asked 2025-08-13 03:29:45 +0200

ELLEI gravatar image

I am using Sage to find the LLL reduced log-unit lattices of number fields and this is how I do it:

bnf = K.pari_bnf()
UL = [[bnf[2][j][i].sage().real() for i in range(r+1)] for j in range(r)]
G=Matrix(RR, r, [u.dot_product(v) for u in UL for v in UL])
L = pari.qflllgram(pari(G)

In above, K is my number field and UL is the basis matrix. I use it to get the corresponding Gram matrix. When I use but L always is an identity matrix.

If I input the above Gram matrix directly in PARI to qflll(G), it outputs the correct transformation LLL reduction basis. why I always get identity matrix in Sage??

Thank you!

edit retag flag offensive close merge delete

Comments

Please add some complete code that actually runs. Do you mean something like this?

R.<x> = PolynomialRing(QQ)
f = R.zero()
while not f.is_irreducible():
    f = R.random_element(degree=5)
K.<a> = NumberField(f)
bnf = K.pari_bnf()
r = bnf[2].sage().nrows() - 1
UL = [vector([bnf[2][j][i].sage().real() for i in range(r+1)]) for j in range(r)]
G = Matrix(RR, r, [u.dot_product(v) for u in UL for v in UL])
L = pari.qflllgram(pari(G))
rburing gravatar imagerburing ( 2025-08-14 10:35:11 +0200 )edit