"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Graphics/TriD/Rout/rout.pd" between
PDL-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.
=cut
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; SV **svp; SV *sv; int ind; int x,y,z;
int npv;
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;
$links() = -1; $links() = -1;
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;
%} %}
ind = $links(np => ind); ind = $links(np => ind);
} }
} }
} }
} }
} }
/* Store new */ /* Store new */
svp = hv_fetch(hv, (char *)&index, sizeof(int), 1); SV **svp = hv_fetch(hv, (char *)&index, sizeof(index), 1)
if(svp == NULL) { ;
die("Invalid sv from hvfetch"); if(!svp || !*svp)
} $CROAK("Invalid sv from hvfetch");
sv = *svp; SV *sv = *svp;
if((npv = SvIV(sv))) { int npv;
if(SvOK(sv) && (npv = SvIV(sv))) {
npv --; npv --;
$links() = $links(np => npv); $links() = $links(np => npv);
$links(np => npv) = np; $links(np => npv) = np;
} else { } else {
sv_setiv(sv,np+1); sv_setiv(sv,np+1);
$links() = -1; $links() = -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.
=cut
' '
); );
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.
=cut
' '
); );
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
use strict;
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;
# print "segdim = $segdim\n";
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);
# print "contour segments done ",$points->info,"\n";
$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[3]; float a_int[3];
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){
croak("Bad first dimension in contour_segments"); $CROAK("Bad first dimension in contour_segments");
} }
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,
#'
#=for ref
#
#Internal support for contour_segments above.
#
#=cut
#'
); );
pp_addpm({At=>'Bot'},<<'EOD'); pp_addpm({At=>'Bot'},<<'EOD');
=head1 AUTHOR =head1 AUTHOR
Copyright (C) 2000 James P. Edwards Copyright (C) 2000 James P. Edwards
Copyright (C) 1997 Tuomas J. Lukka. Copyright (C) 1997 Tuomas J. Lukka.
All rights reserved. There is no warranty. You are allowed All rights reserved. There is no warranty. You are allowed
to redistribute this software / documentation under certain to redistribute this software / documentation under certain
conditions. For details, see the file COPYING in the PDL conditions. For details, see the file COPYING in the PDL
distribution. If this file is separated from the PDL distribution, distribution. If this file is separated from the PDL distribution,
the copyright notice should be included in the file. the copyright notice should be included in the file.
=cut =cut
EOD EOD
pp_done(); pp_done();
 End of changes. 16 change blocks. 
37 lines changed or deleted 10 lines changed or added

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