Hi!
On 23 Okt., 11:59, Simon King <[email protected]> wrote:
> So, one should create an empty matrix and then insert the elements row
> by row.
It it also more efficient on a smaller skale (and does the right
thing):
sage: MS = MatrixSpace(ZZ,100,50)
sage: L = [[ZZ.random_element() for _ in range(50)] for __ in
range(100)]
sage: timeit('M = MS(0)\nfor i in range(len(L)): M[i]=L[i]')
625 loops, best of 3: 602 µs per loop
sage: timeit('M = Matrix(ZZ,L)')
125 loops, best of 3: 2.81 ms per loop
sage: M = MS(0)
sage: for i in range(len(L)): M[i]=L[i]
....:
sage: M == Matrix(ZZ,L)
True
Cheers,
Simon
--
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