This function will shift certain amount in a specific dimension of the array in either cyclic or off-edge mode. Explicit memory management for the shift is needed.