Wrong conclusion in previous txn!  The problem is with the matrix
routines and not with the Cyclotomics.
Wrote a couple of routines based on simple Gauss Seidel techniques
operating on a list of lists and produced the following results

F.<s>=CyclotomicField(29)
a=[[s^(i*j) for i in range(n)] for j in range(n)]
sage: time ai=gaussinv(a)
Time: CPU 0.72 s, Wall: 0.72 s
sage: x=matrix(a)
sage: time xi=x.inverse()
Time: CPU 2.74 s, Wall: 2.75 s
sage: time adet=gaussdet(a)
Time: CPU 0.33 s, Wall: 0.33 s
sage: time xdet=x.det()
Time: CPU 50.12 s, Wall: 50.14 s
sage: xi==matrix(ai)
True
sage: adet==xdet
True

So Cyclotomics looks fine.  I will use my own routines for the time
being.

Graham
On Mar 1, 10:17 am, firebird <[email protected]> wrote:
> Alastair
>
> Thanks for the rapid reply.
>
> Your Sage code is far superior to mine.  Very interesting and
> instructive!  Looks as though GAP->Sage recipe conversion may be
> easier than I thought.
>
> Original is just an example... GAP array is nothing special.
> All Sage Cyclotomics is very slow in comparison to GAP:-(
>
> Finally, mat.<tab> looks very useful.
>
> Graham
>
> On Feb 29, 10:35 pm, Alastair Irving <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > On 29/02/2012 19:54, firebird wrote:> I am having performance problems when 
> > using SAGE matrices with
> > > Cyclotomic Fields.  Processing in GAP appears almost instant, whereas
> > > the similar computation takes of the order  of a minute in SAGE. Am I
> > > missing something?
>
> > > Sage:
> > > F.<s>=CyclotomicField(29)
> > > m=[]
> > > n=20
> > > for i in range(n):
> > >    row=[]
> > >    for j in range(n):
> > >      row.append(s**(i*j))
> > >    m.append(row)
> > > mat=matrix(m)
>
> > There are shorter ways of creating this matrix.  I did it with
> > mat=Matrix(20,20,[s^(i*j) for i in range(20) for j in range(20)])
> > This isn't the only way, do
> > Matrix?
> > to see the documentation if you're interested in other possibilities,
> > (useing a function to define the matrix entries might be even shorter).
>
> > > print mat.det()
>
> > I agree this is slow, about 5 minutes on my system.  I did a few smaller
> > matrices and the time gets worse very rapidly as you increase the number
> > of rows.
>
> > > GAP:
> > > n:=20;
> > > m:=List([1..n],i->List([1..n],j->E(29)^(i*j)));
> > > Print(Determinant(m),"\n");
>
> > This is incredibly fast.  Is it possible that gap is recognising this as
> > a special determinant and just applying a standard formula?  I changed a
> > couple of random elements in the matrix to small integers and then the
> > computation took a bit longer.  It might be interesting to try a 20x20
> > matrix with random small entries over your field to see how long it takes.
>
> > If its not exploiting the structure of the matrix and is just much
> > quicker than sage then I suppose the question to answer would be if this
> > is caused by Sage taking many more field operations to do the
> > computation or if it is slower at doing the individual field operations.
>
> > > I am new to Sage and still find negotiating the documentation tricky.
> > > Where, for example, might I find a list of methods corresponding to
> > > class matrix?
>
> > Once you've defined your matrix you can type "mat." and then press tab
> > and it will list all the available methods.
>
> > I hope this is of some use
>
> > Alastair

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

Reply via email to