Re: [Numpy-discussion] numpy ndarray questions

2009-01-27 Thread Sturla Molden
> On Tue, 2009-01-27 at 14:16 +0100, Sturla Molden wrote: >> def aligned_array(N, dtype): >> d = dtype() >> tmp = numpy.array(N * d.nbytes + 16, dtype=numpy.uint8) >> address = tmp.__array_interface__['data'][0] >> offset = (16 - address % 16) % 16 >> return tmp[offset:off

Re: [Numpy-discussion] numpy ndarray questions

2009-01-27 Thread Jochen
On Tue, 2009-01-27 at 14:16 +0100, Sturla Molden wrote: > On 1/27/2009 12:37 PM, Sturla Molden wrote: > > > import ctypes > > import numpy > > > > fftw_malloc = ctypes.cdll.fftw.fftw_malloc > > fftw_malloc.argtypes = [ctypes.c_ulong,] > > fftw_malloc.restype = ctypes.c_ulong > > > > def aligned_

Re: [Numpy-discussion] numpy ndarray questions

2009-01-27 Thread Jochen
On Tue, 2009-01-27 at 12:37 +0100, Sturla Molden wrote: > On 1/27/2009 1:26 AM, Jochen wrote: > > > a = fftw3.AlignedArray(1024,complex) > > > > a = a+1 > > = used this way is not assignment, it is name binding. > > It is easy to use function's like fftw_malloc with NumPy: > > > import ctypes

Re: [Numpy-discussion] numpy ndarray questions

2009-01-27 Thread Sturla Molden
On 1/27/2009 12:37 PM, Sturla Molden wrote: > import ctypes > import numpy > > fftw_malloc = ctypes.cdll.fftw.fftw_malloc > fftw_malloc.argtypes = [ctypes.c_ulong,] > fftw_malloc.restype = ctypes.c_ulong > > def aligned_array(N, dtype): > d = dtype() > address = fftw_malloc(N * d.nbyte

Re: [Numpy-discussion] numpy ndarray questions

2009-01-27 Thread Sturla Molden
On 1/27/2009 12:37 PM, Sturla Molden wrote: > It is easy to use function's like fftw_malloc with NumPy: Besides this, if I were to write a wrapper for FFTW in Python, I would consider wrapping FFTW's Fortran interface with f2py. It is probably safer, as well as faster, than using ctypes. It wou

Re: [Numpy-discussion] numpy ndarray questions

2009-01-27 Thread Sturla Molden
On 1/27/2009 12:37 PM, Sturla Molden wrote: > address = fftw_malloc(N * d.nbytes) # restype = ctypes.c_ulong > if (address = 0): if (address == ): raise MemoryError, 'fftw_malloc returned NULL' Sorry for the typo. S.M. ___ Numpy-d

Re: [Numpy-discussion] numpy ndarray questions

2009-01-27 Thread Sturla Molden
On 1/27/2009 1:26 AM, Jochen wrote: > a = fftw3.AlignedArray(1024,complex) > > a = a+1 = used this way is not assignment, it is name binding. It is easy to use function's like fftw_malloc with NumPy: import ctypes import numpy fftw_malloc = ctypes.cdll.fftw.fftw_malloc fftw_malloc.argtypes =

Re: [Numpy-discussion] numpy ndarray questions

2009-01-27 Thread Sturla Molden
On 1/27/2009 6:03 AM, Jochen wrote: > BTW memmap arrays have > the same problem > if I create a memmap array and later do something like > a=a+1 > all later changes will not be written to the file. = is Python's rebinding operator. a = a + 1 rebinds a to a different object. As for ndarray's,

Re: [Numpy-discussion] numpy ndarray questions

2009-01-26 Thread Jochen
On Tue, 2009-01-27 at 14:46 +0900, David Cournapeau wrote: > Jochen wrote: > > On Tue, 2009-01-27 at 13:54 +0900, David Cournapeau wrote: > > > >> Jochen wrote: > >> > >>> On Tue, 2009-01-27 at 13:28 +0900, David Cournapeau wrote: > >>> > >>> > Jochen wrote: > > >>>

Re: [Numpy-discussion] numpy ndarray questions

2009-01-26 Thread David Cournapeau
Jochen wrote: > On Tue, 2009-01-27 at 13:54 +0900, David Cournapeau wrote: > >> Jochen wrote: >> >>> On Tue, 2009-01-27 at 13:28 +0900, David Cournapeau wrote: >>> >>> Jochen wrote: > On Tue, 2009-01-27 at 12:49 +0900, David Cournapeau wrote: >

Re: [Numpy-discussion] numpy ndarray questions

2009-01-26 Thread Jochen
On Tue, 2009-01-27 at 13:54 +0900, David Cournapeau wrote: > Jochen wrote: > > On Tue, 2009-01-27 at 13:28 +0900, David Cournapeau wrote: > > > >> Jochen wrote: > >> > >>> On Tue, 2009-01-27 at 12:49 +0900, David Cournapeau wrote: > >>> > >>> > Jochen wrote: > > >>>

Re: [Numpy-discussion] numpy ndarray questions

2009-01-26 Thread David Cournapeau
Jochen wrote: > On Tue, 2009-01-27 at 13:28 +0900, David Cournapeau wrote: > >> Jochen wrote: >> >>> On Tue, 2009-01-27 at 12:49 +0900, David Cournapeau wrote: >>> >>> Jochen wrote: > Hi all, > > I just wrote ctypes bindings to fftw3 (see >

Re: [Numpy-discussion] numpy ndarray questions

2009-01-26 Thread Jochen
On Tue, 2009-01-27 at 13:28 +0900, David Cournapeau wrote: > Jochen wrote: > > On Tue, 2009-01-27 at 12:49 +0900, David Cournapeau wrote: > > > >> Jochen wrote: > >> > >>> Hi all, > >>> > >>> I just wrote ctypes bindings to fftw3 (see > >>> http://projects.scipy.org/pipermail/scipy-user/200

Re: [Numpy-discussion] numpy ndarray questions

2009-01-26 Thread David Cournapeau
Jochen wrote: > On Tue, 2009-01-27 at 12:49 +0900, David Cournapeau wrote: > >> Jochen wrote: >> >>> Hi all, >>> >>> I just wrote ctypes bindings to fftw3 (see >>> http://projects.scipy.org/pipermail/scipy-user/2009-January/019557.html >>> for the post to scipy). >>> Now I have a couple of

Re: [Numpy-discussion] numpy ndarray questions

2009-01-26 Thread Jochen
On Tue, 2009-01-27 at 12:49 +0900, David Cournapeau wrote: > Jochen wrote: > > Hi all, > > > > I just wrote ctypes bindings to fftw3 (see > > http://projects.scipy.org/pipermail/scipy-user/2009-January/019557.html > > for the post to scipy). > > Now I have a couple of numpy related questions: > >

Re: [Numpy-discussion] numpy ndarray questions

2009-01-26 Thread David Cournapeau
Jochen wrote: > Hi all, > > I just wrote ctypes bindings to fftw3 (see > http://projects.scipy.org/pipermail/scipy-user/2009-January/019557.html > for the post to scipy). > Now I have a couple of numpy related questions: > > In order to be able to use simd instructions I > create an ndarray subcl

Re: [Numpy-discussion] numpy ndarray questions

2009-01-26 Thread Jochen
On Mon, 2009-01-26 at 19:25 -0600, Ryan May wrote: > Jochen wrote: > > Hi all, > > > > I just wrote ctypes bindings to fftw3 (see > > http://projects.scipy.org/pipermail/scipy-user/2009-January/019557.html > > for the post to scipy). > > Now I have a couple of numpy related questions: > > > > In

Re: [Numpy-discussion] numpy ndarray questions

2009-01-26 Thread Ryan May
Jochen wrote: > Hi all, > > I just wrote ctypes bindings to fftw3 (see > http://projects.scipy.org/pipermail/scipy-user/2009-January/019557.html > for the post to scipy). > Now I have a couple of numpy related questions: > > In order to be able to use simd instructions I > create an ndarray sub

[Numpy-discussion] numpy ndarray questions

2009-01-26 Thread Jochen
Hi all, I just wrote ctypes bindings to fftw3 (see http://projects.scipy.org/pipermail/scipy-user/2009-January/019557.html for the post to scipy). Now I have a couple of numpy related questions: In order to be able to use simd instructions I create an ndarray subclass, which uses fftw_malloc to