Cholesky decomposition: Difference between revisions

With Numeric.LinearAlgebra
(Added Wren)
(With Numeric.LinearAlgebra)
Line 1,575:
9.899494936611665 1.6245538642137891 1.849711005231382 1.3926212476455924
</pre>
 
===With Numeric.LinearAlgebra===
<lang haskell>import Numeric.LinearAlgebra
 
a,b :: Matrix R
a = (3><3)
[25, 15, -5
,15, 18, 0
,-5, 0, 11]
 
b = (4><4)
[ 18, 22, 54, 42
, 22, 70, 86, 62
, 54, 86,174,134
, 42, 62,134,106]
 
main = do
let sa = sym a
sb = sym b
print sa
print $ chol sa
print sb
print $ chol sb
print $ tr $ chol sb
 
</lang>
{{out}}
<pre>Herm (3><3)
[ 25.0, 15.0, -5.0
, 15.0, 18.0, 0.0
, -5.0, 0.0, 11.0 ]
(3><3)
[ 5.0, 3.0, -1.0
, 0.0, 3.0, 1.0
, 0.0, 0.0, 3.0 ]
Herm (4><4)
[ 18.0, 22.0, 54.0, 42.0
, 22.0, 70.0, 86.0, 62.0
, 54.0, 86.0, 174.0, 134.0
, 42.0, 62.0, 134.0, 106.0 ]
(4><4)
[ 4.242640687119285, 5.185449728701349, 12.727922061357857, 9.899494936611665
, 0.0, 6.565905201197403, 3.0460384954008553, 1.6245538642137891
, 0.0, 0.0, 1.6497422479090704, 1.849711005231382
, 0.0, 0.0, 0.0, 1.3926212476455904 ]
(4><4)
[ 4.242640687119285, 0.0, 0.0, 0.0
, 5.185449728701349, 6.565905201197403, 0.0, 0.0
, 12.727922061357857, 3.0460384954008553, 1.6497422479090704, 0.0
, 9.899494936611665, 1.6245538642137891, 1.849711005231382, 1.3926212476455904 ]</pre>
 
=={{header|Icon}} and {{header|Unicon}}==
Anonymous user