## "Fossies" - the Fresh Open Source Software Archive ### Source code changes of the file "Graphics/TriD/Rout/rout.pd" betweenPDL-2.077.tar.gz and PDL-2.078.tar.gz

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

rout.pd  (PDL-2.077):rout.pd  (PDL-2.078)
skipping to change at line 37 skipping to change at line 37
\$coords(tri => 1) = \$y(); \$coords(tri => 1) = \$y();
\$coords(tri => 2) = \$z(); \$coords(tri => 2) = \$z();
', ',
Doc => <<EOT Doc => <<EOT
=for ref =for ref
Combine three coordinates into a single ndarray. Combine three coordinates into a single ndarray.
Combine x, y and z to a single ndarray the first dimension Combine x, y and z to a single ndarray the first dimension
of which is 3. This routine does dataflow automatically. of which is 3. This routine does dataflow automatically.
EOT EOT
); );
# checks all neighbouring boxes. # checks all neighbouring boxes.
# Returns (r = |dist|+d) a*r^-2 + b*r^-1 + c*r^-0.5 # Returns (r = |dist|+d) a*r^-2 + b*r^-1 + c*r^-0.5
pp_def( pp_def(
'repulse', 'repulse',
GenericTypes => ['F','D'], GenericTypes => ['F','D'],
Pars => 'coords(nc,np); Pars => 'coords(nc,np);
skipping to change at line 65 skipping to change at line 62
double a; double a;
double b; double b;
double c; double c;
double d; double d;
', ',
Code => ' Code => '
double a = \$COMP(a); double a = \$COMP(a);
double b = \$COMP(b); double b = \$COMP(b);
double c = \$COMP(c); double c = \$COMP(c);
double d = \$COMP(d); double d = \$COMP(d);
int ind; int x,y,z; int ind; int x,y,z;
HV *hv = newHV(); HV *hv = newHV();
double boxsize = \$COMP(boxsize); double boxsize = \$COMP(boxsize);
int dmult = \$COMP(dmult); int dmult = \$COMP(dmult);
loop(np) %{ loop(np) %{
int index = 0; int index = 0;
loop(nc) %{ loop(nc) %{
\$vecs() = 0; \$vecs() = 0;
index *= dmult; index *= dmult;
index += (int)(\$coords()/boxsize); index += (int)(\$coords()/boxsize);
%} %}
/* Repulse old (shame to use x,y,z...) */ /* Repulse old (shame to use x,y,z...) */
for(x=-1; x<=1; x++) { for(x=-1; x<=1; x++) {
for(y=-1; y<=1; y++) { for(y=-1; y<=1; y++) {
for(z=-1; z<=1; z++) { for(z=-1; z<=1; z++) {
int ni = index + x + dmult * y + int ni = index + x + dmult * y +
dmult * dmult * z; dmult * dmult * z;
svp = hv_fetch(hv, (char *)&ni, sizeof(int), SV **svp = hv_fetch(hv, (char *)&ni, sizeof(int),
0); 0);
if(svp && *svp) { if(svp && *svp) {
ind = SvIV(*svp) - 1; ind = SvIV(*svp) - 1;
while(ind>=0) { while(ind>=0) {
double dist = 0; double dist = 0;
double dist2; double dist2;
double tmp; double tmp;
double func; double func;
loop(nc) %{ loop(nc) %{
tmp = tmp =
skipping to change at line 121 skipping to change at line 117
\$vecs(np => ind) += \$vecs(np => ind) +=
func * tmp; func * tmp;
%} %}
} }
} }
} }
} }
} }
/* Store new */ /* Store new */
= hv_fetch(hv, (char *)&index, SV **svp = hv_fetch(hv, (char *)&index, sizeof(index), 1)
;
sv from hvfetch"); if(!svp || !*svp)
\$CROAK("Invalid sv from hvfetch");
= *svp; SV *sv = *svp;
= SvIV(sv))) { int npv;
if(SvOK(sv) && (npv = SvIV(sv))) {
npv --; npv --;
} else { } else {
sv_setiv(sv,np+1); sv_setiv(sv,np+1);
} }
%} %}
hv_undef(hv); hv_undef(hv);
', Doc => ' ', Doc => '
=for ref =for ref
Repulsive potential for molecule-like constructs. Repulsive potential for molecule-like constructs.
C<repulse> uses a hash table of cubes to quickly calculate C<repulse> uses a hash table of cubes to quickly calculate
a repulsive force that vanishes at infinity for many a repulsive force that vanishes at infinity for many
objects. For use by the module L<PDL::Graphics::TriD::MathGraph>. objects. For use by the module L<PDL::Graphics::TriD::MathGraph>.
For definition of the potential, see the actual function. For definition of the potential, see the actual function.
' '
); );
pp_def( pp_def(
'attract', 'attract',
GenericTypes => ['F','D'], GenericTypes => ['F','D'],
Pars => 'coords(nc,np); Pars => 'coords(nc,np);
int from(nl); int from(nl);
int to(nl); int to(nl);
strength(nl); strength(nl);
skipping to change at line 197 skipping to change at line 190
=for ref =for ref
Attractive potential for molecule-like constructs. Attractive potential for molecule-like constructs.
C<attract> is used to calculate C<attract> is used to calculate
an attractive force for many an attractive force for many
objects, of which some attract each other (in a way objects, of which some attract each other (in a way
like molecular bonds). like molecular bonds).
For use by the module L<PDL::Graphics::TriD::MathGraph>. For use by the module L<PDL::Graphics::TriD::MathGraph>.
For definition of the potential, see the actual function. For definition of the potential, see the actual function.
' '
); );
sub trid { sub trid {
my (\$par,\$ind) = @_; my (\$par,\$ind) = @_;
join ',', map {"\\$\$par(\$ind => \$_)"} (0..2); join ',', map {"\\$\$par(\$ind => \$_)"} (0..2);
} }
pp_def('vrmlcoordsvert', pp_def('vrmlcoordsvert',
Pars => 'vertices(n=3)', Pars => 'vertices(n=3)',
skipping to change at line 263 skipping to change at line 253
right y-segment and finally across to the next x-segment. Once we find one in a right y-segment and finally across to the next x-segment. Once we find one in a
box (two on a point) we can quit because there can only be one. After we are do ne box (two on a point) we can quit because there can only be one. After we are do ne
with a given x-segment, we look to the leftover possibilities for the adjoining y-segment. with a given x-segment, we look to the leftover possibilities for the adjoining y-segment.
Thus the contours are built as a collection of line segments rather than a set o f closed Thus the contours are built as a collection of line segments rather than a set o f closed
polygons. polygons.
=back =back
=cut =cut
sub PDL::Graphics::TriD::Contours::contour_segments { sub PDL::Graphics::TriD::Contours::contour_segments {
my(\$this,\$c,\$data,\$points) = @_; my(\$this,\$c,\$data,\$points) = @_;
# pre compute space for output of pp routine # pre compute space for output of pp routine
my \$segdim = (\$data->getdim(0)-1)*(\$data->getdim(1)-1)*4; my \$segdim = (\$data->getdim(0)-1)*(\$data->getdim(1)-1)*4;
my \$segs = zeroes(3,\$segdim,\$c->nelem); my \$segs = zeroes(3,\$segdim,\$c->nelem);
my \$cnt = zeroes(\$c->nelem); my \$cnt = zeroes(\$c->nelem);
contour_segments_internal(\$c,\$data,\$points,\$segs,\$cnt); contour_segments_internal(\$c,\$data,\$points,\$segs,\$cnt);
\$this->{Points} = pdl->null; \$this->{Points} = pdl->null;
my \$pcnt=0; my \$pcnt=0;
my \$ncnt; my \$ncnt;
for(my \$i=0; \$i<\$c->nelem; \$i++){ for(my \$i=0; \$i<\$c->nelem; \$i++){
\$ncnt = \$cnt->slice("(\$i)"); \$ncnt = \$cnt->slice("(\$i)");
next if(\$ncnt==-1); next if(\$ncnt==-1);
\$pcnt = \$pcnt+\$ncnt; \$pcnt = \$pcnt+\$ncnt;
\$this->{ContourSegCnt}[\$i] = \$pcnt; \$this->{ContourSegCnt}[\$i] = \$pcnt;
\$pcnt=\$pcnt+1; \$pcnt=\$pcnt+1;
\$this->{Points} = \$this->{Points}->append(\$segs->slice(":,0:\$ncnt ,(\$i)")->transpose); \$this->{Points} = \$this->{Points}->append(\$segs->slice(":,0:\$ncnt ,(\$i)")->transpose);
} }
\$this->{Points} = \$this->{Points}->transpose; \$this->{Points} = \$this->{Points}->transpose;
} }
EOD EOD
pp_def('contour_segments_internal', pp_def('contour_segments_internal',
skipping to change at line 313 skipping to change at line 294
int ds, ms, ns; int ds, ms, ns;
float dist; float dist;
float a_int; float a_int;
int i, j, m1, n1, mr, ml, p, found, p1, a; int i, j, m1, n1, mr, ml, p, found, p1, a;
ds = \$SIZE(d); ds = \$SIZE(d);
ms = \$SIZE(m); ms = \$SIZE(m);
ns = \$SIZE(n); ns = \$SIZE(n);
if(ds != 3){ if(ds != 3){
} }
p=0; p=0;
p1=1; p1=1;
loop(m) %{ loop(m) %{
if(m<ms-1){ if(m<ms-1){
m1=m+1; m1=m+1;
loop(n)%{ loop(n)%{
if(n<ns-1){ if(n<ns-1){
n1=n+1; n1=n+1;
skipping to change at line 452 skipping to change at line 433
} }
} }
} /* n<ns-1 */ } /* n<ns-1 */
%} %}
} }
%} %}
/*printf("p= %d \n",p); */ /*printf("p= %d \n",p); */
\$cnt()=p-1;' \$cnt()=p-1;'
, ,
Doc => undef, Doc => undef,
); );