Compression.pm (PDL-2.081) | : | Compression.pm (PDL-2.082) | ||
---|---|---|---|---|
skipping to change at line 57 | skipping to change at line 57 | |||
=cut | =cut | |||
#line 74 "compression.pd" | #line 74 "compression.pd" | |||
=head1 METHODS | =head1 METHODS | |||
=cut | =cut | |||
#line 73 "Compression.pm" | #line 73 "Compression.pm" | |||
#line 949 "/home/osboxes/pdl-code/blib/lib/PDL/PP.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 120 | skipping to change at line 120 | |||
$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 142 "Compression.pm" | |||
#line 950 "/home/osboxes/pdl-code/blib/lib/PDL/PP.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 144 | skipping to change at line 144 | |||
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 168 "Compression.pm" | |||
#line 951 "/home/osboxes/pdl-code/blib/lib/PDL/PP.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 175 "Compression.pm" | |||
#line 949 "/home/osboxes/pdl-code/blib/lib/PDL/PP.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 174 | skipping to change at line 174 | |||
$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 206 "Compression.pm" | |||
#line 950 "/home/osboxes/pdl-code/blib/lib/PDL/PP.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 221 "Compression.pm" | |||
#line 951 "/home/osboxes/pdl-code/blib/lib/PDL/PP.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 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 | |||
End of changes. 6 change blocks. | ||||
6 lines changed or deleted | 6 lines changed or added |