[MATRIX-SIG] A proposal (LONG) - "reverse of take" revisited

Aaron Watters arw@dante.mh.lucent.com
Wed, 2 Jul 1997 07:38:04 -0400


Sorry.  Can't shut up!

> |ufunc.reduceat(a, indices, axis=0)                               
> |
> |   This is a weird function, and most people should just ignore it. It  
> |   will reduce a to each of the given indices so that as new size along
> |   the given axis will be the same as the length of indices.
> 
> This function is not weird. It is natural, powerful and useful. It
> reduces each block to one value.

Okay, let's just say the description is weird.  A simple two line
example of its use?

> Something like the following are needed (all defined recursively):
> 
> * A slice that does not make a copy, so I can modify a part of an image.
> * Efficiently view a big array as an array of blocks (each an array
> itself) and vice versa.
> * Convert an array of arrays to and from a big array.
> * The ability to extract, insert, and manipulate sub-blocks of blocks.
> For example, consider an interlaced image as an array of blocks, each
> with two rows. Construct a pair of new images containing the even and
> odd rows. Process these two images separately and recombine them.

If you are willing to pay a bit in overhead it seems to me that
it might be possible to prototype the concept(s) as a Python class
(or set of Python classes) that wrap an array.  After you're happy
with the Python implementation you could "push it down" to C
if it wasn't fast enough.  In fact I'd recommend all such proposals
have Python prototypes.  It might be the case that some of the
prototypes could be optimized well enough at the Python level
to be just fine.   -- Aaron Watters

_______________
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________