"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Basic/Core/Core.pm" 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).

Core.pm  (PDL-2.077):Core.pm  (PDL-2.078)
skipping to change at line 200 skipping to change at line 200
=head2 Broadcast rules and assignments =head2 Broadcast rules and assignments
Versions of PDL through 2.4.10 have some irregularity with broadcasting and Versions of PDL through 2.4.10 have some irregularity with broadcasting and
assignments. Currently the broadcasting engine performs a full expansion of assignments. Currently the broadcasting engine performs a full expansion of
both sides of the computed assignment operator C<.=> (which assigns values both sides of the computed assignment operator C<.=> (which assigns values
to a pre-existing PDL). This leads to counter-intuitive behavior in to a pre-existing PDL). This leads to counter-intuitive behavior in
some cases: some cases:
=over 3 =over 3
=item * Generalized scalars and computed assignment
If the PDL on the left-hand side of C<.=> has a dim of size 1, it can be
treated as a generalized scalar, as in:
$x = sequence(2,3);
$y = zeroes(1,3);
$y .= $x;
In this case, C<$y> is automatically treated as a 2x3-PDL during the
broadcasting operation, but half of the values from C<$x> silently disappear.
The output is, as Kernighan and Ritchie would say, "undefined".
Further, if the value on the right of C<.=> is empty, then C<.=> becomes
a silent no-op:
$x = zeroes(0);
$y = zeroes(1);
$y .= $x+1;
print $y;
will print C<[0]>. In this case, "$x+1" is empty, and "$y" is a generalized
scalar that is adjusted to be empty, so the assignment is carried out for
zero elements (a no-op).
Both of these behaviors are considered harmful and should not be relied upon:
they may be patched away in a future version of PDL.
=item * Empty PDLs and generalized scalars =item * Empty PDLs and generalized scalars
Generalized scalars (PDLs with a dim of size 1) can match any size in the Generalized scalars (PDLs with a dim of size 1) can match any size in the
corresponding dim, including 0. Thus, corresponding dim, including 0. Thus,
$x = ones(2,0); $x = ones(2,0);
$y = sequence(2,1); $y = sequence(2,1);
$c = $x * $y; $c = $x * $y;
print $c; print $c;
skipping to change at line 3433 skipping to change at line 3405
} }
chop $ret; $ret.="]"; chop $ret; $ret.="]";
return $ret; return $ret;
} }
# String 2D array in nice uniform format # String 2D array in nice uniform format
sub str2D{ sub str2D{
my($self,$format,$level)=@_; my($self,$format,$level)=@_;
# print "STR2D:\n"; $self->printdims();
my @dims = $self->dims(); my @dims = $self->dims();
barf "Not 2D" if scalar(@dims)!=2; barf "Not 2D" if scalar(@dims)!=2;
my $x = listref_c($self); my $x = listref_c($self);
my ($i, $f, $t, $len, $ret); my ($i, $f, $t, $len, $ret);
my $dtype = $self->get_datatype(); my $dtype = $self->get_datatype();
my $badflag = $self->badflag(); my $badflag = $self->badflag();
my $findmax = 1; my $findmax = 1;
if (!defined $format || $format eq "") { if (!defined $format || $format eq "") {
skipping to change at line 3972 skipping to change at line 3943
File::Map::sys_map( File::Map::sys_map(
${$pdl_dataref}, ${$pdl_dataref},
$len, $len,
File::Map::PROT_READ() | ($writable ? File::Map::PROT_WRITE() : 0), File::Map::PROT_READ() | ($writable ? File::Map::PROT_WRITE() : 0),
($shared ? File::Map::MAP_SHARED() : File::Map::MAP_PRIVATE()), ($shared ? File::Map::MAP_SHARED() : File::Map::MAP_PRIVATE()),
$fh, $fh,
0 0
); );
$pdl->upd_data; $pdl->upd_data(1);
if ($PDL::debug) { if ($PDL::debug) {
printf STDERR "set_data_by_file_map: length \${\$pdl_dataref} is %d.\n" , length ${$pdl_dataref}; printf STDERR "set_data_by_file_map: length \${\$pdl_dataref} is %d.\n" , length ${$pdl_dataref};
} }
$pdl->set_donttouchdata($len); $pdl->set_donttouchdata($len);
} else { } else {
# Special case: zero-length file # Special case: zero-length file
$_[0] = undef; $_[0] = undef;
 End of changes. 3 change blocks. 
30 lines changed or deleted 1 lines changed or added

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