[Numpy-discussion] "aligned" matrix / ctypes

Robert Kern robert.kern@gmail....
Fri Apr 25 13:51:37 CDT 2008

On Fri, Apr 25, 2008 at 11:09 AM, Zachary Pincus
<zachary.pincus@yale.edu> wrote:
> 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 function for allocating arrays with totally arbitrary
> alignment along each dimension (e.g. you could allocate an 10x20 array of
> uint16's where each uint16 is aligned to 4-byte boundaries and each row of
> 20 uint16's is aligned to 32-byte boundaries, and the entire buffer is
> aligned to a 128-byte boundary.) I've also included helper functions for two
> common cases: when you want everything aligned to a particular multiple
> (every element, row, etc. as well as the whole buffer), and when you want an
> array where the rows (second-fastest moving index) are so aligned (this was
> my original use case, for fast image-blitting).

There is one more important case, which is aligning just the beginning
of the array.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco

More information about the Numpy-discussion mailing list