On Wed, Jul 20, 2011 at 8:00 AM, Maarten Derickx
<m.derickx.stud...@gmail.com> wrote:
> I just found out that getting the transformation matrix is possible using
> some more low level part of the sage interface (i.e. use the ntl wrapper
> directly).
>
> sage: B=ntl.mat_ZZ(5,5,range(25))
> sage: B.LLL(return_U=True)
> (2, 1250, [
> [1 -2 1 0 0]
> [2 -3 0 1 0]
> [3 -4 0 0 1]
> [1 0 0 0 0]
> [-3 1 0 0 0]
> ])
>
> return_U is the keyword argument that also gives you the transformation
> matrix

The original poster figured that out too.  Unfortunately, the matrix
one gets that way above is *broken* due to a bug in the NTL wrapper:


sage: C = B.LLL(return_U=True)
sage: C[2]
[
[1 0 0 0 0]
[0 1 0 0 0]
[0 0 1 0 0]
[0 0 0 1 0]
[0 0 0 0 1]
]
sage: C[2].list()        # WTF?
[]

Here is an evil hack to get C[2]'s entries anyways:


sage: s = '[' + str(C[2]).replace('
',',').replace('[','').replace('\n','').replace(']',',')[:-2] + ']'
sage: v = sage_eval(s)
sage: v
[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]
sage: matrix(QQ, 5, v)
[1 0 0 0 0]
[0 1 0 0 0]
[0 0 1 0 0]
[0 0 0 1 0]
[0 0 0 0 1]

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to