Re: [Numpy-discussion] Sum, multiply are slow ?

2007-07-11 Thread David Cournapeau
Travis Oliphant wrote: > David Cournapeau wrote: > >> Hi, >> >> While profiling some code, I noticed that sum in numpy is kind of >> slow once you use axis argument: >> >> > Yes, this is expected because when using an access argument, the > following two things can happen > > 1

Re: [Numpy-discussion] Sum, multiply are slow ?

2007-07-11 Thread Travis Oliphant
David Cournapeau wrote: > Hi, > > While profiling some code, I noticed that sum in numpy is kind of > slow once you use axis argument: > Yes, this is expected because when using an access argument, the following two things can happen 1) You may be skipping over large chunks of memory

Re: [Numpy-discussion] Sum, multiply are slow ?

2007-07-11 Thread dmitrey
very interesting, however, it would be better if you provide exact code. I didn't use timeit and I have some troubles with the module. Regards, D. David Cournapeau wrote: > Hi, > > While profiling some code, I noticed that sum in numpy is kind of > slow once you use axis argument: > > im

[Numpy-discussion] Sum, multiply are slow ?

2007-07-11 Thread David Cournapeau
Hi, While profiling some code, I noticed that sum in numpy is kind of slow once you use axis argument: import numpy as N a = N.random.randn(1e5, 30) %timeit N.sum(a) #-> 26.8ms %timeit N.sum(a, 1) #-> 65.5ms %timeit N.sum(a, 0) #-> 141ms Now, if I use some tricks, I get: %timeit N.sum(a

Re: [Numpy-discussion] How do I tell f2py to generate Numeric modules?

2007-07-11 Thread Lisandro Dalcin
On 7/10/07, Ben ZX <[EMAIL PROTECTED]> wrote: > I ran f2py. It seems to always generate NumPy modules. > > How do I tell f2py to generate Numeric modules? If you do $ f2py -h you will see near the beginning the option '--2d-numeric'. I never tested it (moved to numpy from its very beginings)

Re: [Numpy-discussion] Conversion from numarray to numpy

2007-07-11 Thread Eike Welk
Sorry, I made a typo! On Wednesday 11 July 2007 17:32, Eike Welk wrote: > On Wednesday 11 July 2007 12:52, Michał Szpadzik wrote: > > I would like to know how change this True/False to 1/0 > > To convert an array of bool to an array double, you can use the > function numpy.doube( ... ). The functi

[Numpy-discussion] alter_code1.py changes .stddev() to .std() ...

2007-07-11 Thread Xavier Saint-Mleux
Hello, I'm having a lot of fun converting python code from numarray to numpy and I just found out that the alter_code1.py conversion script changes numarray's '.stddev()' to numpy's '.std()', even though the semantics are different ("sample" std.dev. or not; divide by N-1 vs. by N). Should I o

Re: [Numpy-discussion] Conversion from numarray to numpy

2007-07-11 Thread Eike Welk
On Wednesday 11 July 2007 12:52, Michał Szpadzik wrote: > I would like to know how change this True/False to 1/0 To convert an array of bool to an array double, you can use the function numpy.doube( ... ). The function numpy.int32( ... ) converts to integers. Regards, Eike. ___

Re: [Numpy-discussion] Conversion from numarray to numpy

2007-07-11 Thread Keith Goodman
On 7/11/07, Michał Szpadzik <[EMAIL PROTECTED]> wrote: > I would like to know how change this True/False to 1/0 Multiplying by 1 changes the True/False to 1/0. But sum gives the same result for True/False as it does for 1/0. So maybe you don't need to convert from True/False to 1/0? __

[Numpy-discussion] Conversion from numarray to numpy

2007-07-11 Thread Michał Szpadzik
Some time ago I wrote small lib for signal processing. Now I'm trying to convert it from numarray to numpy, and I've problem: Code in numarray: for i in range(len(myinput)-m+1): cin=tempmatr[:] ctmp=tempmatr[i] xtmp=(numarray.abs(cin-ctmp))<=r x2tmp=numarray.sum(n