nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
huffman.hpp
Go to the documentation of this file.
1
3// toolboxes/comm/include/nk/comm/source/huffman.hpp
4//
5// Huffman entropy coding (huffmandict + huffmanenco / huffmandeco).
6
7#pragma once
8
9#include <memory_resource>
10#include <nk/value/value.hpp>
11#include <utility>
12
13namespace nk::comm {
14
17
18
35std::pair<Value, double>
36huffmandict(const Value &symbols, const Value &probs,
37 std::pmr::memory_resource *mr = nullptr);
38
51Value huffmanenco(const Value &sig, const Value &dict,
52 std::pmr::memory_resource *mr = nullptr);
53
67Value huffmandeco(const Value &bits, const Value &dict,
68 std::pmr::memory_resource *mr = nullptr);
69
70
72} // namespace nk::comm
Core MATLAB-compatible multidimensional array and scalar value type.
Definition value.hpp:61
Value huffmandeco(const Value &bits, const Value &dict, std::pmr::memory_resource *mr=nullptr)
Decode a Huffman bit stream (dec = huffmandeco(bits, dict)).
Value huffmanenco(const Value &sig, const Value &dict, std::pmr::memory_resource *mr=nullptr)
Encode a symbol sequence using a Huffman dictionary (enc = huffmanenco(sig, dict)).
std::pair< Value, double > huffmandict(const Value &symbols, const Value &probs, std::pmr::memory_resource *mr=nullptr)
Build a canonical Huffman dictionary ([dict, avglen] = huffmandict(symbols, probs)).