def SLdshear(inputArray, k, axis):
"""
Computes the discretized shearing operator for a given inputArray, shear
number k and axis.
This version is adapted such that the MATLAB indexing can be used here in the
Python version.
"""
axis = axis - 1
if k==0:
return inputArray
rows = np.asarray(inputArray.shape)[0]
cols = np.asarray(inputArray.shape)[1]
shearedArray = np.zeros((rows, cols), dtype=inputArray.dtype)
if axis == 0:
for col in range(cols):
shearedArray[:,col] = np.roll(inputArray[:,col], int(k * np.floor(cols/2-col)))
else:
for row in range(rows):
shearedArray[row,:] = np.roll(inputArray[row,:], int(k * np.floor(rows/2-row)))
return shearedArray
评论列表
文章目录