Cholesky decomposition: Difference between revisions

m
→‎{{header|Raku}}: disambiguate with '×', clarify function/value setup, add output
m (syntax highlighting fixup automation)
m (→‎{{header|Raku}}: disambiguate with '×', clarify function/value setup, add output)
Line 3,098:
=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo|2015.12}}
<syntaxhighlight lang=raku line>sub cholesky(@A) {
my @L = @A »*×» 0;
for ^@A -> $\i {
for 0..$i -> $\j {
@L[$i][$;j] = ($i == $j ?? &sqrt !! 1/@L[$j][$;j] *× * )(\ # select function
(@A[$i][$;j] - [+] (@L[$i;*] Z* @L[$j;*])[^$j]) # provide value
); }
}
}
return @L;
}
 
.fmt('%3d').say for cholesky [
[25],
[15, 18],
Line 3,116 ⟶ 3,115:
];
 
.say for cholesky ['';
 
.fmt('6.3f').say for cholesky [
[18, 22, 54, 42],
[22, 70, 86, 62],
Line 3,122 ⟶ 3,123:
[42, 62, 134, 106],
];</syntaxhighlight>
{{out}}
<pre> 5
3 3
-1 1 3
 
4.243 0.000 0.000 0.000
5.185 6.566 0.000 0.000
12.728 3.046 1.650 0.000
9.899 1.625 1.850 1.393</pre>
 
=={{header|REXX}}==
2,392

edits