Deconvolution/1D: Difference between revisions

m
→‎{{header|Perl 6}}: fixed 'trim_system'
(→‎{{header|Haskell}}: Fixed a compilation error (GHC 8.02), removed redundant import, applied hlint, hindent)
m (→‎{{header|Perl 6}}: fixed 'trim_system')
Line 808:
 
=={{header|Perl 6}}==
{{works with|Rakudo 2015-09-07|2018.02}}
<!-- SqrtNegInf: 'trim_system' was causing the calc. to fail, so skip for now -->
 
Translation of Python, using a modified version of the Reduced Row Echelon Form subroutine <code>rref()</code> from [[Reduced row echelon form#Perl 6|here]].
Line 835 ⟶ 834:
my ($lead, $rows, $cols) = 0, +$m, +$m[0];
 
# Trim off over specified rows if they exist., for efficiency
# if $rows >= +$m;cols {
# Not strictly necessary, but can save a lot of
# $m = trim_system($m);
# redundant calculations. [remove until debugged]
# if $rows >= +$cols {m;
# }
# $m = trim_system($m);
# $rows = +$m;
# }
 
for ^$rows -> $r {
Line 873 ⟶ 870:
for ^$vars -> $lead {
for ^$m -> $row {
@t.push(: | $m.splice( $row, 1 ) ) and last if $m[$row][$lead];
}
}
while (+@t < $vars) and +$m { @t.push(: $m.splice( 0, 1 ) ) };
return @t;
}
2,392

edits