"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "GENERATED/PDL/Compression.pm" between
PDL-2.074.tar.gz and PDL-2.075.tar.gz

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

Compression.pm  (PDL-2.074):Compression.pm  (PDL-2.075)
skipping to change at line 17 skipping to change at line 17
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::Compression ; bootstrap PDL::Compression ;
#line 6 "compression.pd" #line 5 "compression.pd"
=head1 NAME =head1 NAME
PDL::Compression - compression utilities PDL::Compression - compression utilities
=head1 DESCRIPTION =head1 DESCRIPTION
These routines generally accept some data as a PDL and compress it These routines generally accept some data as a PDL and compress it
into a smaller PDL. Algorithms typically work on a single dimension into a smaller PDL. Algorithms typically work on a single dimension
and thread over other dimensions, producing a threaded table of and broadcast over other dimensions, producing a broadcasted table of
compressed values if more than one dimension is fed in. compressed values if more than one dimension is fed in.
The Rice algorithm, in particular, is designed to be identical to the The Rice algorithm, in particular, is designed to be identical to the
RICE_1 algorithm used in internal FITS-file compression (see PDL::IO::FITS). RICE_1 algorithm used in internal FITS-file compression (see PDL::IO::FITS).
=head1 SYNOPSIS =head1 SYNOPSIS
use PDL::Compression use PDL::Compression
($y,$xsize) = $x->rice_compress(); ($y,$xsize) = $x->rice_compress();
$c = $y->rice_expand($xsize); $c = $y->rice_expand($xsize);
=cut =cut
use strict; use strict;
use warnings; use warnings;
#line 52 "Compression.pm" #line 53 "Compression.pm"
=head1 FUNCTIONS =head1 FUNCTIONS
=cut =cut
#line 75 "compression.pd" #line 74 "compression.pd"
=head1 METHODS =head1 METHODS
=cut =cut
#line 71 "Compression.pm" #line 73 "Compression.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1058 "../../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
scalar context, you get back only the compressed PDL; in list context, scalar context, you get back only the compressed PDL; in list context,
you also get back ancillary information that is required to uncompress you also get back ancillary information that is required to uncompress
the data with rice_uncompress. the data with rice_uncompress.
Multidimensional data are threaded over - each row is compressed Multidimensional data are broadcasted over - each row is compressed
separately, and the returned PDL is squished to the maximum compressed separately, and the returned PDL is squished to the maximum compressed
size of any row. If any of the streams could not be compressed (the size of any row. If any of the streams could not be compressed (the
algorithm produced longer output), the corresponding length is set to -1 algorithm produced longer output), the corresponding length is set to -1
and the row is treated as if it had length 0. and the row is treated as if it had length 0.
Rice compression only works on integer data types -- if you have Rice compression only works on integer data types -- if you have
floating point data you must first quantize them. floating point data you must first quantize them.
The underlying algorithm is identical to the Rice compressor used in The underlying algorithm is identical to the Rice compressor used in
CFITSIO (and is used by PDL::IO::FITS to load and save compressed FITS CFITSIO (and is used by PDL::IO::FITS to load and save compressed FITS
skipping to change at line 118 skipping to change at line 118
($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 139 "Compression.pm" #line 142 "Compression.pm"
#line 1059 "../../blib/lib/PDL/PP.pm"
#line 1060 "../../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
) { ) {
die("rice_compress: input needs to have type byte, short, ushort, or long , not ".($in->type)."\n"); die("rice_compress: input needs to have type byte, short, ushort, or long , not ".($in->type)."\n");
} }
# 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 164 "Compression.pm" #line 168 "Compression.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
*rice_compress = \&PDL::rice_compress; *rice_compress = \&PDL::rice_compress;
#line 170 "Compression.pm" #line 175 "Compression.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1058 "../../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 170 skipping to change at line 172
($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 200 "Compression.pm" #line 206 "Compression.pm"
#line 1059 "../../blib/lib/PDL/PP.pm"
#line 1060 "../../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 214 "Compression.pm" #line 221 "Compression.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
*rice_expand = \&PDL::rice_expand; *rice_expand = \&PDL::rice_expand;
#line 220 "Compression.pm" #line 228 "Compression.pm"
#line 36 "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,
the copyright notice should be included in the file. the copyright notice should be included in the file.
skipping to change at line 224 skipping to change at line 228
=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 262 "Compression.pm" #line 271 "Compression.pm"
# Exit with OK status # Exit with OK status
1; 1;
 End of changes. 20 change blocks. 
20 lines changed or deleted 24 lines changed or added

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