"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Basic/Core/Core.pm" between
PDL-2.076.tar.gz and PDL-2.077.tar.gz

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

Core.pm  (PDL-2.076):Core.pm  (PDL-2.077)
skipping to change at line 31 skipping to change at line 31
# If "D" is available for pack(). # If "D" is available for pack().
our $CAN_PACK_D = !! eval { my $packed = pack "D", 0; 1 }; our $CAN_PACK_D = !! eval { my $packed = pack "D", 0; 1 };
our @EXPORT = qw( piddle pdl null barf ); # Only stuff always exported! our @EXPORT = qw( piddle pdl null barf ); # Only stuff always exported!
my @convertfuncs = map $_->convertfunc, PDL::Types::types(); my @convertfuncs = map $_->convertfunc, PDL::Types::types();
my @exports_internal = qw(howbig broadcastids topdl); my @exports_internal = qw(howbig broadcastids topdl);
my @exports_normal = (@EXPORT, my @exports_normal = (@EXPORT,
@convertfuncs, @convertfuncs,
qw(nelem dims shape null qw(nelem dims shape null
empty empty dup dupN
convert inplace zeroes zeros ones nan inf i list listindices unpdl convert inplace zeroes zeros ones nan inf i list listindices unpdl
set at flows broadcast_define over reshape dog cat barf type set at flows broadcast_define over reshape dog cat barf type
thread_define dummy mslice approx flat sclr squeeze thread_define dummy mslice approx flat sclr squeeze
get_autopthread_targ set_autopthread_targ get_autopthread_actual get_autopthread_targ set_autopthread_targ get_autopthread_actual
get_autopthread_dim get_autopthread_size set_autopthread_size) ); get_autopthread_dim get_autopthread_size set_autopthread_size) );
our @EXPORT_OK = (@exports_internal, @exports_normal); our @EXPORT_OK = (@exports_internal, @exports_normal);
our %EXPORT_TAGS = ( our %EXPORT_TAGS = (
Func => [@exports_normal], Func => [@exports_normal],
Internal => [@exports_internal] ); Internal => [@exports_internal] );
skipping to change at line 64 skipping to change at line 64
$PDL::indxformat = "%12d"; # Default print format for PDL_Indx values $PDL::indxformat = "%12d"; # Default print format for PDL_Indx values
$PDL::undefval = 0; # Value to use instead of undef when creating PDL s $PDL::undefval = 0; # Value to use instead of undef when creating PDL s
$PDL::toolongtoprint = 10000; # maximum pdl size to stringify for printing $PDL::toolongtoprint = 10000; # maximum pdl size to stringify for printing
################ Exportable functions of the Core ###################### ################ Exportable functions of the Core ######################
*at_c = *at_bad_c; # back-compat alias *at_c = *at_bad_c; # back-compat alias
*thread_define = *broadcast_define; *thread_define = *broadcast_define;
*PDL::threadover_n = *PDL::broadcastover_n; *PDL::threadover_n = *PDL::broadcastover_n;
*dup = \&PDL::dup; *dupN = \&PDL::dupN;
*howbig = \&PDL::howbig; *unpdl = \&PDL::unpdl; *howbig = \&PDL::howbig; *unpdl = \&PDL::unpdl;
*nelem = \&PDL::nelem; *inplace = \&PDL::inplace; *nelem = \&PDL::nelem; *inplace = \&PDL::inplace;
*dims = \&PDL::dims; *list = \&PDL::list; *dims = \&PDL::dims; *list = \&PDL::list;
*broadcastids = \&PDL::broadcastids; *listindices = \&PDL::listindices; *broadcastids = \&PDL::broadcastids; *listindices = \&PDL::listindices;
*null = \&PDL::null; *set = \&PDL::set; *null = \&PDL::null; *set = \&PDL::set;
*at = \&PDL::at; *flows = \&PDL::flows; *at = \&PDL::at; *flows = \&PDL::flows;
*sclr = \&PDL::sclr; *shape = \&PDL::shape; *sclr = \&PDL::sclr; *shape = \&PDL::shape;
for my $t (PDL::Types::types()) { for my $t (PDL::Types::types()) {
my $conv = $t->convertfunc; my $conv = $t->convertfunc;
skipping to change at line 179 skipping to change at line 180
PDLs can represent the empty set using "structured Empty" variables. PDLs can represent the empty set using "structured Empty" variables.
An empty PDL is not a null PDL. An empty PDL is not a null PDL.
Any dim of a PDL can be set explicitly to size 0. If so, the PDL Any dim of a PDL can be set explicitly to size 0. If so, the PDL
contains zero values (because the total number of values is the contains zero values (because the total number of values is the
product of all the sizes in the PDL's shape or dimlist). product of all the sizes in the PDL's shape or dimlist).
Scalar PDLs are zero-dimensional and have no entries in the dim list, Scalar PDLs are zero-dimensional and have no entries in the dim list,
so they cannot be empty. 1-D and higher PDLs can be empty. Empty so they cannot be empty. 1-D and higher PDLs can be empty. Empty
PDLs are useful for set operations, and are most commonly encountered PDLs are useful for set operations, and are most commonly encountered
in the output from selection operators such as L<which|PDL::Primitive> in the output from selection operators such as L<which|PDL::Primitive/which>
and L<whichND|PDL::Primitive>. Not all empty PDLs have the same and L<whichND|PDL::Primitive/whichND>. Not all empty PDLs have the same
broadcasting properties -- e.g. a 2x0-PDL represents a collection of broadcasting properties -- e.g. a 2x0-PDL represents a collection of
2-vectors that happens to contain no elements, while a simple 0-PDL 2-vectors that happens to contain no elements, while a simple 0-PDL
represents a collection of scalar values (that also happens to contain represents a collection of scalar values (that also happens to contain
no elements). no elements).
Note that 0 dims are not adjustable via the broadcasting rules -- a dim Note that 0 dims are not adjustable via the broadcasting rules -- a dim
with size 0 can only match a corresponding dim of size 0 or 1. with size 0 can only match a corresponding dim of size 0 or 1.
=head2 Broadcast rules and assignments =head2 Broadcast rules and assignments
skipping to change at line 775 skipping to change at line 776
representation of the PDL, which you probably shouldn't be doing representation of the PDL, which you probably shouldn't be doing
anyway. (see L</get_dataref>.) anyway. (see L</get_dataref>.)
=cut =cut
sub topdl {PDL->topdl(@_)} sub topdl {PDL->topdl(@_)}
####################### Overloaded operators ####################### ####################### Overloaded operators #######################
{ package PDL; { package PDL;
use overload '""' => \&PDL::Core::string; use Carp;
use overload
'""' => \&PDL::Core::string,
"=" => sub {$_[0]}, # Don't deep copy, just copy reference
bool => sub {
return 0 if $_[0]->isnull;
confess("multielement ndarray in conditional expression (see PDL::FAQ ques
tions 6-10 and 6-11)")
unless $_[0]->nelem == 1;
confess("bad value ndarray in conditional expression")
if $_[0]->badflag and $_[0].'' eq 'BAD';
$_[0]->clump(-1)->at(0);
},
;
} }
##################### Data type/conversion stuff ######################## ##################### Data type/conversion stuff ########################
sub PDL::dims { # Return dimensions as @list sub PDL::dims { # Return dimensions as @list
PDL->topdl(shift)->dims_c; PDL->topdl(shift)->dims_c;
} }
sub PDL::shape { # Return dimensions as a pdl sub PDL::shape { # Return dimensions as a pdl
indx([PDL->topdl(shift)->dims]); indx([PDL->topdl(shift)->dims]);
skipping to change at line 1508 skipping to change at line 1521
barf("For safety, <pos> < -(dims+1) forbidden in dummy. min=" barf("For safety, <pos> < -(dims+1) forbidden in dummy. min="
. -($pdl->getndims+1).", pos=". ($dim-1-$pdl->getndims) ) if($dim<0); . -($pdl->getndims+1).", pos=". ($dim-1-$pdl->getndims) ) if($dim<0);
# Avoid negative repeat count warning that came with 5.21 and later. # Avoid negative repeat count warning that came with 5.21 and later.
my $dim_diff = $dim - $pdl->getndims; my $dim_diff = $dim - $pdl->getndims;
my($s) = ',' x ( $dim_diff > 0 ? $pdl->getndims : $dim ); my($s) = ',' x ( $dim_diff > 0 ? $pdl->getndims : $dim );
$s .= '*1,' x ( $dim_diff > 0 ? $dim_diff : 0 ); $s .= '*1,' x ( $dim_diff > 0 ? $dim_diff : 0 );
$s .= "*$size"; $s .= "*$size";
$pdl->slice($s); $pdl->slice($s);
} }
=head2 dup
=for ref
Duplicates an ndarray along a dimension
=for example
$x = sequence(3);
$y = $x->dup(0, 2); # doubles along first dimension
# $y now [0 1 2 0 1 2]
=cut
sub PDL::dup {
my ($this, $dim, $times) = @_;
return $this->copy if $times == 1;
$this->dummy($dim+1, $times)->clump($dim, $dim+1);
}
=head2 dupN
=for ref
Duplicates an ndarray along several dimensions
=for example
$x = sequence(3,2);
$y = $x->dupN(2, 3); # doubles along first dimension, triples along second
=cut
sub PDL::dupN {
my ($this, @times) = @_;
return $this->copy if !grep $_ != 1, @times;
my $sl = join ',', map ":,*$_", @times; # insert right-size dummy after each r
eal
$this = $this->slice($sl);
$this = $this->clump($_, $_+1) for 0..$#times;
$this;
}
=head2 clump =head2 clump
=for ref =for ref
"clumps" several dimensions into one large dimension "clumps" several dimensions into one large dimension
If called with one argument C<$n> clumps the first C<$n> If called with one argument C<$n> clumps the first C<$n>
dimensions into one. For example, if C<$x> has dimensions dimensions into one. For example, if C<$x> has dimensions
C<(5,3,4)> then after C<(5,3,4)> then after
 End of changes. 5 change blocks. 
4 lines changed or deleted 61 lines changed or added

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