## "Fossies" - the Fresh Open Source Software Archive ### Source code changes of the file "Libtmp/Slatec/Gaussian.pm" betweenPDL-2.074.tar.gz and PDL-2.075.tar.gz

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

Gaussian.pm  (PDL-2.074):Gaussian.pm  (PDL-2.075)
skipping to change at line 215 skipping to change at line 215
\$this->{EigVec} = \$tmpvec->double; \$this->{EigVec} = \$tmpvec->double;
} }
# This takes the eigenvalues and the eigenmatrix and makes the # This takes the eigenvalues and the eigenmatrix and makes the
# matrix we did not have # matrix we did not have
sub _otrans { sub _otrans {
my(\$this,\$inv) = @_; my(\$this,\$inv) = @_;
my \$tmp = PDL->null; my \$tmp = PDL->null;
\$tmp .= \$this->{EigVec}; my \$foo; \$tmp .= \$this->{EigVec}; my \$foo;
if(\$inv) { if(\$inv) {
(\$foo = \$tmp->(0)) /= \$this->{EigVal}; (\$foo = \$tmp->broadcast(0)) /= \$this->{EigVal};
} else { } else {
(\$foo = \$tmp->(0)) *= \$this->{EigVal}; (\$foo = \$tmp->broadcast(0)) *= \$this->{EigVal};
} }
,0),
} }
# Calculate prefactor. # Calculate prefactor.
sub _pref { sub _pref {
my(\$this) = @_; my(\$this) = @_;
print "IPREF\n"; print "IPREF\n";
my \$tmp = (log(\$this->{EigVal})); my \$tmp = (log(\$this->{EigVal}));
\$tmp->sumover(\$this->{lnPrefactor}); \$tmp->sumover(\$this->{lnPrefactor});
\$this->{lnPrefactor} *= -0.5; \$this->{lnPrefactor} *= -0.5;
\$this->{lnPrefactor} -= 0.5 * \$this->{NDims} * log (2*3.14); \$this->{lnPrefactor} -= 0.5 * \$this->{NDims} * log (2*3.14);
skipping to change at line 249 skipping to change at line 249
} }
# (nvars,foo) => (xdims,foo) # (nvars,foo) => (xdims,foo)
sub calc_lnvalue (\$\$\$) { sub calc_lnvalue (\$\$\$) {
my(\$this,\$xorig,\$p) = @_; my(\$this,\$xorig,\$p) = @_;
my \$x = \$xorig; my \$x = \$xorig;
my \$muxed = (PDL->zeroes(@{\$this->{NDims}},@{\$p->{Dims}}))->double; my \$muxed = (PDL->zeroes(@{\$this->{NDims}},@{\$p->{Dims}}))->double;
# print "MUXED1: \$muxed\n"; # print "MUXED1: \$muxed\n";
my \$arg11 = my \$arg11 = \$this->{Mu}->broadcast(1..\$#{\$this->{NFuncs}}+1);
my \$arg12 = my \$arg12 = \$muxed->broadcast(1..\$#{\$this->{NFuncs}}+1);
print "TOINNER1\n"; print "TOINNER1\n";
PDL::Ops::my_biop1(\$x, \$arg11, \$arg12, "-"); PDL::Ops::my_biop1(\$x, \$arg11, \$arg12, "-");
print "TOINNER2\n"; print "TOINNER2\n";
# print "MUXED: \$muxed\n"; # print "MUXED: \$muxed\n";
print "TOINNER2\n"; print "TOINNER2\n";
my \$arg1 = (\$muxed->(1..\$#{\$this->{NFuncs}}+1)); my \$arg1 = (\$muxed->broadcast(1..\$#{\$this->{NFuncs}}+1));
print "TOINNER3\n"; print "TOINNER3\n";
my \$arg2 = (\$this->{ICV}->(2..\$#{\$this->{ICV}{Dims}})); my \$arg2 = (\$this->{ICV}->broadcast(2..\$#{\$this->{ICV}{Dims}}));
print "TOINNER4\n"; print "TOINNER4\n";
my \$arg3 = (\$p->(0..\$#{\$this->{NFuncs}})); my \$arg3 = (\$p->broadcast(0..\$#{\$this->{NFuncs}}));
print "TOINNER5\n"; print "TOINNER5\n";
PDL::Primitive::inner2(\$arg1,\$arg2,\$arg1,\$arg3); PDL::Primitive::inner2(\$arg1,\$arg2,\$arg1,\$arg3);
print "FROMINNER2\n"; print "FROMINNER2\n";
\$p /= -2; \$p /= -2;
print "TON3\n"; print "TON3\n";
\$p += \$this->{lnPrefactor}; \$p += \$this->{lnPrefactor};
print "OUTON3\n"; print "OUTON3\n";
} }
# Again, (nvars,newndims,foo) => (newndims,newndims,@xdims,foo) # Again, (nvars,newndims,foo) => (newndims,newndims,@xdims,foo)
sub calc_lccovariance { sub calc_lccovariance {
my(\$this,\$vec,\$var) = @_; my(\$this,\$vec,\$var) = @_;
my \$tmp = PDL->null; my \$tmp = PDL->null;
\$tmp, \$tmp,
} }
# (nvars,newndims,foo) => (newndims,@gdims,foo) # (nvars,newndims,foo) => (newndims,@gdims,foo)
# (nvars,@xdims)->) -> (@gdims) # (nvars,@xdims)->broadcast) -> (@gdims)
sub calc_lcavg { sub calc_lcavg {
my(\$this,\$vec,\$var) = @_; my(\$this,\$vec,\$var) = @_;
# kill INT,\$\$; # kill INT,\$\$;
PDL::Primitive::inner( PDL::Primitive::inner(
} }
# Calculate the average of a second-degree term x^T M x # Calculate the average of a second-degree term x^T M x
# (nvars,nvars[,npolys]) => ([npolys],@gdims) # (nvars,nvars[,npolys]) => ([npolys],@gdims)
sub calc_qavg { sub calc_qavg {
my(\$this,\$terms,\$res) = @_; my(\$this,\$terms,\$res) = @_;
# The way to do this is to first transform the polynomial into # The way to do this is to first transform the polynomial into
# our coordinate system and then take the diagonal terms, # our coordinate system and then take the diagonal terms,
# which are then multiplied by the covariance eigenvalues. # which are then multiplied by the covariance eigenvalues.
my @cids = 2..\$#{\$terms->{Dims}}; my @cids = 2..\$#{\$terms->{Dims}};
my @cdims = @{\$terms->{Dims}}[2..\$#{\$terms->{Dims}}]; my @cdims = @{\$terms->{Dims}}[2..\$#{\$terms->{Dims}}];
my \$tmp1 = PDL->zeroes(@{\$this->{NDims}},@{\$this->{NDims}}); my \$tmp1 = PDL->zeroes(@{\$this->{NDims}},@{\$this->{NDims}});
my \$tmp2 = PDL->zeroes(@{\$this->{NDims}},@{\$this->{NDims}}, my \$tmp2 = PDL->zeroes(@{\$this->{NDims}},@{\$this->{NDims}},
@cdims, @{\$this->{NFuncs}}); @cdims, @{\$this->{NFuncs}});
PDL::Primitive::inner2t( PDL::Primitive::inner2t(
\$this->{EigVec}->transpose, \$this->{EigVec}->transpose,
\$this->{EigVec}, \$this->{EigVec},
\$tmp1, \$tmp1,
); );
\$tmp2->flush(); \$tmp2->flush();
# Now, pick the diagonal of \$tmp2, over the unwanted dims.. # Now, pick the diagonal of \$tmp2, broadcasting over the unwanted dims..
my \$diag = my \$diag = \$tmp2->broadcast(@cids)->diagonal(0);
# And multiply it by the covariance eigenvalues. # And multiply it by the covariance eigenvalues.
\$diag *= \$this->{EigVal}; \$diag *= \$this->{EigVal};
# Return the sum # Return the sum
\$diag = \$diag->un(1); \$diag = \$diag->unbroadcast(1);
\$diag->sumover(\$res); \$diag->sumover(\$res);
} }
# [(nvars,nvars[,npolys]), (nvars[,npolys])] => # [(nvars,nvars[,npolys]), (nvars[,npolys])] =>
# ([npolys,]@gdims) # ([npolys,]@gdims)
sub calc_poly2 { sub calc_poly2 {
my(\$this,\$coeffs,\$res) = @_; my(\$this,\$coeffs,\$res) = @_;
} }
# #
End of changes. 17 change blocks.
28 lines changed or deleted 29 lines changed or added