"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Basic/Slices/slices.pd" 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).

slices.pd  (PDL-2.075):slices.pd  (PDL-2.076)
skipping to change at line 1721 skipping to change at line 1721
); );
=head2 splitdim =head2 splitdim
=cut =cut
pp_def( pp_def(
'splitdim', 'splitdim',
Doc => <<'EOD', Doc => <<'EOD',
=for ref =for ref
Splits a dimension in the parent ndarray (opposite of L<clump|PDL::Core/clump>) Splits a dimension in the parent ndarray (opposite of L<clump|PDL::Core/clump>).
As of 2.076, throws exception if non-divisible C<nsp> given, and can
After give negative C<nthdim> which then counts backwards.
=for example =for example
After
$y = $x->splitdim(2,3); $y = $x->splitdim(2,3);
the expression the expression
$y->at(6,4,m,n,3,6) == $x->at(6,4,m+3*n) $y->at(6,4,m,n,3,6) == $x->at(6,4,m+3*n)
is always true (C<m> has to be less than 3). is always true (C<m> has to be less than 3).
=cut =cut
EOD EOD
P2Child => 1, P2Child => 1,
TwoWay => 1, TwoWay => 1,
OtherPars => join('', map "PDL_Indx $_;", qw(nthdim nsp)), OtherPars => join('', map "PDL_Indx $_;", qw(nthdim nsp)),
AffinePriv => 1, AffinePriv => 1,
RedoDims => ' RedoDims => '
PDL_Indx i = $COMP(nthdim); PDL_Indx i = $COMP(nthdim);
PDL_Indx nsp = $COMP(nsp); PDL_Indx nsp = $COMP(nsp);
if(nsp == 0) {$CROAK("Cannot split to 0\n");} if(nsp == 0) {$CROAK("Cannot split to 0\n");}
if(i <0 || i >= $PARENT(ndims)) { if (i < 0)
$CROAK("nthdim %"IND_FLAG" must not be negative or great i = $COMP(nthdim) += $PARENT(ndims);
er or equal to number of dims %"IND_FLAG"\n", if (i < 0 || i >= $PARENT(ndims))
$CROAK("nthdim %"IND_FLAG" after adjusting for negative
must not be negative or greater or equal to number of dims %"IND_FLAG"\n",
i, $PARENT(ndims)); i, $PARENT(ndims));
} if (nsp > $PARENT(dims[i]))
if(nsp > $PARENT(dims[i])) {
$CROAK("nsp %"IND_FLAG" cannot be greater than dim %"IND _FLAG"\n", $CROAK("nsp %"IND_FLAG" cannot be greater than dim %"IND _FLAG"\n",
nsp, $PARENT(dims[i])); nsp, $PARENT(dims[i]));
} if (($PARENT(dims)[i] % nsp) != 0)
$CROAK("nsp %"IND_FLAG" non-divisible into dim %"IND_FLA
G"\n",
nsp, $PARENT(dims[i]));
$PRIV(offs) = 0; $PRIV(offs) = 0;
$SETNDIMS($PARENT(ndims)+1); $SETNDIMS($PARENT(ndims)+1);
$DOPRIVALLOC(); $DOPRIVALLOC();
for(i=0; i<$COMP(nthdim); i++) { for(i=0; i<$COMP(nthdim); i++) {
$CHILD(dims)[i] = $PARENT(dims)[i]; $CHILD(dims)[i] = $PARENT(dims)[i];
$PRIV(incs)[i] = $PARENT(dimincs)[i]; $PRIV(incs)[i] = $PARENT(dimincs)[i];
} }
$CHILD(dims)[i] = $COMP(nsp); $CHILD(dims)[i] = $COMP(nsp);
$CHILD(dims)[i+1] = $PARENT(dims)[i] / $COMP(nsp); $CHILD(dims)[i+1] = $PARENT(dims)[i] / $COMP(nsp);
$PRIV(incs)[i] = $PARENT(dimincs)[i]; $PRIV(incs)[i] = $PARENT(dimincs)[i];
skipping to change at line 2076 skipping to change at line 2081
have a 2D image C<axis=0> will select certain C<X> values have a 2D image C<axis=0> will select certain C<X> values
- i.e. extract columns - i.e. extract columns
As this is an index function, any modifications to the As this is an index function, any modifications to the
slice will change the parent. slice will change the parent.
=cut =cut
sub PDL::dice_axis { sub PDL::dice_axis {
my($self,$axis,$idx) = @_; my($self,$axis,$idx) = @_;
my $ix = ref($self)->topdl($idx); my $ix = PDL->topdl($idx);
barf("dice_axis: index must be <=1D") if $ix->getndims > 1; barf("dice_axis: index must be <=1D") if $ix->getndims > 1;
return $self->mv($axis,0)->index1d($ix)->mv(0,$axis); return $self->mv($axis,0)->index1d($ix)->mv(0,$axis);
} }
*dice_axis = \&PDL::dice_axis; *dice_axis = \&PDL::dice_axis;
EOD EOD
############################## ##############################
# 'slice' is now implemented as a small Perl wrapper around # 'slice' is now implemented as a small Perl wrapper around
# a PP call. This permits unification of the former slice, # a PP call. This permits unification of the former slice,
# and dice into a single call. At the moment, dicing # and dice into a single call. At the moment, dicing
 End of changes. 6 change blocks. 
10 lines changed or deleted 16 lines changed or added

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