Module dsi_bitstream::codes::minimal_binary
source · Expand description
Minimal binary codes.
A minimal binary code with upper bound u > 0 (AKA truncated binary
encoding) is an
optimal prefix-free code for the first u natural numbers with uniform distribution.
There are several such prefix-free codes, and the one implemented here is
defined as follows: if s = ⌊log₂u⌋, then the first 2^(s+1) - u codewords are
the first binary numbers of length s – 1, and the remaining codewords
are the last 2u - 2^(s+1) binary numbers of length s.
Traits§
- Trait for reading minimal binary codes.
- Trait for writing minimal binary codes.
Functions§
- Return the length of the minimal binary code for
nwith upper boundmax.