- SEE ALSO
Data::BitStream::Code::Baer - A Role implementing Baer codes
A role written for Data::BitStream that provides get and set methods for the power law codes of Michael B. Baer. The role applies to a stream object.
Provided Object Methods
- put_baer($k, $value)
- put_baer($k, @values)
Insert one or more values as Baer c_k codes. Returns 1.
- get_baer($k, $count)
Decode one or more Baer c_k codes from the stream. If count is omitted, one value will be read. If count is negative, values will be read until the end of the stream is reached. In scalar context it returns the last code read; in array context it returns an array of all codes read.
The parameter k cannot be more than 32.
k=0 is the base c_0 code.
k<0 performs unary (1-based) coding of small values followed by c_0 coding the remainder (
c_o(value+k)) for large values. This works well when the probability of small values is much higher than larger values.
k>0 is similar to a Rice(k) code in that we encode
c_o(value>>k) followed by encoding the bottom k bits of value. This works well when most values are medium-sized.
Typical k values are between -6 and 6.
These methods are required for the role.
- Michael B. Baer, "Prefix Codes for Power Laws," in IEEE International Symposium on Information Theory 2008 (ISIT 2008), pp 2464-2468, Toronto ON.
Dana Jacobsen <email@example.com>
Copyright 2011 by Dana Jacobsen <firstname.lastname@example.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.