Hi,

I'm doing some computations with complex numbers and speed is
critical. I'm puzzled by the following.

sage: A= MatrixSpace(CDF, 2).random_element()
sage: B= MatrixSpace(CDF, 2).random_element()
sage: %timeit A*B
625 loops, best of 3: 20 µs per loop

sage: AA= numpy.array(A); BB= numpy.array(B)
sage: %timeit AA.dot(BB)
625 loops, best of 3: 2.24 µs per loop

So numpy seems much faster for this. But on the other hand

sage: z= A[0,0]
sage: %timeit z*z
625 loops, best of 3: 241 ns per loop
sage: zz= AA[0,0]
sage: %timeit zz*zz
625 loops, best of 3: 521 ns per loop

so now numpy is much slower!!

what is going on? is there a way to get the best of both worlds
simply, both for matrix operations and simple arithmetic?

i think zz above might still be considered as a 1 x 1 matrix instead
of a complex number, somehow, and this may be slowing things down.

any help appreciated!
thanks
pierre

-- 
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