I am trying to find a more efficient way to shift the columns of the partitions of an array according to a defined slope and fill in the shifted regions with zeros I have done it below but, I know it could probably done in a way that manages memory better and is probably faster too. Memory comes in to play for me when the array is really large. See the example code below.
columns = 40;
rows = 9;
data = Table[i*100 + j, {i, rows}, {j, columns}];
dt = 2;
steplength = 5*dt;
steps = Floor[columns/steplength];
shifts = Floor[steplength/Abs[dt]];
partdata = Partition[data, {rows, steplength}];
Do[step[i] = partdata[[1]][[i]], {i, steps}];
Do[dtstep[i] = Partition[step[i], {rows, Abs[dt]}], {i, steps}];
Do[shiftdtstep[i][j] = ArrayPad[dtstep[i][[1]][[j]], {If[dt >= 0, {shifts - j, j - 1}, {j - 1, shifts - j}],{0,0}}], {i, steps}, {j, shifts}];
Do[shiftedstep[i] = ArrayReshape[Transpose[Table[shiftdtstep[i][j], {j, shifts}]], {rows + shifts - 1,Abs[dt]*shifts}], {i, steps}];
shifteddata = ArrayReshape[Transpose[Table[shiftedstep[i], {i, steps}]], {rows + shifts - 1, steps*steplength}];
data // MatrixForm
shifteddata // MatrixForm
The important thing for me is that the variable dt can be either positive or negative and any value I choose within reason of the original data.