[Numpy-discussion] Method to shift elements in an array?
mpi at osc.kiku.dk
Wed Feb 22 11:41:18 EST 2006
On Wed, 22 Feb 2006, Alan G Isaac wrote:
> On Wed, 22 Feb 2006, Zachary Pincus apparently wrote:
> > Does numpy have an built-in mechanism to shift elements along some
> > axis in an array? (e.g. to "roll" [0,1,2,3] by some offset, here 2,
> > to make [2,3,0,1])
> This sounds like the rotater command in GAUSS.
> As far as I know there is no equivalent in numpy.
> Please post your ultimate solution.
> Alan Isaac
Similar to cshift() (cyclic shift) in F90. Very nice for calculating
finite differences, such as
x' = ( cshift(x,+1) - cshift(x-1) ) / dx
This would be a very handy feature indeed.
More information about the NumPy-Discussion