David Joyner wrote: > Going form a vague memory: > My colleague was arguing that one should not teach > a course in scientific programming using Sage > because it was so slow in doing some very simple > things. Apparently if A is a vector or matrix in matlab > (ie, an array or real numbers) and f is a function > (eg, a sin or a polynomial), then f(A) is both > easy for the student to write and also super > optimized. He doubted Sage could do that. > So for large sized arrays with thousands of entries, > matlab would leave Sage in the dust. > > My only argument, if I remember, was that his > argument did not make intuitive sense. I said that > though I didn't know off the top of my head > how to write down the evaluation of a function > on a matrix in an optimized way, there must exist one. > With scipy used in industry for serious number-crunching, > it must be possible.
Indeed. With numpy and scipy, it is pretty easy. sage: a=random_matrix(ZZ,3) sage: a [ -1 0 1] [ 0 0 -72] [ -1 -1 0] sage: a_npy=a.numpy() sage: a_npy array([[ -1, 0, 1], [ 0, 0, -72], [ -1, -1, 0]]) sage: sin(a_npy) array([[-0.84147098, 0. , 0.84147098], [ 0. , 0. , -0.25382336], [-0.84147098, -0.84147098, 0. ]]) sage: However, Sage does not have extremely good integration between the symbolics and matrices just yet, so you do something like: sage: a.apply_map(sin) [ -sin(1) 0 sin(1)] [ 0 0 -sin(72)] [ -sin(1) -sin(1) 0] You might also be interested in http://www.scipy.org/NumPy_for_Matlab_Users Thanks, Jason -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org