Slices.pm (PDL-2.075) | : | Slices.pm (PDL-2.076) | ||
---|---|---|---|---|
skipping to change at line 870 | skipping to change at line 870 | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 953 "Slices.pm" | #line 953 "Slices.pm" | |||
#line 1060 "../../blib/lib/PDL/PP.pm" | #line 1060 "../../blib/lib/PDL/PP.pm" | |||
*xchg = \&PDL::xchg; | *xchg = \&PDL::xchg; | |||
#line 960 "Slices.pm" | #line 960 "Slices.pm" | |||
#line 1319 "slices.pd" | #line 1327 "slices.pd" | |||
=head2 reorder | =head2 reorder | |||
=for ref | =for ref | |||
Re-orders the dimensions of a PDL based on the supplied list. | Re-orders the dimensions of a PDL based on the supplied list. | |||
Similar to the L</xchg> method, this method re-orders the dimensions | Similar to the L</xchg> method, this method re-orders the dimensions | |||
of a PDL. While the L</xchg> method swaps the position of two dimensions, | of a PDL. While the L</xchg> method swaps the position of two dimensions, | |||
the reorder method can change the positions of many dimensions at | the reorder method can change the positions of many dimensions at | |||
skipping to change at line 1031 | skipping to change at line 1031 | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 1125 "Slices.pm" | #line 1125 "Slices.pm" | |||
#line 1060 "../../blib/lib/PDL/PP.pm" | #line 1060 "../../blib/lib/PDL/PP.pm" | |||
*mv = \&PDL::mv; | *mv = \&PDL::mv; | |||
#line 1132 "Slices.pm" | #line 1132 "Slices.pm" | |||
#line 1495 "slices.pd" | #line 1503 "slices.pd" | |||
=head2 using | =head2 using | |||
=for ref | =for ref | |||
Returns array of column numbers requested | Returns array of column numbers requested | |||
=for usage | =for usage | |||
line $pdl->using(1,2); | line $pdl->using(1,2); | |||
skipping to change at line 1196 | skipping to change at line 1196 | |||
#line 1058 "../../blib/lib/PDL/PP.pm" | #line 1058 "../../blib/lib/PDL/PP.pm" | |||
=head2 splitdim | =head2 splitdim | |||
=for sig | =for sig | |||
Signature: (P(); C(); PDL_Indx nthdim;PDL_Indx nsp) | Signature: (P(); C(); PDL_Indx nthdim;PDL_Indx nsp) | |||
=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). | |||
=for bad | =for bad | |||
splitdim does not process bad values. | splitdim does not process bad values. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 1346 "Slices.pm" | #line 1348 "Slices.pm" | |||
#line 1060 "../../blib/lib/PDL/PP.pm" | #line 1060 "../../blib/lib/PDL/PP.pm" | |||
*splitdim = \&PDL::splitdim; | *splitdim = \&PDL::splitdim; | |||
#line 1353 "Slices.pm" | #line 1355 "Slices.pm" | |||
#line 1058 "../../blib/lib/PDL/PP.pm" | #line 1058 "../../blib/lib/PDL/PP.pm" | |||
=head2 rotate | =head2 rotate | |||
=for sig | =for sig | |||
Signature: (x(n); indx shift(); [oca]y(n)) | Signature: (x(n); indx shift(); [oca]y(n)) | |||
=for ref | =for ref | |||
Shift vector elements along with wrap. Flows data back&forth. | Shift vector elements along with wrap. Flows data back&forth. | |||
=for bad | =for bad | |||
rotate does not process bad values. | rotate does not process bad values. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 1379 "Slices.pm" | #line 1381 "Slices.pm" | |||
#line 1060 "../../blib/lib/PDL/PP.pm" | #line 1060 "../../blib/lib/PDL/PP.pm" | |||
*rotate = \&PDL::rotate; | *rotate = \&PDL::rotate; | |||
#line 1386 "Slices.pm" | #line 1388 "Slices.pm" | |||
#line 1058 "../../blib/lib/PDL/PP.pm" | #line 1058 "../../blib/lib/PDL/PP.pm" | |||
=head2 broadcastI | =head2 broadcastI | |||
=for sig | =for sig | |||
Signature: (P(); C(); PDL_Indx id; PDL_Indx whichdims[]) | Signature: (P(); C(); PDL_Indx id; PDL_Indx whichdims[]) | |||
=for ref | =for ref | |||
skipping to change at line 1272 | skipping to change at line 1274 | |||
=for example | =for example | |||
$y = $x->broadcastI(0,1,5); # broadcast over dims 1,5 in id 1 | $y = $x->broadcastI(0,1,5); # broadcast over dims 1,5 in id 1 | |||
=for bad | =for bad | |||
broadcastI does not process bad values. | broadcastI does not process bad values. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 1419 "Slices.pm" | #line 1421 "Slices.pm" | |||
#line 1060 "../../blib/lib/PDL/PP.pm" | #line 1060 "../../blib/lib/PDL/PP.pm" | |||
*broadcastI = \&PDL::broadcastI; | *broadcastI = \&PDL::broadcastI; | |||
#line 1426 "Slices.pm" | #line 1428 "Slices.pm" | |||
#line 1058 "../../blib/lib/PDL/PP.pm" | #line 1058 "../../blib/lib/PDL/PP.pm" | |||
=head2 unbroadcast | =head2 unbroadcast | |||
=for sig | =for sig | |||
Signature: (P(); C(); int atind) | Signature: (P(); C(); int atind) | |||
=for ref | =for ref | |||
skipping to change at line 1299 | skipping to change at line 1301 | |||
All broadcasted dimensions are made real again. | All broadcasted dimensions are made real again. | |||
See [TBD Doc] for details and examples. | See [TBD Doc] for details and examples. | |||
=for bad | =for bad | |||
unbroadcast does not process bad values. | unbroadcast does not process bad values. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 1454 "Slices.pm" | #line 1456 "Slices.pm" | |||
#line 1060 "../../blib/lib/PDL/PP.pm" | #line 1060 "../../blib/lib/PDL/PP.pm" | |||
*unbroadcast = \&PDL::unbroadcast; | *unbroadcast = \&PDL::unbroadcast; | |||
#line 1461 "Slices.pm" | #line 1463 "Slices.pm" | |||
#line 1935 "slices.pd" | #line 1948 "slices.pd" | |||
=head2 dice | =head2 dice | |||
=for ref | =for ref | |||
Dice rows/columns/planes out of a PDL using indexes for | Dice rows/columns/planes out of a PDL using indexes for | |||
each dimension. | each dimension. | |||
This function can be used to extract irregular subsets | This function can be used to extract irregular subsets | |||
along many dimension of a PDL, e.g. only certain rows in an image, | along many dimension of a PDL, e.g. only certain rows in an image, | |||
skipping to change at line 1451 | skipping to change at line 1453 | |||
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; | |||
#line 1617 "Slices.pm" | #line 1619 "Slices.pm" | |||
#line 1058 "../../blib/lib/PDL/PP.pm" | #line 1058 "../../blib/lib/PDL/PP.pm" | |||
=head2 slice | =head2 slice | |||
=for sig | =for sig | |||
Signature: (P(); C(); pdl_slice_args *arglist) | Signature: (P(); C(); pdl_slice_args *arglist) | |||
=for usage | =for usage | |||
skipping to change at line 1627 | skipping to change at line 1629 | |||
$x->slice([1,3]); # Same as above three calls, but using array ref syntax | $x->slice([1,3]); # Same as above three calls, but using array ref syntax | |||
$x->slice([3,1]); | $x->slice([3,1]); | |||
$x->slice([-2,1]); | $x->slice([-2,1]); | |||
=for bad | =for bad | |||
slice does not process bad values. | slice does not process bad values. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 1795 "Slices.pm" | #line 1797 "Slices.pm" | |||
#line 1059 "../../blib/lib/PDL/PP.pm" | #line 1059 "../../blib/lib/PDL/PP.pm" | |||
sub PDL::slice { | sub PDL::slice { | |||
my ($source, @others) = @_; | my ($source, @others) = @_; | |||
for my $i(0..$#others) { | for my $i(0..$#others) { | |||
my $idx = $others[$i]; | my $idx = $others[$i]; | |||
if (ref $idx eq 'ARRAY') { | if (ref $idx eq 'ARRAY') { | |||
my @arr = map UNIVERSAL::isa($_, 'PDL') ? $_->flat->at(0) : $_, @{$other s[$i]}; | my @arr = map UNIVERSAL::isa($_, 'PDL') ? $_->flat->at(0) : $_, @{$other s[$i]}; | |||
$others[$i] = \@arr; | $others[$i] = \@arr; | |||
skipping to change at line 1667 | skipping to change at line 1669 | |||
$others[$i] = $idx->flat->at(0); | $others[$i] = $idx->flat->at(0); | |||
} | } | |||
else { | else { | |||
#### Zero elements -- force an extended empty. | #### Zero elements -- force an extended empty. | |||
$others[$i] = "1:0:1"; | $others[$i] = "1:0:1"; | |||
} | } | |||
} | } | |||
PDL::_slice_int($source,my $o=$source->initialize,\@others); | PDL::_slice_int($source,my $o=$source->initialize,\@others); | |||
$o; | $o; | |||
} | } | |||
#line 1837 "Slices.pm" | #line 1839 "Slices.pm" | |||
#line 1060 "../../blib/lib/PDL/PP.pm" | #line 1060 "../../blib/lib/PDL/PP.pm" | |||
*slice = \&PDL::slice; | *slice = \&PDL::slice; | |||
#line 1844 "Slices.pm" | #line 1846 "Slices.pm" | |||
#line 2426 "slices.pd" | #line 2439 "slices.pd" | |||
=head1 BUGS | =head1 BUGS | |||
For the moment, you can't slice one of the zero-length dims of an | For the moment, you can't slice one of the zero-length dims of an | |||
empty ndarray. It is not clear how to implement this in a way that makes | empty ndarray. It is not clear how to implement this in a way that makes | |||
sense. | sense. | |||
Many types of index errors are reported far from the indexing | Many types of index errors are reported far from the indexing | |||
operation that caused them. This is caused by the underlying architecture: | operation that caused them. This is caused by the underlying architecture: | |||
slice() sets up a mapping between variables, but that mapping isn't | slice() sets up a mapping between variables, but that mapping isn't | |||
skipping to change at line 1699 | skipping to change at line 1701 | |||
Copyright (C) 1997 Tuomas J. Lukka. Contributions by | Copyright (C) 1997 Tuomas J. Lukka. Contributions by | |||
Craig DeForest, deforest@boulder.swri.edu. | Craig DeForest, deforest@boulder.swri.edu. | |||
Documentation contributions by David Mertens. | Documentation contributions by David Mertens. | |||
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 | |||
#line 1876 "Slices.pm" | #line 1878 "Slices.pm" | |||
# Exit with OK status | # Exit with OK status | |||
1; | 1; | |||
End of changes. 20 change blocks. | ||||
21 lines changed or deleted | 23 lines changed or added |