1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use crate::backends::match_model::MatchModel;
#[derive(Clone, Debug)]
/// Gapped/sparse match predictor wrapper over [`MatchModel`].
pub struct SparseMatchModel {
inner: MatchModel,
}
impl SparseMatchModel {
/// Create a sparse match model with configurable gap range and mixing behavior.
pub fn new(
hash_bits: usize,
min_len: usize,
max_len: usize,
gap_min: usize,
gap_max: usize,
base_mix: f64,
confidence_scale: f64,
) -> Self {
Self {
inner: MatchModel::new(
hash_bits,
min_len,
max_len,
gap_min,
gap_max,
base_mix,
confidence_scale,
),
}
}
/// Fill `out` with the current normalized byte PDF.
pub fn fill_pdf(&mut self, out: &mut [f64; 256]) {
self.inner.fill_pdf(out);
}
/// Borrow the current normalized byte PDF.
pub fn pdf(&mut self) -> &[f64; 256] {
self.inner.pdf()
}
/// Borrow the cumulative distribution derived from the current PDF.
pub fn cdf(&mut self) -> &[f64; 257] {
self.inner.cdf()
}
/// Return `ln(max(P(symbol), min_prob))`.
pub fn log_prob(&mut self, symbol: u8, min_prob: f64) -> f64 {
self.inner.log_prob(symbol, min_prob)
}
/// Observe one symbol and update sparse-match statistics.
pub fn update(&mut self, symbol: u8) {
self.inner.update(symbol);
}
/// Reset only conditioning history, preserving learned tables.
pub fn reset_history(&mut self) {
self.inner.reset_history();
}
/// Advance history without updating learned sparse-match tables.
pub fn update_history_only(&mut self, symbol: u8) {
self.inner.update_history_only(symbol);
}
}