Compression.pm (PDL-2.082) | : | Compression.pm (PDL-2.083) | ||
---|---|---|---|---|
skipping to change at line 55 | skipping to change at line 55 | |||
=head1 FUNCTIONS | =head1 FUNCTIONS | |||
=cut | =cut | |||
#line 74 "compression.pd" | #line 74 "compression.pd" | |||
=head1 METHODS | =head1 METHODS | |||
=cut | =cut | |||
#line 73 "Compression.pm" | #line 68 "Compression.pm" | |||
#line 958 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
=head2 rice_compress | =head2 rice_compress | |||
=for sig | =for sig | |||
Signature: (in(n); [o]out(m); int[o]len(); int blocksize) | Signature: (in(n); [o]out(m); int[o]len(); int blocksize) | |||
=for ref | =for ref | |||
Squishes an input PDL along the 0 dimension by Rice compression. In | Squishes an input PDL along the 0 dimension by Rice compression. In | |||
skipping to change at line 118 | skipping to change at line 116 | |||
($out, $len, $blocksize, $dim0) = $pdl->rice_compress; | ($out, $len, $blocksize, $dim0) = $pdl->rice_compress; | |||
$new = $out->rice_expand; | $new = $out->rice_expand; | |||
=for bad | =for bad | |||
rice_compress ignores the bad-value flag of the input ndarrays. | rice_compress ignores the bad-value flag 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. | 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 142 "Compression.pm" | ||||
#line 959 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
sub PDL::rice_compress { | sub PDL::rice_compress { | |||
my $in = shift; | my $in = shift; | |||
my $blocksize = shift || 32; | my $blocksize = shift || 32; | |||
## Reject floating-point inputs | ## Reject floating-point inputs | |||
if( $in->type != byte && | if( $in->type != byte && | |||
$in->type != short && | $in->type != short && | |||
$in->type != ushort && | $in->type != ushort && | |||
$in->type != long | $in->type != long | |||
) { | ) { | |||
skipping to change at line 142 | skipping to change at line 137 | |||
} | } | |||
# output buffer starts the same size; truncate at the end. | # output buffer starts the same size; truncate at the end. | |||
my ($out) = zeroes($in); | my ($out) = zeroes($in); | |||
# lengths go here | # lengths go here | |||
my ($len) = zeroes(long, $in->slice("(0)")->dims); | my ($len) = zeroes(long, $in->slice("(0)")->dims); | |||
PDL::_rice_compress_int( $in, $out, $len, $blocksize ); | PDL::_rice_compress_int( $in, $out, $len, $blocksize ); | |||
my $l = $len->max; | my $l = $len->max; | |||
$out = $out->slice("0:".($l-1))->sever; | $out = $out->slice("0:".($l-1))->sever; | |||
return wantarray ? ($out, $in->dim(0), $blocksize, $len) : $out; | return wantarray ? ($out, $in->dim(0), $blocksize, $len) : $out; | |||
} | } | |||
#line 168 "Compression.pm" | ||||
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
*rice_compress = \&PDL::rice_compress; | *rice_compress = \&PDL::rice_compress; | |||
#line 175 "Compression.pm" | ||||
#line 958 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
=head2 rice_expand | =head2 rice_expand | |||
=for sig | =for sig | |||
Signature: (in(n); [o]out(m); int blocksize) | Signature: (in(n); [o]out(m); int blocksize) | |||
=for ref | =for ref | |||
Unsquishes a PDL that has been squished by rice_compress. | Unsquishes a PDL that has been squished by rice_compress. | |||
skipping to change at line 172 | skipping to change at line 161 | |||
($out, $len, $blocksize, $dim0) = $pdl->rice_compress; | ($out, $len, $blocksize, $dim0) = $pdl->rice_compress; | |||
$copy = $out->rice_expand($dim0, $blocksize); | $copy = $out->rice_expand($dim0, $blocksize); | |||
=for bad | =for bad | |||
rice_expand ignores the bad-value flag of the input ndarrays. | rice_expand ignores the bad-value flag 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. | 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 206 "Compression.pm" | ||||
#line 959 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
sub PDL::rice_expand { | sub PDL::rice_expand { | |||
my $squished = shift; | my $squished = shift; | |||
my $dim0 =shift; | my $dim0 =shift; | |||
my $blocksize = shift || 32; | my $blocksize = shift || 32; | |||
# Allocate output array | # Allocate output array | |||
my $out = zeroes( $squished->slice("(0),*$dim0") ); | my $out = zeroes( $squished->slice("(0),*$dim0") ); | |||
PDL::_rice_expand_int( $squished, $out, $blocksize ); | PDL::_rice_expand_int( $squished, $out, $blocksize ); | |||
return $out; | return $out; | |||
} | } | |||
#line 221 "Compression.pm" | ||||
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
*rice_expand = \&PDL::rice_expand; | *rice_expand = \&PDL::rice_expand; | |||
#line 228 "Compression.pm" | ||||
#line 35 "compression.pd" | #line 35 "compression.pd" | |||
=head1 AUTHORS | =head1 AUTHORS | |||
Copyright (C) 2010 Craig DeForest. | Copyright (C) 2010 Craig DeForest. | |||
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, | |||
skipping to change at line 228 | skipping to change at line 210 | |||
=over 3 | =over 3 | |||
=item * Add object encapsulation | =item * Add object encapsulation | |||
=item * Add test suite | =item * Add test suite | |||
=back | =back | |||
=cut | =cut | |||
#line 271 "Compression.pm" | #line 244 "Compression.pm" | |||
# Exit with OK status | # Exit with OK status | |||
1; | 1; | |||
End of changes. 8 change blocks. | ||||
20 lines changed or deleted | 2 lines changed or added |