"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "GENERATED/PDL/Slices.pm" between
PDL-2.079.tar.gz and PDL-2.080.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.pm  (PDL-2.079):Slices.pm  (PDL-2.080)
# #
# GENERATED WITH PDL::PP! Don't modify! # GENERATED WITH PDL::PP! Don't modify!
# #
package PDL::Slices; package PDL::Slices;
our @EXPORT_OK = qw(index index1d index2d indexND indexNDb rangeb rld rle _clump _int xchg mv using diagonal lags splitdim rotate broadcastI unbroadcast dice dic e_axis slice ); our @EXPORT_OK = qw(index index1d index2d indexND indexNDb rangeb rld rle rlevec rldvec rleseq rldseq rleND rldND _clump_int xchg mv using diagonal lags splitdi m rotate broadcastI unbroadcast dice dice_axis slice );
our %EXPORT_TAGS = (Func=>\@EXPORT_OK); our %EXPORT_TAGS = (Func=>\@EXPORT_OK);
use PDL::Core; use PDL::Core;
use PDL::Exporter; use PDL::Exporter;
use DynaLoader; use DynaLoader;
our @ISA = ( 'PDL::Exporter','DynaLoader' ); our @ISA = ( 'PDL::Exporter','DynaLoader' );
push @PDL::Core::PP, __PACKAGE__; push @PDL::Core::PP, __PACKAGE__;
bootstrap PDL::Slices ; bootstrap PDL::Slices ;
skipping to change at line 87 skipping to change at line 87
use strict; use strict;
use warnings; use warnings;
use PDL::Core ':Internal'; use PDL::Core ':Internal';
use Scalar::Util 'blessed'; use Scalar::Util 'blessed';
#line 91 "Slices.pm" #line 91 "Slices.pm"
=head1 FUNCTIONS =head1 FUNCTIONS
=cut =cut
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../blib/lib/PDL/PP.pm"
=head2 index =head2 index
=for sig =for sig
Signature: (a(n); indx ind(); [oca] c()) Signature: (a(n); indx ind(); [oca] c())
=for ref =for ref
C<index>, C<index1d>, and C<index2d> provide rudimentary index indirection. C<index>, C<index1d>, and C<index2d> provide rudimentary index indirection.
skipping to change at line 164 skipping to change at line 164
columns from an array in one operation, see L</dice> or columns from an array in one operation, see L</dice> or
L</indexND>. L</indexND>.
=for bad =for bad
index barfs if any of the index values are bad. index barfs if any of the index values are bad.
=cut =cut
#line 184 "Slices.pm" #line 184 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*index = \&PDL::index; *index = \&PDL::index;
#line 191 "Slices.pm" #line 191 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../blib/lib/PDL/PP.pm"
=head2 index1d =head2 index1d
=for sig =for sig
Signature: (a(n); indx ind(m); [oca] c(m)) Signature: (a(n); indx ind(m); [oca] c(m))
=for ref =for ref
C<index>, C<index1d>, and C<index2d> provide rudimentary index indirection. C<index>, C<index1d>, and C<index2d> provide rudimentary index indirection.
skipping to change at line 246 skipping to change at line 246
columns from an array in one operation, see L</dice> or columns from an array in one operation, see L</dice> or
L</indexND>. L</indexND>.
=for bad =for bad
index1d propagates BAD index elements to the output variable. index1d propagates BAD index elements to the output variable.
=cut =cut
#line 274 "Slices.pm" #line 274 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*index1d = \&PDL::index1d; *index1d = \&PDL::index1d;
#line 281 "Slices.pm" #line 281 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../blib/lib/PDL/PP.pm"
=head2 index2d =head2 index2d
=for sig =for sig
Signature: (a(na,nb); indx inda(); indx indb(); [oca] c()) Signature: (a(na,nb); indx inda(); indx indb(); [oca] c())
=for ref =for ref
C<index>, C<index1d>, and C<index2d> provide rudimentary index indirection. C<index>, C<index1d>, and C<index2d> provide rudimentary index indirection.
skipping to change at line 328 skipping to change at line 328
columns from an array in one operation, see L</dice> or columns from an array in one operation, see L</dice> or
L</indexND>. L</indexND>.
=for bad =for bad
index2d barfs if either of the index values are bad. index2d barfs if either of the index values are bad.
=cut =cut
#line 364 "Slices.pm" #line 364 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*index2d = \&PDL::index2d; *index2d = \&PDL::index2d;
#line 371 "Slices.pm" #line 371 "Slices.pm"
#line 245 "slices.pd" #line 241 "slices.pd"
=head2 indexNDb =head2 indexNDb
=for ref =for ref
Backwards-compatibility alias for indexND Backwards-compatibility alias for indexND
=head2 indexND =head2 indexND
=for ref =for ref
skipping to change at line 385 skipping to change at line 385
=cut =cut
sub PDL::indexND { sub PDL::indexND {
my($source,$index, $boundary) = @_; my($source,$index, $boundary) = @_;
return PDL::range($source,$index,undef,$boundary); return PDL::range($source,$index,undef,$boundary);
} }
*PDL::indexNDb = \&PDL::indexND; *PDL::indexNDb = \&PDL::indexND;
#line 425 "Slices.pm" #line 425 "Slices.pm"
#line 297 "slices.pd" #line 293 "slices.pd"
sub PDL::range { sub PDL::range {
my($source,$ind,$sz,$bound) = @_; my($source,$ind,$sz,$bound) = @_;
# Convert to indx type up front (also handled in rangeb if necessary) # Convert to indx type up front (also handled in rangeb if necessary)
my $index = (ref $ind && UNIVERSAL::isa($ind,'PDL') && $ind->type eq 'indx') ? $ind : indx($ind); my $index = (ref $ind && UNIVERSAL::isa($ind,'PDL') && $ind->type eq 'indx') ? $ind : indx($ind);
my $size = defined($sz) ? PDL->pdl($sz) : undef; my $size = defined($sz) ? PDL->pdl($sz) : undef;
# Handle empty PDL case: return a properly constructed Empty. # Handle empty PDL case: return a properly constructed Empty.
if($index->isempty) { if($index->isempty) {
skipping to change at line 425 skipping to change at line 425
elsif($bound !~ m/^[0123ftepx]+$/ && $bound =~ m/^([0123ftepx])/i ) { elsif($bound !~ m/^[0123ftepx]+$/ && $bound =~ m/^([0123ftepx])/i ) {
$bound = $1; $bound = $1;
} }
} }
no warnings; # shut up about passing undef into rangeb no warnings; # shut up about passing undef into rangeb
$source->rangeb($index,$size,$bound); $source->rangeb($index,$size,$bound);
} }
#line 471 "Slices.pm" #line 471 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../blib/lib/PDL/PP.pm"
=head2 rangeb =head2 rangeb
=for sig =for sig
Signature: (P(); C(); pdl *ind_pdl; SV *size; SV *boundary_sv) Signature: (P(); C(); pdl *ind_pdl; SV *size; SV *boundary_sv)
=for ref =for ref
Engine for L</range> Engine for L</range>
skipping to change at line 691 skipping to change at line 691
C<range> is a perl front-end to a PP function, C<rangeb>. Calling C<range> is a perl front-end to a PP function, C<rangeb>. Calling
C<rangeb> is marginally faster but requires that you include all arguments. C<rangeb> is marginally faster but requires that you include all arguments.
DEVEL NOTES DEVEL NOTES
* index broadcast dimensions are effectively clumped internally. This * index broadcast dimensions are effectively clumped internally. This
makes it easier to loop over the index array but a little more brain-bending makes it easier to loop over the index array but a little more brain-bending
to tease out the algorithm. to tease out the algorithm.
=cut
=for bad =for bad
rangeb processes bad values. rangeb processes 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 754 "Slices.pm" #line 752 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*rangeb = \&PDL::rangeb; *rangeb = \&PDL::rangeb;
#line 761 "Slices.pm" #line 759 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../blib/lib/PDL/PP.pm"
=head2 rld =head2 rld
=for sig =for sig
Signature: (indx a(n); b(n); [o]c(m)) Signature: (indx a(n); b(n); [o]c(m))
=for ref =for ref
Run-length decode a vector Run-length decode a vector
skipping to change at line 731 skipping to change at line 729
=for example =for example
rld($x,$y,$c=null); rld($x,$y,$c=null);
=for bad =for bad
rld does not process bad values. rld 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 795 "Slices.pm" #line 793 "Slices.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 949 "../../blib/lib/PDL/PP.pm"
sub PDL::rld { sub PDL::rld {
my ($x,$y) = @_; my ($x,$y) = @_;
my ($c); my ($c);
if ($#_ == 2) { if ($#_ == 2) {
$c = $_[2]; $c = $_[2];
} else { } else {
# XXX Need to improve emulation of broadcasting in auto-generating c # XXX Need to improve emulation of broadcasting in auto-generating c
my ($size) = $x->sumover->max->sclr; my ($size) = $x->sumover->max->sclr;
my (@dims) = $x->dims; my (@dims) = $x->dims;
shift @dims; shift @dims;
$c = $y->zeroes($size,@dims); $c = $y->zeroes($size,@dims);
} }
&PDL::_rld_int($x,$y,$c); &PDL::_rld_int($x,$y,$c);
$c; $c;
} }
#line 816 "Slices.pm" #line 814 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*rld = \&PDL::rld; *rld = \&PDL::rld;
#line 823 "Slices.pm" #line 821 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../blib/lib/PDL/PP.pm"
=head2 rle =head2 rle
=for sig =for sig
Signature: (c(n); indx [o]a(m); [o]b(m)) Signature: (c(n); indx [o]a(m); [o]b(m))
=for ref =for ref
Run-length encode a vector Run-length encode a vector
skipping to change at line 808 skipping to change at line 806
$y = $x->cumusumover; $y = $x->cumusumover;
$yprob1x = $y->slice('-1:0')->double / $y->slice('(-1)'); $yprob1x = $y->slice('-1:0')->double / $y->slice('(-1)');
$z = cat($x1, 1 / $yprob1x**$nrolls)->transpose; $z = cat($x1, 1 / $yprob1x**$nrolls)->transpose;
=for bad =for bad
rle does not process bad values. rle 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 883 "Slices.pm" #line 881 "Slices.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 949 "../../blib/lib/PDL/PP.pm"
sub PDL::rle { sub PDL::rle {
my $c = shift; my $c = shift;
my ($x,$y) = @_==2 ? @_ : (null,null); my ($x,$y) = @_==2 ? @_ : (null,null);
PDL::_rle_int($c,$x,$y); PDL::_rle_int($c,$x,$y);
my $max_ind = ($c->ndims<2) ? ($x!=0)->sumover-1 : my $max_ind = ($c->ndims<2) ? ($x!=0)->sumover-1 :
($x!=0)->clump(1..$x->ndims-1)->sumover->max->sc lr-1; ($x!=0)->clump(1..$x->ndims-1)->sumover->max->sc lr-1;
return ($x->slice("0:$max_ind"),$y->slice("0:$max_ind")); return ($x->slice("0:$max_ind"),$y->slice("0:$max_ind"));
} }
#line 897 "Slices.pm" #line 895 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*rle = \&PDL::rle; *rle = \&PDL::rle;
#line 904 "Slices.pm" #line 902 "Slices.pm"
#line 948 "../../blib/lib/PDL/PP.pm"
=head2 rlevec
=for sig
Signature: (c(M,N); indx [o]a(N); [o]b(M,N))
=for ref
Run-length encode a set of vectors.
Higher-order rle(), for use with qsortvec().
Given set of vectors $c, generate a vector $a with the number of occurrences of
each element
(where an "element" is a vector of length $M ocurring in $c),
and a set of vectors $b containing the unique values.
As for rle(), only the elements up to the first instance of 0 in $a should be co
nsidered.
Can be used together with clump() to run-length encode "values" of arbitrary dim
ensions.
Can be used together with rotate(), cat(), append(), and qsortvec() to count N-g
rams
over a 1d PDL.
See also: L</rle>, L<PDL::Ufunc/qsortvec>, L<PDL::Primitive/uniqvec>
Contributed by Bryan Jurish E<lt>moocow@cpan.orgE<gt>.
=for bad
rlevec 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.
=cut
#line 943 "Slices.pm"
#line 950 "../../blib/lib/PDL/PP.pm"
*rlevec = \&PDL::rlevec;
#line 950 "Slices.pm"
#line 948 "../../blib/lib/PDL/PP.pm"
=head2 rldvec
=for sig
Signature: (indx a(N); b(M,N); [o]c(M,N))
=for ref
Run-length decode a set of vectors, akin to a higher-order rld().
Given a vector $a() of the number of occurrences of each row, and a set $c()
of row-vectors each of length $M, run-length decode to $c().
Can be used together with clump() to run-length decode "values" of arbitrary dim
ensions.
See also: L</rld>.
Contributed by Bryan Jurish E<lt>moocow@cpan.orgE<gt>.
=for bad
rldvec 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.
=cut
#line 984 "Slices.pm"
#line 949 "../../blib/lib/PDL/PP.pm"
sub PDL::rldvec {
my ($a,$b,$c) = @_;
if (!defined($c)) {
# XXX Need to improve emulation of threading in auto-generating c
my ($rowlen) = $b->dim(0);
my ($size) = $a->sumover->max;
my (@dims) = $a->dims;
shift(@dims);
$c = $b->zeroes($b->type,$rowlen,$size,@dims);
}
&PDL::_rldvec_int($a,$b,$c);
return $c;
}
#line 1003 "Slices.pm"
#line 950 "../../blib/lib/PDL/PP.pm"
*rldvec = \&PDL::rldvec;
#line 1010 "Slices.pm"
#line 948 "../../blib/lib/PDL/PP.pm"
=head2 rleseq
=for sig
Signature: (c(N); indx [o]a(N); [o]b(N))
=for ref
Run-length encode a vector of subsequences.
Given a vector of $c() of concatenated variable-length, variable-offset subseque
nces,
generate a vector $a containing the length of each subsequence
and a vector $b containing the subsequence offsets.
As for rle(), only the elements up to the first instance of 0 in $a should be co
nsidered.
See also L</rle>.
Contributed by Bryan Jurish E<lt>moocow@cpan.orgE<gt>.
=for bad
rleseq 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.
=cut
#line 1044 "Slices.pm"
#line 950 "../../blib/lib/PDL/PP.pm"
*rleseq = \&PDL::rleseq;
#line 1051 "Slices.pm"
#line 948 "../../blib/lib/PDL/PP.pm"
=head2 rldseq
=for sig
Signature: (indx a(N); b(N); [o]c(M))
=for ref
Run-length decode a subsequence vector.
Given a vector $a() of sequence lengths
and a vector $b() of corresponding offsets,
decode concatenation of subsequences to $c(),
as for:
$c = null;
$c = $c->append($b($_)+sequence($a->type,$a($_))) foreach (0..($N-1));
See also: L</rld>.
Contributed by Bryan Jurish E<lt>moocow@cpan.orgE<gt>.
=for bad
rldseq 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.
=cut
#line 1088 "Slices.pm"
#line 949 "../../blib/lib/PDL/PP.pm"
sub PDL::rldseq {
my ($a,$b,$c) = @_;
if (!defined($c)) {
my $size = $a->sumover->max;
my (@dims) = $a->dims;
shift(@dims);
$c = $b->zeroes($b->type,$size,@dims);
}
&PDL::_rldseq_int($a,$b,$c);
return $c;
}
#line 1105 "Slices.pm"
#line 950 "../../blib/lib/PDL/PP.pm"
*rldseq = \&PDL::rldseq;
#line 1112 "Slices.pm"
#line 1346 "slices.pd"
=head2 rleND
=for sig
Signature: (data(@vdims,N); int [o]counts(N); [o]elts(@vdims,N))
=for ref
Run-length encode a set of (sorted) n-dimensional values.
Generalization of rle() and vv_rlevec():
given set of values $data, generate a vector $counts with the number of occurren
ces of each element
(where an "element" is a matrix of dimensions @vdims ocurring as a sequential ru
n over the
final dimension in $data), and a set of vectors $elts containing the elements wh
ich begin a run.
Really just a wrapper for clump() and rlevec().
See also: L</rle>, L</rlevec>.
Contributed by Bryan Jurish E<lt>moocow@cpan.orgE<gt>.
=cut
*PDL::rleND = \&rleND;
sub rleND {
my $data = shift;
my @vdimsN = $data->dims;
##-- construct output pdls
my $counts = $#_ >= 0 ? $_[0] : zeroes(long, $vdimsN[$#vdimsN]);
my $elts = $#_ >= 1 ? $_[1] : zeroes($data->type, @vdimsN);
##-- guts: call rlevec()
rlevec($data->clump($#vdimsN), $counts, $elts->clump($#vdimsN));
return ($counts,$elts);
}
=head2 rldND
=for sig
Signature: (int counts(N); elts(@vdims,N); [o]data(@vdims,N);)
=for ref
Run-length decode a set of (sorted) n-dimensional values.
Generalization of rld() and rldvec():
given a vector $counts() of the number of occurrences of each @vdims-dimensioned
element,
and a set $elts() of @vdims-dimensioned elements, run-length decode to $data().
Really just a wrapper for clump() and rldvec().
See also: L</rld>, L</rldvec>.
Contributed by Bryan Jurish E<lt>moocow@cpan.orgE<gt>.
=cut
*PDL::rldND = \&rldND;
sub rldND {
my ($counts,$elts) = (shift,shift);
my @vdimsN = $elts->dims;
##-- construct output pdl
my ($data);
if ($#_ >= 0) { $data = $_[0]; }
else {
my $size = $counts->sumover->max; ##-- get maximum size for Nth-dimensi
on for small encodings
my @countdims = $counts->dims;
shift(@countdims);
$data = zeroes($elts->type, @vdimsN, @countdims);
}
##-- guts: call rldvec()
rldvec($counts, $elts->clump($#vdimsN), $data->clump($#vdimsN));
return $data;
}
#line 1195 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*_clump_int = \&PDL::_clump_int; *_clump_int = \&PDL::_clump_int;
#line 911 "Slices.pm" #line 1202 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../blib/lib/PDL/PP.pm"
=head2 xchg =head2 xchg
=for sig =for sig
Signature: (P(); C(); PDL_Indx n1; PDL_Indx n2) Signature: (P(); C(); PDL_Indx n1; PDL_Indx n2)
=for ref =for ref
exchange two dimensions exchange two dimensions
skipping to change at line 863 skipping to change at line 1115
are exchanged with each other i.e. are exchanged with each other i.e.
$y->at(5,3,2,8) == $x->at(5,3,8,2) $y->at(5,3,2,8) == $x->at(5,3,8,2)
=for bad =for bad
xchg does not process bad values. xchg 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 951 "Slices.pm" #line 1242 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*xchg = \&PDL::xchg; *xchg = \&PDL::xchg;
#line 958 "Slices.pm" #line 1249 "Slices.pm"
#line 1269 "slices.pd" #line 1502 "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 990 skipping to change at line 1242
my $errString = "PDL::reorder: Dim index $newDimOrder[$i] out of r ange in position $i\n(range is 0-$#newDimOrder)"; my $errString = "PDL::reorder: Dim index $newDimOrder[$i] out of r ange in position $i\n(range is 0-$#newDimOrder)";
barf($errString); barf($errString);
} }
} }
# Checking that they are all present and also not duplicated is done by broadcast() [I think] # Checking that they are all present and also not duplicated is done by broadcast() [I think]
# a quicker way to do the reorder # a quicker way to do the reorder
return $pdl->broadcast(@newDimOrder)->unbroadcast(0); return $pdl->broadcast(@newDimOrder)->unbroadcast(0);
} }
#line 1083 "Slices.pm" #line 1374 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../blib/lib/PDL/PP.pm"
=head2 mv =head2 mv
=for sig =for sig
Signature: (P(); C(); PDL_Indx n1; PDL_Indx n2) Signature: (P(); C(); PDL_Indx n1; PDL_Indx n2)
=for ref =for ref
move a dimension to another position move a dimension to another position
skipping to change at line 1024 skipping to change at line 1276
The other dimensions are moved accordingly. The other dimensions are moved accordingly.
Negative dimension indices count from the end. Negative dimension indices count from the end.
=for bad =for bad
mv does not process bad values. mv 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 1123 "Slices.pm" #line 1414 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*mv = \&PDL::mv; *mv = \&PDL::mv;
#line 1130 "Slices.pm" #line 1421 "Slices.pm"
#line 1445 "slices.pd" #line 1675 "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 1061 skipping to change at line 1313
*using = \&PDL::using; *using = \&PDL::using;
sub PDL::using { sub PDL::using {
my ($x,@ind)=@_; my ($x,@ind)=@_;
@ind = list $ind[0] if (blessed($ind[0]) && $ind[0]->isa('PDL')); @ind = list $ind[0] if (blessed($ind[0]) && $ind[0]->isa('PDL'));
foreach (@ind) { foreach (@ind) {
$_ = $x->slice("($_)"); $_ = $x->slice("($_)");
} }
@ind; @ind;
} }
#line 1165 "Slices.pm" #line 1456 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../blib/lib/PDL/PP.pm"
=head2 diagonal =head2 diagonal
=for sig =for sig
Signature: (P(); C(); PDL_Indx whichdims[]) Signature: (P(); C(); PDL_Indx whichdims[])
=for ref =for ref
Returns the multidimensional diagonal over the specified dimensions. Returns the multidimensional diagonal over the specified dimensions.
skipping to change at line 1121 skipping to change at line 1373
[0 0 1] [0 0 1]
] ]
] ]
=for bad =for bad
diagonal does not process bad values. diagonal 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 1231 "Slices.pm" #line 1522 "Slices.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 949 "../../blib/lib/PDL/PP.pm"
sub PDL::diagonal { shift->_diagonal_int(my $o=PDL->null, \@_); $o } sub PDL::diagonal { shift->_diagonal_int(my $o=PDL->null, \@_); $o }
#line 1238 "Slices.pm" #line 1529 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*diagonal = \&PDL::diagonal; *diagonal = \&PDL::diagonal;
#line 1245 "Slices.pm" #line 1536 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../blib/lib/PDL/PP.pm"
=head2 lags =head2 lags
=for sig =for sig
Signature: (P(); C(); PDL_Indx nthdim;PDL_Indx step;PDL_Indx n) Signature: (P(); C(); PDL_Indx nthdim;PDL_Indx step;PDL_Indx n)
=for ref =for ref
Returns an ndarray of lags to parent. Returns an ndarray of lags to parent.
skipping to change at line 1179 skipping to change at line 1431
C<$step> and C<$nlags> must be positive. C<$nthdim> can be C<$step> and C<$nlags> must be positive. C<$nthdim> can be
negative and will then be counted from the last dim backwards negative and will then be counted from the last dim backwards
in the usual way (-1 = last dim). in the usual way (-1 = last dim).
=for bad =for bad
lags does not process bad values. lags 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 1299 "Slices.pm" #line 1590 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*lags = \&PDL::lags; *lags = \&PDL::lags;
#line 1306 "Slices.pm" #line 1597 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../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>).
skipping to change at line 1218 skipping to change at line 1470
$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 1637 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*splitdim = \&PDL::splitdim; *splitdim = \&PDL::splitdim;
#line 1353 "Slices.pm" #line 1644 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../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 1670 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*rotate = \&PDL::rotate; *rotate = \&PDL::rotate;
#line 1386 "Slices.pm" #line 1677 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../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
internal internal
skipping to change at line 1274 skipping to change at line 1526
=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 1710 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*broadcastI = \&PDL::broadcastI; *broadcastI = \&PDL::broadcastI;
#line 1426 "Slices.pm" #line 1717 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../blib/lib/PDL/PP.pm"
=head2 unbroadcast =head2 unbroadcast
=for sig =for sig
Signature: (P(); C(); int atind) Signature: (P(); C(); PDL_Indx atind)
=for ref =for ref
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 1745 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*unbroadcast = \&PDL::unbroadcast; *unbroadcast = \&PDL::unbroadcast;
#line 1461 "Slices.pm" #line 1752 "Slices.pm"
#line 1890 "slices.pd" #line 2110 "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 1458 skipping to change at line 1710
=cut =cut
sub PDL::dice_axis { sub PDL::dice_axis {
my($self,$axis,$idx) = @_; my($self,$axis,$idx) = @_;
my $ix = PDL->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 1907 "Slices.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 948 "../../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
$slice = $data->slice([2,3],'x',[2,2,0],"-1:1:-1", "*3"); $slice = $data->slice([2,3],'x',[2,2,0],"-1:1:-1", "*3");
skipping to change at line 1629 skipping to change at line 1881
$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 2085 "Slices.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 949 "../../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;
next; next;
} }
skipping to change at line 1669 skipping to change at line 1921
$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 2127 "Slices.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 950 "../../blib/lib/PDL/PP.pm"
*slice = \&PDL::slice; *slice = \&PDL::slice;
#line 1844 "Slices.pm" #line 2134 "Slices.pm"
#line 2381 "slices.pd" #line 2599 "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 1701 skipping to change at line 1953
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 2166 "Slices.pm"
# Exit with OK status # Exit with OK status
1; 1;
 End of changes. 77 change blocks. 
78 lines changed or deleted 346 lines changed or added

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