Angharad has asked for the wisdom of the Perl Monks concerning the following question:
Most of this works just fine, but not this line#!/usr/bin/perl use PDL; my $a = pdl [ [ 0.6490, 0.0330, 0.1670, 0.3700], [ 0.1150, 0.0290, 0.0480, 0.0650], [ 0.0070, 0.3570, 0.3870, 0.2010], [ 0.0630, 0.0760, 0.0540, 0.0560], [ 0, 0.0400, 0.0160, 0.0160], [ 0.0120, 0.0620, 0.0430, 0.0380], [ 0.1530, 0.4020, 0.2850, 0.2550], ]; ($U, $S, $V) = svd($a); # create square matrix for 'S' @valuesS = list $S; $SqS = pdl [ [ $valuesS[0], 0, 0, 0], [ 0, $valuesS[1], 0, 0], [ 0, 0, $valuesS[2], 0], [ 0, 0, 0, $valuesS[3]], ]; # transpose V $Vt = $V->transpose(); $Us = $U->slice('0:1,0:6'); $Ss = $SqS->slice('0:1,0:1'); $Vs = $Vt->slice('0:3,0:1'); print "$Us\n"; print "$Ss\n"; print "$Vs\n"; $recA = $Us * $Ss * $Vs; print "$recA\n";
Where I get the following error$recA = $Us * $Ss * $Vs;
Any suggestions as to a work around appreciated folks :)recA = U(:,1:ns)*S(1:ns,1:ns)*Vt(1:ns,:)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Arrgghh! Perl and Matlab (round 2)
by ambrus (Abbot) on Aug 12, 2005 at 16:36 UTC | |
|
Re: Arrgghh! Perl and Matlab (round 2)
by tall_man (Parson) on Aug 12, 2005 at 23:00 UTC | |
by ambrus (Abbot) on Aug 13, 2005 at 13:31 UTC | |
|
Re: Arrgghh! Perl and Matlab (round 2)
by Angharad (Pilgrim) on Aug 15, 2005 at 09:51 UTC |