mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
54 lines
1.4 KiB
Markdown
54 lines
1.4 KiB
Markdown
---
|
|
layout: default
|
|
---
|
|
|
|
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
|
|
|
<h1 id="function-transpose">Function transpose <a href="#function-transpose" title="Permalink">#</a></h1>
|
|
|
|
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.
|
|
|
|
|
|
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.transpose(x)
|
|
```
|
|
|
|
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`x` | Array | Matrix | Matrix to be transposed
|
|
|
|
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
Array | Matrix | The transposed matrix
|
|
|
|
|
|
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
|
|
|
|
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
const A = [[1, 2, 3], [4, 5, 6]]
|
|
math.transpose(A) // returns [[1, 4], [2, 5], [3, 6]]
|
|
```
|
|
|
|
|
|
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
|
|
|
[diag](diag.html),
|
|
[inv](inv.html),
|
|
[subset](subset.html),
|
|
[squeeze](squeeze.html)
|