http://www.perlmonks.org?node_id=483450


in reply to Arrgghh! Perl and Matlab (round 2)

There's an easier way to create your $Sqs matrix. I tried this with your example and the suggestion by ambrus about matrix multiplication, and it worked.
$Sqs = zeroes($V); $Sqs->diagonal(0,1) .= $S;

Replies are listed 'Best First'.
Re^2: Arrgghh! Perl and Matlab (round 2)
by ambrus (Abbot) on Aug 13, 2005 at 13:31 UTC

    There's an even easier way:

    $Sqs = stretcher($S);
    see PDL::MatrixOps.