pub struct Params {
pub m: usize,
pub u: i64,
pub v: i64,
}Expand description
Window [u, v] for m binary queries.
Fields§
§m: usizeNumber of commuting involutions Q_1 … Q_m.
u: i64Lower end of the window (may be negative).
v: i64Upper end of the window (may exceed m).
Implementations§
Source§impl Params
impl Params
Sourcepub fn paper(m: usize) -> Self
pub fn paper(m: usize) -> Self
The parameters exactly as chosen in the paper.
Examples found in repository?
12fn main() {
13 println!("== Paper parameters (binary case) ==");
14 println!("{:>5} {:>3} {:>4} {:>6} {:>6} {:>4} {:>8} {:>12}", "m", "r", "B", "u", "v", "D", "D<m?", "exc.frac");
15 for m in [3, 8, 16, 32, 48, 64, 65, 80, 96, 128, 256, 1024] {
16 let p = Params::paper(m);
17 println!(
18 "{:>5} {:>3} {:>4} {:>6} {:>6} {:>4} {:>8} {:>12.3e}",
19 m,
20 paper_r(m),
21 paper_half_width(m),
22 p.u,
23 p.v,
24 p.degree(),
25 p.window_bites(),
26 p.exception_fraction()
27 );
28 }
29 let t = paper_threshold_m();
30 let d = Params::paper(t).degree();
31 let axes = 2 * (t + d - 1);
32 println!(
33 "\nWindow first bites at m = {t} (D = {d}). One kernel level then uses about A = 2(m+D-1) = {axes} axes,"
34 );
35 println!("so a single level needs N >= 2^{axes} (rough lower estimate, not a figure from the paper).");
36
37 println!("\n== Exact repair check ==");
38 for (m, b) in [(6usize, 1.0f64), (8, 1.5), (10, 2.0)] {
39 let params = Params::with_half_width(m, b);
40 let w = 1usize << m;
41 let shifts = balanced_shifts(m, w);
42 let xs: Vec<Vec<Fp>> = (0..w)
43 .map(|i| (0..1u64 << m).map(|k| Fp::new((i as u64 + 1) * 1_000_003 + k * k)).collect())
44 .collect();
45
46 // Prediction alone (no repair) is wrong at the exceptions.
47 let ctr0 = OpCounter::default();
48 let wrong_rows = (0..w)
49 .filter(|&i| apply_predictor(¶ms, shifts[i], &xs[i], &ctr0) != apply_f_reference(m, &xs[i]))
50 .count();
51
52 let ctr = OpCounter::default();
53 let out = apply_f_repaired(¶ms, &xs, &shifts, None, &ctr);
54 let exact = xs.iter().zip(&out.rows).all(|(x, y)| *y == apply_f_reference(m, x));
55 println!(
56 "m={m:>2} window=[{},{}] D={} W={w}: prediction-only wrong rows {wrong_rows}/{w}, \
57 s={} (paper budget W/2m^3 = {}), repaired exact = {exact}, \
58 Q-calls={} (naive {}), spectral rows={}",
59 params.u,
60 params.v,
61 params.degree(),
62 out.s,
63 paper_exception_budget(w, m),
64 ctr.q(),
65 w * m,
66 ctr.spectral()
67 );
68 assert!(exact);
69 }
70 println!("\nNote: Q-calls are high because the predictor is expanded directly");
71 println!("(no matrix-root/routing). This checks correctness, not the paper's cost savings.");
72
73 println!("\n== Cyclic / abelian-group DFT via Newton + in-place Toeplitz (grids.tex) ==");
74 use log_fft::paper::grid::{naive_group_dft, newton::vandermonde, AxisPlan, GroupDft};
75 let cases: Vec<(usize, Option<u64>)> = vec![(17, None), (255, None), (1020, None), (4096, None), (1000, Some(3)), (777, Some(5))];
76 for (a, q) in cases {
77 let (plan, label) = match q {
78 None => (AxisPlan::dft(a), "DFT".to_string()),
79 Some(q) => (AxisPlan::geometric(a, Fp::new(q)), format!("V_a(q={q})")),
80 };
81 let x: Vec<Fp> = (0..a as u64).map(|i| Fp::new(i * 2654435761 + 1)).collect();
82 let mut scratch = vec![Fp::ZERO; a];
83 let y = plan.forward(&x, &mut scratch);
84 let v = vandermonde(a, plan.q);
85 let expect: Vec<Fp> = (0..a).map(|j| (0..a).fold(Fp::ZERO, |s, k| s + v[j][k] * x[k])).collect();
86 let ok = y == expect;
87 let back = plan.inverse(&y, &mut scratch) == x;
88 let restored = scratch.iter().all(|v| *v == Fp::ZERO);
89 println!(
90 "{label:>11} a={a:>5} b={:>5} factors={:<14} forward exact={ok} inverse exact={back} scratch restored={restored}",
91 plan.engine.dft.b,
92 format!("{:?}", plan.engine.dft.factors),
93 );
94 assert!(ok && back && restored);
95 }
96 let dims = [3usize, 5, 17, 4];
97 let g = GroupDft::new(&dims);
98 let x: Vec<Fp> = (0..g.len() as u64).map(|i| Fp::new(i * i + 9)).collect();
99 let exact = g.forward(&x) == naive_group_dft(&dims, &x);
100 println!("G = Z3 x Z5 x Z17 x Z4 (N={}): exact = {exact}", g.len());
101 assert!(exact);
102}Sourcepub fn with_half_width(m: usize, b: f64) -> Self
pub fn with_half_width(m: usize, b: f64) -> Self
A window [⌊m/2 − b⌋, ⌈m/2 + b⌉] with a chosen half-width b.
For small m the paper’s window covers all of [0, m], so there are
no exceptions and the repair step has nothing to do. A narrower window
makes exceptions appear, which tests the repair step.
Examples found in repository?
12fn main() {
13 println!("== Paper parameters (binary case) ==");
14 println!("{:>5} {:>3} {:>4} {:>6} {:>6} {:>4} {:>8} {:>12}", "m", "r", "B", "u", "v", "D", "D<m?", "exc.frac");
15 for m in [3, 8, 16, 32, 48, 64, 65, 80, 96, 128, 256, 1024] {
16 let p = Params::paper(m);
17 println!(
18 "{:>5} {:>3} {:>4} {:>6} {:>6} {:>4} {:>8} {:>12.3e}",
19 m,
20 paper_r(m),
21 paper_half_width(m),
22 p.u,
23 p.v,
24 p.degree(),
25 p.window_bites(),
26 p.exception_fraction()
27 );
28 }
29 let t = paper_threshold_m();
30 let d = Params::paper(t).degree();
31 let axes = 2 * (t + d - 1);
32 println!(
33 "\nWindow first bites at m = {t} (D = {d}). One kernel level then uses about A = 2(m+D-1) = {axes} axes,"
34 );
35 println!("so a single level needs N >= 2^{axes} (rough lower estimate, not a figure from the paper).");
36
37 println!("\n== Exact repair check ==");
38 for (m, b) in [(6usize, 1.0f64), (8, 1.5), (10, 2.0)] {
39 let params = Params::with_half_width(m, b);
40 let w = 1usize << m;
41 let shifts = balanced_shifts(m, w);
42 let xs: Vec<Vec<Fp>> = (0..w)
43 .map(|i| (0..1u64 << m).map(|k| Fp::new((i as u64 + 1) * 1_000_003 + k * k)).collect())
44 .collect();
45
46 // Prediction alone (no repair) is wrong at the exceptions.
47 let ctr0 = OpCounter::default();
48 let wrong_rows = (0..w)
49 .filter(|&i| apply_predictor(¶ms, shifts[i], &xs[i], &ctr0) != apply_f_reference(m, &xs[i]))
50 .count();
51
52 let ctr = OpCounter::default();
53 let out = apply_f_repaired(¶ms, &xs, &shifts, None, &ctr);
54 let exact = xs.iter().zip(&out.rows).all(|(x, y)| *y == apply_f_reference(m, x));
55 println!(
56 "m={m:>2} window=[{},{}] D={} W={w}: prediction-only wrong rows {wrong_rows}/{w}, \
57 s={} (paper budget W/2m^3 = {}), repaired exact = {exact}, \
58 Q-calls={} (naive {}), spectral rows={}",
59 params.u,
60 params.v,
61 params.degree(),
62 out.s,
63 paper_exception_budget(w, m),
64 ctr.q(),
65 w * m,
66 ctr.spectral()
67 );
68 assert!(exact);
69 }
70 println!("\nNote: Q-calls are high because the predictor is expanded directly");
71 println!("(no matrix-root/routing). This checks correctness, not the paper's cost savings.");
72
73 println!("\n== Cyclic / abelian-group DFT via Newton + in-place Toeplitz (grids.tex) ==");
74 use log_fft::paper::grid::{naive_group_dft, newton::vandermonde, AxisPlan, GroupDft};
75 let cases: Vec<(usize, Option<u64>)> = vec![(17, None), (255, None), (1020, None), (4096, None), (1000, Some(3)), (777, Some(5))];
76 for (a, q) in cases {
77 let (plan, label) = match q {
78 None => (AxisPlan::dft(a), "DFT".to_string()),
79 Some(q) => (AxisPlan::geometric(a, Fp::new(q)), format!("V_a(q={q})")),
80 };
81 let x: Vec<Fp> = (0..a as u64).map(|i| Fp::new(i * 2654435761 + 1)).collect();
82 let mut scratch = vec![Fp::ZERO; a];
83 let y = plan.forward(&x, &mut scratch);
84 let v = vandermonde(a, plan.q);
85 let expect: Vec<Fp> = (0..a).map(|j| (0..a).fold(Fp::ZERO, |s, k| s + v[j][k] * x[k])).collect();
86 let ok = y == expect;
87 let back = plan.inverse(&y, &mut scratch) == x;
88 let restored = scratch.iter().all(|v| *v == Fp::ZERO);
89 println!(
90 "{label:>11} a={a:>5} b={:>5} factors={:<14} forward exact={ok} inverse exact={back} scratch restored={restored}",
91 plan.engine.dft.b,
92 format!("{:?}", plan.engine.dft.factors),
93 );
94 assert!(ok && back && restored);
95 }
96 let dims = [3usize, 5, 17, 4];
97 let g = GroupDft::new(&dims);
98 let x: Vec<Fp> = (0..g.len() as u64).map(|i| Fp::new(i * i + 9)).collect();
99 let exact = g.forward(&x) == naive_group_dft(&dims, &x);
100 println!("G = Z3 x Z5 x Z17 x Z4 (N={}): exact = {exact}", g.len());
101 assert!(exact);
102}Sourcepub fn with_window(m: usize, u: i64, v: i64) -> Self
pub fn with_window(m: usize, u: i64, v: i64) -> Self
An explicit window [u, v].
Sourcepub fn degree(&self) -> usize
pub fn degree(&self) -> usize
Predictor degree D = v − u.
Examples found in repository?
12fn main() {
13 println!("== Paper parameters (binary case) ==");
14 println!("{:>5} {:>3} {:>4} {:>6} {:>6} {:>4} {:>8} {:>12}", "m", "r", "B", "u", "v", "D", "D<m?", "exc.frac");
15 for m in [3, 8, 16, 32, 48, 64, 65, 80, 96, 128, 256, 1024] {
16 let p = Params::paper(m);
17 println!(
18 "{:>5} {:>3} {:>4} {:>6} {:>6} {:>4} {:>8} {:>12.3e}",
19 m,
20 paper_r(m),
21 paper_half_width(m),
22 p.u,
23 p.v,
24 p.degree(),
25 p.window_bites(),
26 p.exception_fraction()
27 );
28 }
29 let t = paper_threshold_m();
30 let d = Params::paper(t).degree();
31 let axes = 2 * (t + d - 1);
32 println!(
33 "\nWindow first bites at m = {t} (D = {d}). One kernel level then uses about A = 2(m+D-1) = {axes} axes,"
34 );
35 println!("so a single level needs N >= 2^{axes} (rough lower estimate, not a figure from the paper).");
36
37 println!("\n== Exact repair check ==");
38 for (m, b) in [(6usize, 1.0f64), (8, 1.5), (10, 2.0)] {
39 let params = Params::with_half_width(m, b);
40 let w = 1usize << m;
41 let shifts = balanced_shifts(m, w);
42 let xs: Vec<Vec<Fp>> = (0..w)
43 .map(|i| (0..1u64 << m).map(|k| Fp::new((i as u64 + 1) * 1_000_003 + k * k)).collect())
44 .collect();
45
46 // Prediction alone (no repair) is wrong at the exceptions.
47 let ctr0 = OpCounter::default();
48 let wrong_rows = (0..w)
49 .filter(|&i| apply_predictor(¶ms, shifts[i], &xs[i], &ctr0) != apply_f_reference(m, &xs[i]))
50 .count();
51
52 let ctr = OpCounter::default();
53 let out = apply_f_repaired(¶ms, &xs, &shifts, None, &ctr);
54 let exact = xs.iter().zip(&out.rows).all(|(x, y)| *y == apply_f_reference(m, x));
55 println!(
56 "m={m:>2} window=[{},{}] D={} W={w}: prediction-only wrong rows {wrong_rows}/{w}, \
57 s={} (paper budget W/2m^3 = {}), repaired exact = {exact}, \
58 Q-calls={} (naive {}), spectral rows={}",
59 params.u,
60 params.v,
61 params.degree(),
62 out.s,
63 paper_exception_budget(w, m),
64 ctr.q(),
65 w * m,
66 ctr.spectral()
67 );
68 assert!(exact);
69 }
70 println!("\nNote: Q-calls are high because the predictor is expanded directly");
71 println!("(no matrix-root/routing). This checks correctness, not the paper's cost savings.");
72
73 println!("\n== Cyclic / abelian-group DFT via Newton + in-place Toeplitz (grids.tex) ==");
74 use log_fft::paper::grid::{naive_group_dft, newton::vandermonde, AxisPlan, GroupDft};
75 let cases: Vec<(usize, Option<u64>)> = vec![(17, None), (255, None), (1020, None), (4096, None), (1000, Some(3)), (777, Some(5))];
76 for (a, q) in cases {
77 let (plan, label) = match q {
78 None => (AxisPlan::dft(a), "DFT".to_string()),
79 Some(q) => (AxisPlan::geometric(a, Fp::new(q)), format!("V_a(q={q})")),
80 };
81 let x: Vec<Fp> = (0..a as u64).map(|i| Fp::new(i * 2654435761 + 1)).collect();
82 let mut scratch = vec![Fp::ZERO; a];
83 let y = plan.forward(&x, &mut scratch);
84 let v = vandermonde(a, plan.q);
85 let expect: Vec<Fp> = (0..a).map(|j| (0..a).fold(Fp::ZERO, |s, k| s + v[j][k] * x[k])).collect();
86 let ok = y == expect;
87 let back = plan.inverse(&y, &mut scratch) == x;
88 let restored = scratch.iter().all(|v| *v == Fp::ZERO);
89 println!(
90 "{label:>11} a={a:>5} b={:>5} factors={:<14} forward exact={ok} inverse exact={back} scratch restored={restored}",
91 plan.engine.dft.b,
92 format!("{:?}", plan.engine.dft.factors),
93 );
94 assert!(ok && back && restored);
95 }
96 let dims = [3usize, 5, 17, 4];
97 let g = GroupDft::new(&dims);
98 let x: Vec<Fp> = (0..g.len() as u64).map(|i| Fp::new(i * i + 9)).collect();
99 let exact = g.forward(&x) == naive_group_dft(&dims, &x);
100 println!("G = Z3 x Z5 x Z17 x Z4 (N={}): exact = {exact}", g.len());
101 assert!(exact);
102}Sourcepub fn window_bites(&self) -> bool
pub fn window_bites(&self) -> bool
True when the window is strictly narrower than the full count range
[0, m], that is, when the predictor really has degree below m.
Examples found in repository?
12fn main() {
13 println!("== Paper parameters (binary case) ==");
14 println!("{:>5} {:>3} {:>4} {:>6} {:>6} {:>4} {:>8} {:>12}", "m", "r", "B", "u", "v", "D", "D<m?", "exc.frac");
15 for m in [3, 8, 16, 32, 48, 64, 65, 80, 96, 128, 256, 1024] {
16 let p = Params::paper(m);
17 println!(
18 "{:>5} {:>3} {:>4} {:>6} {:>6} {:>4} {:>8} {:>12.3e}",
19 m,
20 paper_r(m),
21 paper_half_width(m),
22 p.u,
23 p.v,
24 p.degree(),
25 p.window_bites(),
26 p.exception_fraction()
27 );
28 }
29 let t = paper_threshold_m();
30 let d = Params::paper(t).degree();
31 let axes = 2 * (t + d - 1);
32 println!(
33 "\nWindow first bites at m = {t} (D = {d}). One kernel level then uses about A = 2(m+D-1) = {axes} axes,"
34 );
35 println!("so a single level needs N >= 2^{axes} (rough lower estimate, not a figure from the paper).");
36
37 println!("\n== Exact repair check ==");
38 for (m, b) in [(6usize, 1.0f64), (8, 1.5), (10, 2.0)] {
39 let params = Params::with_half_width(m, b);
40 let w = 1usize << m;
41 let shifts = balanced_shifts(m, w);
42 let xs: Vec<Vec<Fp>> = (0..w)
43 .map(|i| (0..1u64 << m).map(|k| Fp::new((i as u64 + 1) * 1_000_003 + k * k)).collect())
44 .collect();
45
46 // Prediction alone (no repair) is wrong at the exceptions.
47 let ctr0 = OpCounter::default();
48 let wrong_rows = (0..w)
49 .filter(|&i| apply_predictor(¶ms, shifts[i], &xs[i], &ctr0) != apply_f_reference(m, &xs[i]))
50 .count();
51
52 let ctr = OpCounter::default();
53 let out = apply_f_repaired(¶ms, &xs, &shifts, None, &ctr);
54 let exact = xs.iter().zip(&out.rows).all(|(x, y)| *y == apply_f_reference(m, x));
55 println!(
56 "m={m:>2} window=[{},{}] D={} W={w}: prediction-only wrong rows {wrong_rows}/{w}, \
57 s={} (paper budget W/2m^3 = {}), repaired exact = {exact}, \
58 Q-calls={} (naive {}), spectral rows={}",
59 params.u,
60 params.v,
61 params.degree(),
62 out.s,
63 paper_exception_budget(w, m),
64 ctr.q(),
65 w * m,
66 ctr.spectral()
67 );
68 assert!(exact);
69 }
70 println!("\nNote: Q-calls are high because the predictor is expanded directly");
71 println!("(no matrix-root/routing). This checks correctness, not the paper's cost savings.");
72
73 println!("\n== Cyclic / abelian-group DFT via Newton + in-place Toeplitz (grids.tex) ==");
74 use log_fft::paper::grid::{naive_group_dft, newton::vandermonde, AxisPlan, GroupDft};
75 let cases: Vec<(usize, Option<u64>)> = vec![(17, None), (255, None), (1020, None), (4096, None), (1000, Some(3)), (777, Some(5))];
76 for (a, q) in cases {
77 let (plan, label) = match q {
78 None => (AxisPlan::dft(a), "DFT".to_string()),
79 Some(q) => (AxisPlan::geometric(a, Fp::new(q)), format!("V_a(q={q})")),
80 };
81 let x: Vec<Fp> = (0..a as u64).map(|i| Fp::new(i * 2654435761 + 1)).collect();
82 let mut scratch = vec![Fp::ZERO; a];
83 let y = plan.forward(&x, &mut scratch);
84 let v = vandermonde(a, plan.q);
85 let expect: Vec<Fp> = (0..a).map(|j| (0..a).fold(Fp::ZERO, |s, k| s + v[j][k] * x[k])).collect();
86 let ok = y == expect;
87 let back = plan.inverse(&y, &mut scratch) == x;
88 let restored = scratch.iter().all(|v| *v == Fp::ZERO);
89 println!(
90 "{label:>11} a={a:>5} b={:>5} factors={:<14} forward exact={ok} inverse exact={back} scratch restored={restored}",
91 plan.engine.dft.b,
92 format!("{:?}", plan.engine.dft.factors),
93 );
94 assert!(ok && back && restored);
95 }
96 let dims = [3usize, 5, 17, 4];
97 let g = GroupDft::new(&dims);
98 let x: Vec<Fp> = (0..g.len() as u64).map(|i| Fp::new(i * i + 9)).collect();
99 let exact = g.forward(&x) == naive_group_dft(&dims, &x);
100 println!("G = Z3 x Z5 x Z17 x Z4 (N={}): exact = {exact}", g.len());
101 assert!(exact);
102}Sourcepub fn exception_fraction(&self) -> f64
pub fn exception_fraction(&self) -> f64
Exact fraction of shifts β ∈ F_2^m whose count falls outside the
window. It is the same for every frequency.
Examples found in repository?
12fn main() {
13 println!("== Paper parameters (binary case) ==");
14 println!("{:>5} {:>3} {:>4} {:>6} {:>6} {:>4} {:>8} {:>12}", "m", "r", "B", "u", "v", "D", "D<m?", "exc.frac");
15 for m in [3, 8, 16, 32, 48, 64, 65, 80, 96, 128, 256, 1024] {
16 let p = Params::paper(m);
17 println!(
18 "{:>5} {:>3} {:>4} {:>6} {:>6} {:>4} {:>8} {:>12.3e}",
19 m,
20 paper_r(m),
21 paper_half_width(m),
22 p.u,
23 p.v,
24 p.degree(),
25 p.window_bites(),
26 p.exception_fraction()
27 );
28 }
29 let t = paper_threshold_m();
30 let d = Params::paper(t).degree();
31 let axes = 2 * (t + d - 1);
32 println!(
33 "\nWindow first bites at m = {t} (D = {d}). One kernel level then uses about A = 2(m+D-1) = {axes} axes,"
34 );
35 println!("so a single level needs N >= 2^{axes} (rough lower estimate, not a figure from the paper).");
36
37 println!("\n== Exact repair check ==");
38 for (m, b) in [(6usize, 1.0f64), (8, 1.5), (10, 2.0)] {
39 let params = Params::with_half_width(m, b);
40 let w = 1usize << m;
41 let shifts = balanced_shifts(m, w);
42 let xs: Vec<Vec<Fp>> = (0..w)
43 .map(|i| (0..1u64 << m).map(|k| Fp::new((i as u64 + 1) * 1_000_003 + k * k)).collect())
44 .collect();
45
46 // Prediction alone (no repair) is wrong at the exceptions.
47 let ctr0 = OpCounter::default();
48 let wrong_rows = (0..w)
49 .filter(|&i| apply_predictor(¶ms, shifts[i], &xs[i], &ctr0) != apply_f_reference(m, &xs[i]))
50 .count();
51
52 let ctr = OpCounter::default();
53 let out = apply_f_repaired(¶ms, &xs, &shifts, None, &ctr);
54 let exact = xs.iter().zip(&out.rows).all(|(x, y)| *y == apply_f_reference(m, x));
55 println!(
56 "m={m:>2} window=[{},{}] D={} W={w}: prediction-only wrong rows {wrong_rows}/{w}, \
57 s={} (paper budget W/2m^3 = {}), repaired exact = {exact}, \
58 Q-calls={} (naive {}), spectral rows={}",
59 params.u,
60 params.v,
61 params.degree(),
62 out.s,
63 paper_exception_budget(w, m),
64 ctr.q(),
65 w * m,
66 ctr.spectral()
67 );
68 assert!(exact);
69 }
70 println!("\nNote: Q-calls are high because the predictor is expanded directly");
71 println!("(no matrix-root/routing). This checks correctness, not the paper's cost savings.");
72
73 println!("\n== Cyclic / abelian-group DFT via Newton + in-place Toeplitz (grids.tex) ==");
74 use log_fft::paper::grid::{naive_group_dft, newton::vandermonde, AxisPlan, GroupDft};
75 let cases: Vec<(usize, Option<u64>)> = vec![(17, None), (255, None), (1020, None), (4096, None), (1000, Some(3)), (777, Some(5))];
76 for (a, q) in cases {
77 let (plan, label) = match q {
78 None => (AxisPlan::dft(a), "DFT".to_string()),
79 Some(q) => (AxisPlan::geometric(a, Fp::new(q)), format!("V_a(q={q})")),
80 };
81 let x: Vec<Fp> = (0..a as u64).map(|i| Fp::new(i * 2654435761 + 1)).collect();
82 let mut scratch = vec![Fp::ZERO; a];
83 let y = plan.forward(&x, &mut scratch);
84 let v = vandermonde(a, plan.q);
85 let expect: Vec<Fp> = (0..a).map(|j| (0..a).fold(Fp::ZERO, |s, k| s + v[j][k] * x[k])).collect();
86 let ok = y == expect;
87 let back = plan.inverse(&y, &mut scratch) == x;
88 let restored = scratch.iter().all(|v| *v == Fp::ZERO);
89 println!(
90 "{label:>11} a={a:>5} b={:>5} factors={:<14} forward exact={ok} inverse exact={back} scratch restored={restored}",
91 plan.engine.dft.b,
92 format!("{:?}", plan.engine.dft.factors),
93 );
94 assert!(ok && back && restored);
95 }
96 let dims = [3usize, 5, 17, 4];
97 let g = GroupDft::new(&dims);
98 let x: Vec<Fp> = (0..g.len() as u64).map(|i| Fp::new(i * i + 9)).collect();
99 let exact = g.forward(&x) == naive_group_dft(&dims, &x);
100 println!("G = Z3 x Z5 x Z17 x Z4 (N={}): exact = {exact}", g.len());
101 assert!(exact);
102}Sourcepub fn paper_hoeffding_bound(m: usize) -> f64
pub fn paper_hoeffding_bound(m: usize) -> f64
The paper’s Hoeffding bound 2·exp(−2B²/m) on the exception fraction,
with B = paper_half_width(m).