"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "t/matrixops.t" between
PDL-2.075.tar.gz and PDL-2.076.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

matrixops.t  (PDL-2.075):matrixops.t  (PDL-2.076)
skipping to change at line 299 skipping to change at line 299
my $this_svd_in = $svd_in->slice("0:2","0:1"); my $this_svd_in = $svd_in->slice("0:2","0:1");
my ($u,$s,$v) = svd($this_svd_in->transpose); my ($u,$s,$v) = svd($this_svd_in->transpose);
my $ess = zeroes($this_svd_in->dim(1),$this_svd_in->dim(1)); my $ess = zeroes($this_svd_in->dim(1),$this_svd_in->dim(1));
$ess->slice("$_","$_").=$s->slice("$_") foreach (0..$this_svd_in->dim(1)-1); #ge neric diagonal $ess->slice("$_","$_").=$s->slice("$_") foreach (0..$this_svd_in->dim(1)-1); #ge neric diagonal
ok(all(approx($this_svd_in, $v x $ess x $u->transpose,1e-8)), "svd 2x3"); ok(all(approx($this_svd_in, $v x $ess x $u->transpose,1e-8)), "svd 2x3");
} }
} }
{ {
my $pa = pdl [[ 1, 2, 3, 0],
[ 1, -1, 2, 7],
[ 1, 0, 0, 1]];
my $pb = pdl [[1, 1],
[0, 2],
[0, 2],
[1, 1]];
my $pc = pdl [[ 1, 11],
[ 8, 10],
[ 2, 2]];
my $res = $pa x $pb;
ok(all approx($pc,$res));
my $eq = float [[1,1,1,1]]; # a 4,1-matrix ( 1 1 1 1 )
# Check collapse: output should be a 1x2...
ok(all approx($eq x $pb , pdl([[2,6]]) )); # ([4x1] x [2x4] -> [1x2])
# Check dimensional exception: mismatched dims should throw an error
dies_ok {
my $pz = $pb x $eq; # [2x4] x [4x1] --> error (2 != 1)
};
{
# Check automatic scalar multiplication
my $pz;
lives_ok { $pz = $pb x 2; };
ok( all approx($pz,$pb * 2));
}
{
my $pz;
lives_ok { $pz = pdl(3) x $pb; };
ok( all approx($pz,$pb * 3));
}
}
{
# test inspired by Luis Mochan # test inspired by Luis Mochan
my $A = sequence(2, 2) + 1; my $A = sequence(2, 2) + 1;
my $A1 = $A->slice(',1:0'); # interchange two rows my $A1 = $A->slice(',1:0'); # interchange two rows
my $B = pdl(1,1); my $B = pdl(1,1);
my $x_expected = pdl([[-1, 1]]); my $x_expected = pdl([[-1, 1]]);
check_inplace($B, sub { lu_backsub($A->lu_decomp, $_[0]) }, $x_expected, "lu_bac ksub dims"); check_inplace($B, sub { lu_backsub($A->lu_decomp, $_[0]) }, $x_expected, "lu_bac ksub dims");
check_inplace($B, sub { lu_backsub($A1->lu_decomp, $_[0]) }, $x_expected, "lu_ba cksub dims 2"); check_inplace($B, sub { lu_backsub($A1->lu_decomp, $_[0]) }, $x_expected, "lu_ba cksub dims 2");
my $got = $A x $x_expected->transpose; my $got = $A x $x_expected->transpose;
ok(tapprox($got,$B->transpose,$tol), "A x actually == B") or diag "got: $got"; ok(tapprox($got,$B->transpose,$tol), "A x actually == B") or diag "got: $got";
} }
 End of changes. 1 change blocks. 
33 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)