note
tall_man
I see a couple of problems here. First, there seems to be confusion between the mxn matrix B (which you assigned to the variable <code>$matrix</code>) and the diagonal matrix in the decomposition (which you assigned to the variable <code>$b</code>).
<p>Secondly, the diagonal result in <code>$b</code> is returned in the form of a single row. It must be converted to a diagonal matrix before you can work on it.
<p>I would do something like this instead:
<code>
my $mt = transpose($matrix);
my $m2 = $mt x $matrix;
my $m2i = $m2->inv;
my $psuedo = $m2i x $mt;
</code>
<p>You will only need svd if the m2 matrix is singular or ill-conditioned. It will allow you to "fix" any near-zeros on the diagonal.
480466
480466