UNPKG

1.09 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function qr
4
5Calculate the Matrix QR decomposition. Matrix `A` is decomposed in
6two matrices (`Q`, `R`) where `Q` is an
7orthogonal matrix and `R` is an upper triangular matrix.
8
9
10## Syntax
11
12```js
13math.qr(A)
14```
15
16### Parameters
17
18Parameter | Type | Description
19--------- | ---- | -----------
20`A` | Matrix &#124; Array | A two dimensional matrix or array for which to get the QR decomposition.
21
22### Returns
23
24Type | Description
25---- | -----------
26{Q: Array &#124; Matrix, R: Array &#124; Matrix} | Q: the orthogonal matrix and R: the upper triangular matrix
27
28
29## Examples
30
31```js
32const m = [
33 [1, -1, 4],
34 [1, 4, -2],
35 [1, 4, 2],
36 [1, -1, 0]
37]
38const result = math.qr(m)
39// r = {
40// Q: [
41// [0.5, -0.5, 0.5],
42// [0.5, 0.5, -0.5],
43// [0.5, 0.5, 0.5],
44// [0.5, -0.5, -0.5],
45// ],
46// R: [
47// [2, 3, 2],
48// [0, 5, -2],
49// [0, 0, 4],
50// [0, 0, 0]
51// ]
52// }
53```
54
55
56## See also
57
58[lup](lup.md),
59[lusolve](lusolve.md)