transpose
This function transposes a m x n matrix to a n x m matrix.
The matrix must be rectangular. Consider filling short rows with blanks or zeros before transposing.
Indirect parameter passing is disabled
1
No. | Type | Description |
---|---|---|
1 input |
matrix | input matrix Matrix to be transposed |
Type | Description |
---|---|
matrix | Transposed matrix |
a[] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 } };
echo matrix( "0", 3, '|', 'a[] = ', a[] );
echo("Transpose matrix:");
t[] = transpose( a[] );
echo matrix( "0", 3, '|', 't[] = ', t[] );
| 1 2 3|
| 4 5 6|
a[] = | 7 8 9|
| 10 11 12|
Transpose matrix:
| 1 4 7 10|
t[] = | 2 5 8 11|
| 3 6 9 12|