Expand description
ALICE-Zip — Compression primitives + procedural signal generators
LZ77 sliding window / dictionary coding / Shannon entropy / byte-pair encoding, plus the generator laws (polynomial / Fourier / Perlin) that let downstream crates store how to regenerate a signal instead of its samples (“send the law, not the data”).
The crate is no_std + alloc by default-features-off; the std feature
(on by default) adds the zlib wrappers and std::error::Error.
§Quick start
use alice_zip::prelude::*;
// Compression primitives (no_std)
let tokens = lz77_encode(b"abcabcabcabc", 256, 32);
assert_eq!(lz77_decode(&tokens)?, b"abcabcabcabc");
assert_eq!(shannon_entropy(&(0..=255u8).collect::<Vec<_>>()), 8.0);
// Generator laws: fit a series, keep the coefficients, regenerate
let series: Vec<f32> = (0..64).map(|i| 3.0 + 2.0 * i as f32).collect();
let (coeffs, degree, err) = fit_polynomial(&series, 4, 1e-6).unwrap();
assert_eq!((degree, generate_polynomial(64, &coeffs) == series), (1, true));
let (bins, dc) = analyze_signal(&generate_sine_wave(32, 1.0, 2.0, 0.0, 0.5), 4, 0.99);
let regenerated = generate_from_coefficients(32, &bins, dc);§Module 構成
| Module | 内容 | feature |
|---|---|---|
lz77 | LZ77 sliding-window encode / decode + lz77::LzToken | — |
dictionary | phrase → index 辞書 dictionary::Dictionary (FIFO eviction) | — |
entropy | Shannon entropy + 理論最小サイズ | — |
bpe | Byte-pair encoding (最頻ペア検出 + 置換) | — |
generators | polynomial / Fourier / Perlin generator laws | fft / parallel で加速 path 追加 |
law | fitted law + residual + valid range + provenance + oracle cases, verdict on new evidence | — |
quantize | 8 / 16-bit min-max quantisation of f32 samples | — |
compression | zlib wrappers (flate2); LZMA + .alice residual containers | std; lzma |
error | 共通 error::ZipError | — |
prelude | 主要 API 一括 re-export | — |
§no_std
--no-default-features で core + alloc のみに依存する float の超越関数は
libm に委譲するため、std build と最終 ulp が異なることがある (法則は同一)
64-bit atomics 等の前提は無く、thumbv7em-none-eabihf で CI が rlib build を検証する
§backward compatibility
v0.1.0 まで crate ルート直下に定義していた項目は module 移動後も
ルートから pub use で公開している
Re-exports§
pub use crate::bpe::bpe_replace;pub use crate::bpe::find_most_frequent_pair;pub use crate::dictionary::Dictionary;pub use crate::entropy::shannon_entropy;pub use crate::entropy::theoretical_min_size;pub use crate::error::ZipError;pub use crate::lz77::lz77_decode;pub use crate::lz77::lz77_encode;pub use crate::lz77::LzToken;
Modules§
- bpe
- Byte-pair Encoding (BPE) primitives
- compression
- Byte-stream compression wrappers and the
.aliceresidual container. - container
- A container that holds several payloads, each identified by its SHA-256
- dictionary
- Dictionary coding (= phrase → index mapping with FIFO eviction)
- entropy
- Entropy estimation (= Shannon entropy + theoretical minimum size)
- error
- Error type for ALICE-Zip
- generators
- Procedural signal generators — the laws that let downstream crates store the function that produces the signal instead of the raw samples
- law
- A fitted law kept together with what it was fitted from and where it holds
- lz77
- LZ77 sliding-window compression
- prelude
- Convenience re-export (=
use alice_zip::prelude::*;で主要 API 一括取得) - quantize
- Uniform min / max quantisation of
f32samples to 8 or 16 bits (no_std)