UNFOLD

Syntax: vector = UNFOLD( matrix )

The UNFOLD function has one argument, which must be a matrix. The result is a vector formed by unfolding the rows of the matrix.

Suppose that matrix m has r rows and c columns. Then

UNFOLD(m)[i+(j-1)*r] = m[i,j] for i = 1,2,...,r and j = 1,2,...,c.

Examples

If X is a vector and N is a scalar such than LEN(X) is divisible by N, then UNFOLD(FOLD(X,N)) is equal to X

If M is a matrix with R rows, then FOLD(UNFOLD(M),R) is equal to M

Suppose that

       | 1  4  7 10 |
   M = | 2  5  8 11 |
       | 3  6  9 12 |
 
functionresult
UNFOLD(M) [1;2;3;4;5;6;7;8;9;10;11;12]