[Matrix-SIG] rotater?

Janne Sinkkonen janne@avocado.pc.helsinki.fi
17 Jun 1999 14:07:46 +0300


"Yoon, Hoon (CICG - NY Program Trading)" <HYoon@exchange.ml.com> writes:

>   Thanks much for your answer. It partially answer my Q. Unfortunately, this
> still means I need to loop over axis as you have said. Probably C extension
> time.

You can avoid looping over other axes by first swapping the target
axis to position -1 (bottom-most), then rotating by
 
    result[...,:n] = a[...,-n:] 
    result[...,n:] = a[...,:-n] 

and then swapping back. Swap axes by Numeric.transpose (official,
cumbersome) or Numeric.swapaxes(a,axis0,axis1) (undocumented, easier).
Swapping axes or transposing in general is computationally
cheaper than it appears, because array data is not copied. 

-- 
Janne