```{index} single: PDL::Compression ``` # PDL::Compression ```{pperl-module-badges} PDL::Compression ``` Rice compression of integer ndarrays, as FITS files use it. ```perl use PDL; use PDL::Compression; my $x = long(1, 2, 3, 4, 5, 4, 3, 2, 1, 0); my ($y, $n, $blocksize, $len) = $x->rice_compress; print $y->rice_expand($len, $n), "\n"; # [1 2 3 4 5 4 3 2 1 0] ``` `rice_compress` squeezes each row of a byte, short, ushort or long ndarray; in list context it also returns the row length, the block size and each row's compressed length, which `rice_expand` needs to restore the data. The algorithm is the RICE_1 compression of CFITSIO, so PDL::IO::FITS reads and writes RICE-compressed images with it. This is PDL::Compression of PDL 2.106: upstream's Perl, unchanged, over PDL's own kernels run by pperl's engine.