Syntax: |
matrix = FOLD( vector, scalar )
|
The FOLD
function has two arguments. The first
must be a vector, and the second a scalar. The result is a matrix formed by folding the
data in the vector into the columns of a matrix.
Suppose that vector x
has m
elements. Then
FOLD(x,n)[i,j] = x[i+(j-1)*n]
for i = 1,2,...,n
and j = 1,2,...,m/n
.
Note that m
must be divisible by n
.
Examples
If M
is a matrix with R
rows, then
FOLD(UNFOLD(M),R)
is equal to M
.
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
.
function | result | ||||
FOLD([1:12],3) |
|
||||
FOLD([1:12],4) |
|