QR decomposition: Difference between revisions

Content added Content deleted
(→‎{{header|J}}: note built-in QR decomp function)
(→‎{{header|J}}: trim example to match other lang implementations)
Line 1,135: Line 1,135:
)</lang>
)</lang>


'''Example''': <lang j> ] matrix =: 12 _51 4,6 167 _68,:_4 24 _41
'''Example''': <lang j> QR 12 _51 4,6 167 _68,:_4 24 _41
12 _51 4
6 167 _68
_4 24 _41
QR matrix
+-----------------------------+----------+
+-----------------------------+----------+
| 0.857143 _0.394286 _0.331429|14 21 _14|
| 0.857143 _0.394286 _0.331429|14 21 _14|
| 0.428571 0.902857 0.0342857| 0 175 _70|
| 0.428571 0.902857 0.0342857| 0 175 _70|
|_0.285714 0.171429 _0.942857| 0 0 35|
|_0.285714 0.171429 _0.942857| 0 0 35|
+-----------------------------+----------+
+-----------------------------+----------+</lang>
x:&.> QR matrix NB. Display as exact fractions
+--------------------+----------+
| 6r7 _69r175 _58r175|14 21 _14|
| 3r7 158r175 6r175| 0 175 _70|
|_2r7 6r35 _33r35| 0 0 35|
+--------------------+----------+</lang>


'''Example''' (polynomial fitting using QR reduction):<lang j> X=:i.# Y=:1 6 17 34 57 86 121 162 209 262 321
'''Example''' (polynomial fitting using QR reduction):<lang j> X=:i.# Y=:1 6 17 34 57 86 121 162 209 262 321