On Wednesday, December 5, 2012 5:00:00 PM UTC, Dima Pasechnik wrote:
>
> On 2012-12-05, John Cremona <[email protected] <javascript:>> wrote: 
> > ------=_Part_32_14834482.1354721238473 
> > Content-Type: text/plain; charset=ISO-8859-1 
> > 
> > 
> > 
> > On Wednesday, December 5, 2012 1:56:55 PM UTC, Jason Grout wrote: 
> >> 
> >> On 12/5/12 7:46 AM, John Cremona wrote: 
> >> > I don't know why this takes so long: 
> >> > 
> >> > I have a field F (a snumber field of high degree, 288 in fact) and 
> >> > want to create a 100x100 matrix over F from a list of 100 lists of 
> 100 
> >> > elements of F, while I will call "entries".  If I do 
> >> > 
> >> > M = Matrix(entries) 
> >> > 
> >> > which certainly works fine with smaller examples, then I get tired of 
> >> > waiting (after 10 or 15 minutes) and cannot even interrupt with 
> >> > Ctrl-C.  But if I do 
> >> > 
> >> > M = copy(MatrixSpace(F,100).zero_matrix()) 
> >> > for i in range(100): 
> >> >     for j in range(100): 
> >> >        M[i,j] = entries[i,j] 
> >> > 
> >> > it works in a few seconds.  So what is going wrong with the first 
> >> (simpler) way? 
> >> 
> >> If you just do Matrix(entries), it tries to guess the right base ring 
> >> (using the Sequence() command, IIRC).  In the second example, you are 
> >> explicitly telling Sage the base ring.  I wonder if that is what is 
> >> going on.  To check, can you try doing: 
> >> 
> >> matrix(F, entries) 
> >> 
> >> 
> > That is slow too.  Try 
> > 
> > 
> > Q1092.<z>=CyclotomicField(1092) 
> > entries = [[Q1092.zero_element() for i in range(100)] for j in 
> range(100)] 
> > M=Matrix(Q1092,entries) 
> > 
> > which takes a long time (*) and cannot be interrupted with Ctrl-C. 
>
> from what Volker wrote, it can be gathered that 
> M=Matrix(Q1092,entries,sparse=True) 
> might work much faster. 
>

But Dima, the actual matrix I want to create has almost no zero entries; 
 the zero matrix example was just a simplification to illustrate the issue. 
 Or you you actually mean that tagging the matrix as sparse would be worth 
trying even if it is not?
 
John


> Dima 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to