perlquestion
Angharad
Hi Monks!
<br>
Further to a post I made a day or so ago regarding the pseudoinverse of a mxn matrix, I proceeded to create the following script .. attempting to implement the equation pseudoinvB = (B^tB)^-1B^t where B^t = transpose of non square matrix B.
<code>
#!/usr/bin/perl
use PDL;
my $matrix = pdl [
[4, 2, 9],
[2, 5, 5],
[6, 3, 5],
[8, 4, 6],
];
($a, $b, $c) = svd($matrix);
$bt = transpose($b);
$B1 = $bt*$b;
$B2 = $B1^-1;
$pseudoB = $B2*$bt;
</code>
Does this look OK to people or not?