Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (37 sloc) 1.35 KB
NAME
Integer::Elias - Elias coder
SYNOPSIS
use Integer::Elias::Encoder;
use Integer::Elias::Decoder;
## Gamma code
my $encoder = Integer::Elias::Encoder->new;
$encoder->gamma_encode(0); ## this module can encode 0
$encoder->gamma_encode(5);
$encoder->gamma_encode(10);
$encoder->finish;
say $encoder->as_string;
my $decoder = Integer::Elias::Decoder->new( $encoder->binary );
$decoder->gamma_decode; # 0
$decoder->gamma_decode; # 5
$decoder->gamma_decode; # 10
## Delta code
$encoder = Integer::Elias::Encoder->new;
$encoder->delta_encode(10);
...
$encoder->finish;
say $encoder->as_string;
$decoder = Integer::Elias::Decoder->new( $encoder->binary );
$decoder->delta_decode;
...
DESCRIPTION
Elias gamma/delta code is a universal code encoding positive integers.
SEE ALSO
<http://en.wikipedia.org/wiki/Universal_code_(data_compression)>
<http://www.geocities.jp/m_hiroi/light/pyalgo30.html>
AUTHOR
Naoya Ito, <naoya at bloghackers.net>
COPYRIGHT AND LICENSE
Copyright (C) 2008 by Naoya Ito
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.8.8 or, at
your option, any later version of Perl 5 you may have available.