08.02.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Matrices</strong> <strong>and</strong> <strong>Spaces</strong> <strong>of</strong> <strong>Matrices</strong>, Release 6.1.1<br />

[ 2 1 0]<br />

[-1 1 3]<br />

We compute the extended GCD <strong>of</strong> a list <strong>of</strong> integers using LLL, this example is from the Magma h<strong>and</strong>book:<br />

sage: Q = [ 67015143, 248934363018, 109210, 25590011055, 74631449, \<br />

10230248, 709487, 68965012139, 972065, 864972271 ]<br />

sage: n = len(Q)<br />

sage: S = 100<br />

sage: X = Matrix(ZZ, n, n + 1)<br />

sage: for i in xrange(n):<br />

... X[i,i + 1] = 1<br />

sage: for i in xrange(n):<br />

... X[i,0] = S*Q[i]<br />

sage: L = X.LLL()<br />

sage: M = L.row(n-1).list()[1:]<br />

sage: M<br />

[-3, -1, 13, -1, -4, 2, 3, 4, 5, -1]<br />

sage: add([Q[i]*M[i] for i in range(n)])<br />

-1<br />

TESTS:<br />

sage: matrix(ZZ, 0, 0).LLL()<br />

[]<br />

sage: matrix(ZZ, 3, 0).LLL()<br />

[]<br />

sage: matrix(ZZ, 0, 3).LLL()<br />

[]<br />

sage: M = matrix(ZZ, [[1,2,3],[31,41,51],[101,201,301]])<br />

sage: A = M.LLL()<br />

sage: A<br />

[ 0 0 0]<br />

[-1 0 1]<br />

[ 1 1 1]<br />

sage: B = M.LLL(algorithm=’NTL:LLL’)<br />

sage: C = M.LLL(algorithm=’NTL:LLL’, fp=None)<br />

sage: D = M.LLL(algorithm=’NTL:LLL’, fp=’fp’)<br />

sage: F = M.LLL(algorithm=’NTL:LLL’, fp=’xd’)<br />

sage: G = M.LLL(algorithm=’NTL:LLL’, fp=’rr’)<br />

sage: A == B == C == D == F == G<br />

True<br />

sage: H = M.LLL(algorithm=’NTL:LLL’, fp=’qd’)<br />

Traceback (most recent call last):<br />

...<br />

TypeError: algorithm NTL:LLL_QD not supported<br />

ALGORITHM: Uses the NTL library by Victor Shoup or fpLLL library by Damien Stehle depending on<br />

the chosen algorithm.<br />

REFERENCES:<br />

•ntl.mat_ZZ or sage.libs.fplll.fplll for details on the used algorithms.<br />

LLL_gram()<br />

LLL reduction <strong>of</strong> the lattice whose gram matrix is self.<br />

INPUT:<br />

•M - gram matrix <strong>of</strong> a definite quadratic form<br />

316 Chapter 17. Dense matrices over the integer ring

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!