[Numpy-discussion] Square All Elements Of A Matrix
andrea_gavana at tin.it
andrea_gavana at tin.it
Thu May 12 12:36:24 EDT 2005
Hello David,
>Is this is a big problem for others? This is the first report I've
>seen of the problem on Windows. It may be worth special-casing the
>power ufunc to handle some non-array powers (x**2, x**3, x**0.5, for
>instance).
It's not very clear to me what you wrote, but I have the same behavior on
a Windows 2000 machine I have at work (here is WinXP), with Numeric 23.7
(here is 23.8), with Python 2.3.5 (here is 2.3.4). These 2 machines do not
have anything in common, as far as I know.
Regarding what you said (if I have correctly understood), I get:
>>>start = time.time(); td = dx*dx; print time.time() - start
0.269999980927
>>> start = time.time(); td = dx**2; print time.time() - start
4.5560002327
>>> start = time.time(); td = dx**3; print time.time() - start
4.5759999752
>>> start = time.time(); td = dx**0.5; print time.time() - start
4.19600009918
>>> start = time.time(); td = sqrt(dx); print time.time() - start
0.301000118256
>>> start = time.time(); td = exp(log(dx)); print time.time() - start
0.792000055313
>>> start = time.time(); td = dx**RandomArray.random((1,)); print time.time()
- start
4.14599990845
Whatever power I use, the timing is almost the same. Curious however, how
sqrt(dx) and dx**0.5 behave really differently.
Thanks for your help.
Andrea.
More information about the NumPy-Discussion
mailing list