[Numpy-discussion] Shift or rotate command?

Alan G Isaac aisaac at american.edu
Sun Sep 24 20:41:22 CDT 2006


On Mon, 25 Sep 2006, Bill Baxter apparently wrote: 
> Went ahead and added an enhancement request: 
> http://projects.scipy.org/scipy/numpy/ticket/293 
> This is something I've wanted in the past too. 


GAUSS draws a useful distinction between "shifting" and 
"rotating":

Works roughly like this for the 2D case:

#rotater: rotate row elements
# Format:    y = rotater(x,r)
#            rotater(x,r)
# Input:     x           RxK array
#            rotateby    size R integer array, or integer (rotation amounts)
# Output:    y           RxK array:
#                          rows rotated by rotateby

#shiftr: shift row elements and fill with fv
# Format:    y = shiftr(x,shiftby,fv)
# Input:     x        RxC array
#            shiftby  Rx1 array or scalar (shift amounts)
#            fv       Rx1 array or scalar (fill values)
# Output:    y        RxC array:
#                       rows shifted by shiftby
#                       rows filled with fill

fwiw,
Alan Isaac







More information about the Numpy-discussion mailing list