[Matrix-SIG] Shifted array ops (was: RE: [Matrix-SIG] QUERY: Array indexing)

Frank Horowitz frank@ned.dem.csiro.au
Sat, 13 Mar 1999 18:21:50 +0800

Perry Stoll wrote:
> [Tim Peter's continues to dazzle, but stays true to his Buddha-nature by
> avoiding a practical solution ;]
> What I understand you're asking for is to perform operations on
> shifted/rotated versions of big matrices (aka numeric arrays). If that's what
> you're after, there is a way to do this sort of thing in NumPy using the
> built-in (since Python 1.5, I believe) slice type. The Python deities, in
> their glorious munificence, have given us the built-in function slice()
> to create slice objects.
> The idea is to build up a slice object to represent the particular view of
> the data needed and then apply the slice object to the numeric array you
> have. The slicing operation doesn't create a copy of the data; it's just a
> new view of the original data.
> You'll need to learn how slice objects get interpreted by Numeric, but I
> don't know where that's documented other than in the source. Does anyone know
> if such documetation exists?
> As a concrete example, take look at the functions in
>   http://starship.python.net/crew/jhauser/NumAdd.py.html

[A clinking sound, as the penny *finally* drops for Frank.]


> Of course, getting the end-cases right is your job ;)

Geee. And here I thought that posting dumb questions to this list was my
job :-)

Thanks to all concerned for their helpful answers!

(We now return you to your regularly scheduled "dazzling" soliloquys ;)