50 lines
934 B
Markdown
50 lines
934 B
Markdown
|
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
||
|
|
||
|
# Function transpose
|
||
|
|
||
|
Transpose a matrix. All values of the matrix are reflected over its
|
||
|
main diagonal. Only applicable to two dimensional matrices containing
|
||
|
a vector (i.e. having size `[1,n]` or `[n,1]`). One dimensional
|
||
|
vectors and scalars return the input unchanged.
|
||
|
|
||
|
|
||
|
## Syntax
|
||
|
|
||
|
```js
|
||
|
math.transpose(x)
|
||
|
```
|
||
|
|
||
|
### Parameters
|
||
|
|
||
|
Parameter | Type | Description
|
||
|
--------- | ---- | -----------
|
||
|
`x` | Array | Matrix | Matrix to be transposed
|
||
|
|
||
|
### Returns
|
||
|
|
||
|
Type | Description
|
||
|
---- | -----------
|
||
|
Array | Matrix | The transposed matrix
|
||
|
|
||
|
|
||
|
### Throws
|
||
|
|
||
|
Type | Description
|
||
|
---- | -----------
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
|
||
|
```js
|
||
|
const A = [[1, 2, 3], [4, 5, 6]]
|
||
|
math.transpose(A) // returns [[1, 4], [2, 5], [3, 6]]
|
||
|
```
|
||
|
|
||
|
|
||
|
## See also
|
||
|
|
||
|
[diag](diag.md),
|
||
|
[inv](inv.md),
|
||
|
[subset](subset.md),
|
||
|
[squeeze](squeeze.md)
|