WRAP

Syntax: matrix = WRAP( matrix, scalar )

The WRAP function only accepts a matrix as its first argument. It wraps the column elements of a matrix by the specified step size, the scalar second argument.

Suppose the step size is n.

If n > 0, the column elements of the matrix are shifted down. The first n elements in the first column are zero filled, then the last n elements of each column are brought into the next column. The last n elements in the last column are lost.
If n = 0, the matrix is returned unchanged.
If n < 0, the column elements of the matrix are shifted up. The first n elements in the first column are lost. The first n elements of each column are brought into the preceding column. The last n elements in the last column are zero filled.

If the step size is not an integer, only the integer part will be used.

Examples

Suppose you have a matrix M

            | 1  2  3  4 |
        M = | 5  6  7  8 |
            | 9 10 11 12 |
 

functionresult
WRAP(M,2)
| 0 5  6  7 |
| 0 9 10 11 |
| 1 2  3  4 |
WRAP(M,-2)
| 9 10 11 12 |
| 2  3  4  0 |
| 6  7  8  0 |

  STEP
  FOLD