Re: [Numpy-discussion] aligned matrix / ctypes

2008-04-25 Thread Zachary Pincus
Hello all, Attached is code (plus tests) for allocating aligned arrays -- I think this addresses all the requests in this thread, with regard to allowing for different kinds of alignment. Thanks Robert and Anne for your help and suggestions. Hopefully this will be useful. The core is a

Re: [Numpy-discussion] aligned matrix / ctypes

2008-04-25 Thread Stéfan van der Walt
Robert, Can we check this in somewhere under numpy.core? It seems very useful. Stéfan 2008/4/25 Zachary Pincus [EMAIL PROTECTED]: Hello all, Attached is code (plus tests) for allocating aligned arrays -- I think this addresses all the requests in this thread, with regard to allowing for

Re: [Numpy-discussion] aligned matrix / ctypes

2008-04-24 Thread Sturla Molden
The problem with alignment on 3 byte boundaries, is that 3 is a prime and not a factor of the size of any common data type. (The only exception I can think of is 24 bit RGB values.) So in general, the elements in an array for which the first element is aligned on a 3 byte boundary, may or may not

[Numpy-discussion] aligned matrix / ctypes

2008-04-23 Thread Zachary Pincus
Hello all, I need to allocate a numpy array that I will then pass to a camera driver (via ctypes) so that the driver can fill the array with pixels. The catch is that the driver requires that rows of pixels start at 4- byte boundaries. The sample C++ code given for allocating memory for

Re: [Numpy-discussion] aligned matrix / ctypes

2008-04-23 Thread Robert Kern
On Wed, Apr 23, 2008 at 2:10 PM, Zachary Pincus [EMAIL PROTECTED] wrote: Hello all, I need to allocate a numpy array that I will then pass to a camera driver (via ctypes) so that the driver can fill the array with pixels. The catch is that the driver requires that rows of pixels start at

Re: [Numpy-discussion] aligned matrix / ctypes

2008-04-23 Thread Anne Archibald
On 23/04/2008, Zachary Pincus [EMAIL PROTECTED] wrote: Hi, Thanks a ton for the advice, Robert! Taking an array slice (instead of trying to set up the strides, etc. myself) is a slick way of getting this result indeed. It's worth mentioning that there was some discussion of adding an