simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

qr.md (1142B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      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 &#124; 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 &#124; Matrix, R: Array &#124; Matrix} | Q: the orthogonal matrix and R: the upper triangular matrix
     27 
     28 
     29 ### Throws
     30 
     31 Type | Description
     32 ---- | -----------
     33 
     34 
     35 ## Examples
     36 
     37 ```js
     38 const m = [
     39   [1, -1,  4],
     40   [1,  4, -2],
     41   [1,  4,  2],
     42   [1,  -1, 0]
     43 ]
     44 const result = math.qr(m)
     45 // r = {
     46 //   Q: [
     47 //     [0.5, -0.5,   0.5],
     48 //     [0.5,  0.5,  -0.5],
     49 //     [0.5,  0.5,   0.5],
     50 //     [0.5, -0.5,  -0.5],
     51 //   ],
     52 //   R: [
     53 //     [2, 3,  2],
     54 //     [0, 5, -2],
     55 //     [0, 0,  4],
     56 //     [0, 0,  0]
     57 //   ]
     58 // }
     59 ```
     60 
     61 
     62 ## See also
     63 
     64 [lup](lup.md),
     65 [lusolve](lusolve.md)