Re: [Numpy-discussion] vectorizing loops

2007-10-25 Thread Robert Kern
Gael Varoquaux wrote: > On Thu, Oct 25, 2007 at 04:16:06PM -0700, Mathew Yeates wrote: >> Anybody know of any tricks for handling something like > >> z[0]=1.0 >> for i in range(100): >> out[i]=func1(z[i]) >> z[i+1]=func2(out[i]) > > Something like: > > z[0] = 1. > out = func1(z) > z[1:]

Re: [Numpy-discussion] vectorizing loops

2007-10-25 Thread David Cournapeau
Gael Varoquaux wrote: > On Thu, Oct 25, 2007 at 04:16:06PM -0700, Mathew Yeates wrote: >> Anybody know of any tricks for handling something like > >> z[0]=1.0 >> for i in range(100): >> out[i]=func1(z[i]) >> z[i+1]=func2(out[i]) > > Something like: > > z[0] = 1. > out = func1(z) > z[1:] = f

Re: [Numpy-discussion] vectorizing loops

2007-10-25 Thread Gael Varoquaux
On Thu, Oct 25, 2007 at 04:16:06PM -0700, Mathew Yeates wrote: > Anybody know of any tricks for handling something like > z[0]=1.0 > for i in range(100): > out[i]=func1(z[i]) > z[i+1]=func2(out[i]) Something like: z[0] = 1. out = func1(z) z[1:] = func2(out[:-1]) HTH, Gaël _

Re: [Numpy-discussion] C-API for non-contiguous arrays

2007-10-25 Thread David Cournapeau
Oliver Kranz wrote: > Hi, > > I am working on a Python extension module using of the NumPy C-API. The > extension module is an interface to an image processing and analysis > library written in C++. The C++ functions are exported with > boos::python. Currently I am implementing the support of >

[Numpy-discussion] vectorizing loops

2007-10-25 Thread Mathew Yeates
Anybody know of any tricks for handling something like z[0]=1.0 for i in range(100): out[i]=func1(z[i]) z[i+1]=func2(out[i]) ?? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-di

[Numpy-discussion] fortran array storage question

2007-10-25 Thread Georg Holzmann
Hallo! I have the following problem: I get a data array in column major storage order and want to use it as numpy array without copying data. Therefore I do the following (2D example): obj = PyArray_FromDimsAndData(2, dim0, PyArray_DOUBLE, (char*)data); PyArrayObject *tmp = (PyArrayObject

Re: [Numpy-discussion] convolution and wiener khinchin

2007-10-25 Thread Stefan van der Walt
Hi John The signals should be zero-padded, otherwise you get circular convolution: F = npy.fft.fft(r,len(r)+len(x)-1) X = npy.fft.fft(x,len(r)+len(x)-1) Y = F*X yi = npy.fft.ifft(Y)[:len(x)].real Also take a look at fftconv. Regards Stéfan On Thu, Oct 25, 2007 at 01:00:29PM -0500, John Hunter

[Numpy-discussion] convolution and wiener khinchin

2007-10-25 Thread John Hunter
I am working on an example to illustrate convolution in the temporal and spectral domains, using the property that a convolution in the time domain is a multiplication in the fourier domain. I am using numpy.fft and numpy.convolve to compute the solution two ways, and comparing them. I am getting

Re: [Numpy-discussion] C-API for non-contiguous arrays

2007-10-25 Thread Oliver Kranz
Timothy Hochberg wrote: > > > On 10/25/07, *Oliver Kranz* <[EMAIL PROTECTED] > > wrote: > > Hi, > > I am working on a Python extension module using of the NumPy C-API. The > extension module is an interface to an image processing and analysis > library

Re: [Numpy-discussion] how to select indices from boolean array

2007-10-25 Thread Pauli Virtanen
wBernhard Voigt <[EMAIL PROTECTED]> kirjoitti: > is nonzero the appropriate function to get the indexes of a boolean array? > > foo = numpy.random.random(1) > cut = foo > .5 > indexes = cut.nonzero()[0] I think writing indices = where(foo > 5)[0] might be more clear, although it does t

[Numpy-discussion] how to select indices from boolean array

2007-10-25 Thread Bernhard Voigt
Dear list, is nonzero the appropriate function to get the indexes of a boolean array? foo = numpy.random.random(1) cut = foo > .5 indexes = cut.nonzero()[0] Another question: Why is the the type returned by nonzero a tuple and not an ndarray of the same shape as the input (or self if used on

Re: [Numpy-discussion] C-API for non-contiguous arrays

2007-10-25 Thread Timothy Hochberg
On 10/25/07, Oliver Kranz <[EMAIL PROTECTED]> wrote: > > Hi, > > I am working on a Python extension module using of the NumPy C-API. The > extension module is an interface to an image processing and analysis > library written in C++. The C++ functions are exported with > boos::python. Currently I a

[Numpy-discussion] C-API for non-contiguous arrays

2007-10-25 Thread Oliver Kranz
Hi, I am working on a Python extension module using of the NumPy C-API. The extension module is an interface to an image processing and analysis library written in C++. The C++ functions are exported with boos::python. Currently I am implementing the support of three-dimensional data sets whic