1 |
|
2 |
|
3 | # Function transpose
|
4 |
|
5 | Transpose a matrix. All values of the matrix are reflected over its
|
6 | main diagonal. Only applicable to two dimensional matrices containing
|
7 | a vector (i.e. having size `[1,n]` or `[n,1]`). One dimensional
|
8 | vectors and scalars return the input unchanged.
|
9 |
|
10 |
|
11 | ## Syntax
|
12 |
|
13 | ```js
|
14 | math.transpose(x)
|
15 | ```
|
16 |
|
17 | ### Parameters
|
18 |
|
19 | Parameter | Type | Description
|
20 | --------- | ---- | -----------
|
21 | `x` | Array | Matrix | Matrix to be transposed
|
22 |
|
23 | ### Returns
|
24 |
|
25 | Type | Description
|
26 | ---- | -----------
|
27 | Array | Matrix | The transposed matrix
|
28 |
|
29 |
|
30 | ## Examples
|
31 |
|
32 | ```js
|
33 | const A = [[1, 2, 3], [4, 5, 6]]
|
34 | math.transpose(A) // returns [[1, 4], [2, 5], [3, 6]]
|
35 | ```
|
36 |
|
37 |
|
38 | ## See also
|
39 |
|
40 | [diag](diag.md),
|
41 | [inv](inv.md),
|
42 | [subset](subset.md),
|
43 | [squeeze](squeeze.md)
|