Skip to content

Commit 8b686ab

Browse files
committed
docs(witness): align example cost model with corrected module doc (CodeRabbit #528)
The example crates/perturbation-sim/examples/witness.rs still described the wave path as O(N) per arc; bring it in line with the module-doc correction — per-arc is O(N log N) as implemented (the arc is transformed), narrowing to O(N) only for precomputed/structured arc spectra; the amortized quantity is the single field transform. Example builds; fmt clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CcpLeEC3XK8Eye53GKBVvi
1 parent bb3cd5c commit 8b686ab

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

crates/perturbation-sim/examples/witness.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
//!
44
//! Builds the per-bus inertia-buffer field, then reads three witness arcs both ways:
55
//! the particle walk (`O(hops)` per arc) and the standing wave (one `field_spectrum`
6-
//! transform, then `O(N)` per arc). They agree to floating point — and the wave form
7-
//! amortizes one transform across all arcs.
6+
//! transform reused across all arcs). They agree to floating point. As implemented,
7+
//! each arc is itself transformed, so the per-arc cost is `O(N log N)` (it narrows to
8+
//! `O(N)` only when the arc spectrum is precomputed or the arc is structured/sparse);
9+
//! the amortized quantity is the one **field** transform, not the per-arc dot.
810
//!
911
//! Run: cargo run --release --manifest-path crates/perturbation-sim/Cargo.toml \
1012
//! --example witness
@@ -43,7 +45,8 @@ fn main() {
4345
("alternating", &alt),
4446
];
4547

46-
// Wave view: transform the field ONCE; every arc is then an O(N) read off it.
48+
// Wave view: transform the field ONCE, then reuse the spectrum across all arcs
49+
// (each arc still transformed → O(N log N) per arc; O(N) only if precomputed).
4750
let spectrum = field_spectrum(&field);
4851

4952
println!("witness arc as a standing wave — particle (walk) vs wave (Parseval)\n");
@@ -62,7 +65,8 @@ fn main() {
6265
}
6366
println!(
6467
"\n max |particle − wave| = {max_err:.2e} (Parseval: Hᵀ H = N·I, exact up to fp).\n \
65-
particle = O(hops) pointer-chase per arc; wave = O(N log N) once + O(N) per arc.\n \
68+
particle = O(hops) pointer-chase per arc; wave = O(N log N) field transform once,\n \
69+
reused across all arcs (each arc O(N log N) as written; O(N) only if precomputed).\n \
6670
The standing wave IS the witness arc — evaluated all at once, no chain walk.\n \
6771
(Demonstration in perturbation-sim; the contract witness_table evaluator is the\n \
6872
separate gated step — the SoA spine is additive-only behind the iron rules.)"

0 commit comments

Comments
 (0)