mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
59 lines
985 B
Markdown
59 lines
985 B
Markdown
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
|
|
|
# Function qr
|
|
|
|
Calculate the Matrix QR decomposition. Matrix `A` is decomposed in
|
|
two matrices (`Q`, `R`) where `Q` is an
|
|
orthogonal matrix and `R` is an upper triangular matrix.
|
|
|
|
|
|
## Syntax
|
|
|
|
```js
|
|
math.qr(A);
|
|
```
|
|
|
|
### Parameters
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`A` | Matrix | Array | A two dimensional matrix or array
|
|
|
|
### Returns
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
{Q: Array | Matrix, R: Array | Matrix} | Q: the orthogonal
|
|
|
|
|
|
## Examples
|
|
|
|
```js
|
|
var m = [
|
|
[1, -1, 4],
|
|
[1, 4, -2],
|
|
[1, 4, 2],
|
|
[1, -1, 0]
|
|
];
|
|
var result = math.qr(m);
|
|
// r = {
|
|
// Q: [
|
|
// [0.5, -0.5, 0.5],
|
|
// [0.5, 0.5, -0.5],
|
|
// [0.5, 0.5, 0.5],
|
|
// [0.5, -0.5, -0.5],
|
|
// ],
|
|
// R: [
|
|
// [2, 3, 2],
|
|
// [0, 5, -2],
|
|
// [0, 0, 4],
|
|
// [0, 0, 0]
|
|
// ]
|
|
// }
|
|
```
|
|
|
|
|
|
## See also
|
|
|
|
[lu](lu.md)
|