[Numpy-discussion] Square All Elements Of A Matrix

andrea_gavana at tin.it andrea_gavana at tin.it
Wed May 11 13:45:03 EDT 2005


Hello Fernando,

>I'm not sure what the problem may be, but I certainly don't see your results:
>
>In [22]: dx=RandomArray.random((200000, 10)).astype(Numeric.Float0)
>
>In [23]: time td1 = dx*2.0
>CPU times: user 0.20 s, sys: 0.06 s, total: 0.26 s
>Wall time: 0.26
>
>In [24]: time td2 = dx**2.0
>CPU times: user 0.30 s, sys: 0.06 s, total: 0.36 s
>Wall time: 0.36

This is what I get:

start = time.time(); td2 = dx**2; print time.time() - start
4.367000103

start = time.time(); td2 = dx*dx; print time.time() - start
0.121000051498

This is on a Windows XP, 1 GB RAM, 3.0 GHz, Python 2.3.4, Numeric 23.8.

>This is using Numeric 23.7 on  a Fedora3 box (2.6 GHZ P4).  Do you know
for a fact that 
>you have enough RAM, and that the 6 secs. don't come from paging (the arrays
aren't 
>that large, but you might have other stuff in memory forcing paging).

No, the only thing I have opened is PythonWin (the editor), and I am using
currently 100 MB of the RAM. I don't know why this happens...

Thanks for your help.

Andrea.





More information about the NumPy-Discussion mailing list