1 |
|
2 |
|
3 | # Function qr
|
4 |
|
5 | Calculate the Matrix QR decomposition. Matrix `A` is decomposed in
|
6 | two matrices (`Q`, `R`) where `Q` is an
|
7 | orthogonal matrix and `R` is an upper triangular matrix.
|
8 |
|
9 |
|
10 | ## Syntax
|
11 |
|
12 | ```js
|
13 | math.qr(A)
|
14 | ```
|
15 |
|
16 | ### Parameters
|
17 |
|
18 | Parameter | Type | Description
|
19 | --------- | ---- | -----------
|
20 | `A` | Matrix | Array | A two dimensional matrix or array for which to get the QR decomposition.
|
21 |
|
22 | ### Returns
|
23 |
|
24 | Type | Description
|
25 | ---- | -----------
|
26 | {Q: Array | Matrix, R: Array | Matrix} | Q: the orthogonal matrix and R: the upper triangular matrix
|
27 |
|
28 |
|
29 | ## Examples
|
30 |
|
31 | ```js
|
32 | const m = [
|
33 | [1, -1, 4],
|
34 | [1, 4, -2],
|
35 | [1, 4, 2],
|
36 | [1, -1, 0]
|
37 | ]
|
38 | const 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)
|