SHAPECOL
(matrix, nrow <, ncol> <, pad-value> ) ;
The SHAPECOL function reshapes and repeats values in a matrix. It is similar to the SHAPE function except that the SHAPECOL function produces the result matrix by traversing the argument matrix in column-major order.
The following statements demonstrate the SHAPECOL function:
A = {1 2 3, 4 5 6}; c = shapecol(A, 3); v = shapecol(A, 0, 1); print c v;
Figure 23.319: Reshaped Matrices
c | v | |
---|---|---|
1 | 5 | 1 |
4 | 3 | 4 |
2 | 6 | 2 |
5 | ||
3 | ||
6 |
The vector v
in the example is called the “vec of ” and is written . Uses of the operator in matrix algebra are described in Harville (1997). One important property is the relationship between the operator and the Kronecker product. If , , and have the appropriate dimensions, then
|
There is also a relationship between the SHAPECOL function and the SHAPE function. If is a matrix, then the following two computations are equivalent:
b = shapecol(A, m, n, padVal); c = T(shape(A`, n, m, padVal));
See the VECH function for a similar function that is useful for computing with symmetric matrices.