函数 transpose #
转置矩阵。矩阵的所有值都将与其主对角线进行反射。仅适用于包含向量的二维矩阵(即大小为 [1,n] 或 [n,1])。一维向量和标量将原样返回输入。
Syntax #
math.transpose(x)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
Array | Matrix | 待转置的矩阵 |
Returns #
| Type | Description |
|---|---|
| Array | Matrix | 转置后的矩阵 |
Throws #
Type | Description —- | ———–
Examples #
const A = [[1, 2, 3], [4, 5, 6]]
math.transpose(A) // returns [[1, 4], [2, 5], [3, 6]]