"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Libtmp/Slatec/Gaussian.pm" between
PDL-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->thread(0)) /= $this->{EigVal}; ($foo = $tmp->broadcast(0)) /= $this->{EigVal};
} else { } else {
($foo = $tmp->thread(0)) *= $this->{EigVal}; ($foo = $tmp->broadcast(0)) *= $this->{EigVal};
} }
PDL::Primitive::inner($this->{EigVec}->thread(0,-1),$tmp->thread(-1,0), PDL::Primitive::inner($this->{EigVec}->broadcast(0,-1),$tmp->broadcast(-1
$this->{($inv?"ICV":"CV")}->thread(0,1)); ,0),
$this->{($inv?"ICV":"CV")}->broadcast(0,1));
} }
# 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}[0] * log (2*3.14); $this->{lnPrefactor} -= 0.5 * $this->{NDims}[0] * 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 = $this->{Mu}->thread(1..$#{$this->{NFuncs}}+1); my $arg11 = $this->{Mu}->broadcast(1..$#{$this->{NFuncs}}+1);
my $arg12 = $muxed->thread(1..$#{$this->{NFuncs}}+1); my $arg12 = $muxed->broadcast(1..$#{$this->{NFuncs}}+1);
# my_biop1($x,$this->{Mu}->thread(1..$#{$this->{NFuncs}}+1), # my_biop1($x,$this->{Mu}->broadcast(1..$#{$this->{NFuncs}}+1),
# $muxed->thread(1..$#{$this->{NFuncs}}+1),"-"); # $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->thread(1..$#{$this->{NFuncs}}+1)); my $arg1 = ($muxed->broadcast(1..$#{$this->{NFuncs}}+1));
print "TOINNER3\n"; print "TOINNER3\n";
my $arg2 = ($this->{ICV}->thread(2..$#{$this->{ICV}{Dims}})); my $arg2 = ($this->{ICV}->broadcast(2..$#{$this->{ICV}{Dims}}));
print "TOINNER4\n"; print "TOINNER4\n";
my $arg3 = ($p->thread(0..$#{$this->{NFuncs}})); my $arg3 = ($p->broadcast(0..$#{$this->{NFuncs}}));
print "TOINNER5\n"; print "TOINNER5\n";
# inner2(($muxed->thread(1..$#{$this->{NFuncs}}+1)) # inner2(($muxed->broadcast(1..$#{$this->{NFuncs}}+1))
# ,($this->{ICV}->thread(2..$#{$this->{ICV}{Dims}})), # ,($this->{ICV}->broadcast(2..$#{$this->{ICV}{Dims}})),
# ($muxed->thread(1..$#{$this->{NFuncs}}+1)) # ($muxed->broadcast(1..$#{$this->{NFuncs}}+1))
# ($p->thread(0..$#{$this->{NFuncs}}))); # ($p->broadcast(0..$#{$this->{NFuncs}})));
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;
inner2t($vec->transpose->thread(3..$#{$this->{NFuncs}}+3), inner2t($vec->transpose->broadcast(3..$#{$this->{NFuncs}}+3),
$this->{CV}->thread(2..$#{$this->{NFuncs}}+2), $this->{CV}->broadcast(2..$#{$this->{NFuncs}}+2),
$vec->thread(3..$#{$this->{NFuncs}}+3), $vec->broadcast(3..$#{$this->{NFuncs}}+3),
$tmp, $tmp,
$var->thread(3..$#{$this->{NFuncs}}+3)); $var->broadcast(3..$#{$this->{NFuncs}}+3));
} }
# (nvars,newndims,foo) => (newndims,@gdims,foo) # (nvars,newndims,foo) => (newndims,@gdims,foo)
# (nvars,@xdims)->thread) -> (@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(
$vec->thread(3..$#{$this->{NFuncs}}+3), $vec->broadcast(3..$#{$this->{NFuncs}}+3),
$this->{Mu}->thread(1..$#{$this->{Mu}{Dims}}), $this->{Mu}->broadcast(1..$#{$this->{Mu}{Dims}}),
$var->thread(2..$#{$this->{NFuncs}}+2)); $var->broadcast(2..$#{$this->{NFuncs}}+2));
} }
# 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,
$terms->thread(@cids), $terms->broadcast(@cids),
$this->{EigVec}, $this->{EigVec},
$tmp1, $tmp1,
$tmp2->thread(@cids) $tmp2->broadcast(@cids)
); );
$tmp2->flush(); $tmp2->flush();
# Now, pick the diagonal of $tmp2, threading over the unwanted dims.. # Now, pick the diagonal of $tmp2, broadcasting over the unwanted dims..
my $diag = $tmp2->thread(@cids)->diagonal(0); 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->unthread(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

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