All the time is spent in Matrix_cyclo_dense.__init__ where a (nrows*ncols,
Q1092.degree()) rational matrix is constructed by first creating a list of
all nrows*ncols*Q1092.degree() entries:
elif isinstance(entries, list):
# This code could be made much faster using Cython, etc.
if coerce:
K = parent.base_ring()
entries = [K(a) for a in entries]
entries = sum([a.list() for a in entries], [])
<-------- all the time spent here
self._n = int(self._base_ring._n())
self._matrix = Matrix_rational_dense(MatrixSpace(QQ,
self._nrows*self._ncols, self._degree),
entries, copy=False,
coerce=False).transpose()
On Wednesday, December 5, 2012 3:27:18 PM UTC, John Cremona wrote:
>
>
>
> 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.
>
> John
>
> (*) I have not yet had the patience to wait until it completes!
>
>
>
>> Thanks,
>>
>> Jason
>>
>>
>>
--
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.