nx_dynaoracle_gate.nx
buildroot/runtime/nx_dynaoracle_gate.nx
about
nx_dynaoracle_gate.nx -- GATE for the shared ringdown estimator and the video oracle's derived
constants.
WHY THE FIXTURE IS AN ANALYTIC OSCILLATOR AND NOT A VIDEO CLIP. A gate whose fixture is a real
clip can only assert that today's answer equals yesterday's answer -- it has no ground truth, so
it detects drift and CANNOT detect being wrong. Here the fixture is a mass-spring-damper the gate
integrates itself, so the TRUE natural frequency and damping ratio are known in closed form from
k and c: w0 = sqrt(k/m), zeta = c/(2*sqrt(k*m)), wd = w0*sqrt(1-zeta^2). The teeth then ask
whether rd_analyze RECOVERS numbers it was never told. That is an oracle, not a snapshot.
EVERY TOLERANCE HERE IS DERIVED, NOT PICKED:
* FREQUENCY: rd_analyze times a period by counting whole SAMPLES between zero crossings, so a
plus-or-minus-one-sample error bounds the relative frequency error at 1/P where P is the
period in samples. The tooth computes that bound from the fixture's own period.
* DAMPING: rd_zeta_permil goes through rd_log2_q16, whose own header declares a worst error of
about 0.086 in log2 inside an octave. That propagates as ln-error 0.086*ln2 = 0.0596, and for
a lightly damped decay zeta is about delta/(2*pi), giving a bound near 9.5 permil. The tooth
computes that from the declared constant instead of hard-coding the answer.
A tolerance chosen after seeing the result is the defect this estate refuses; a tolerance derived
from a declared imprecision is a contract.
license_tier: ORIGINAL
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.nxnx_ringdown_lib.nxnx_motion.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 28 | const DG_Q16: i64 = 65536 |
| 29 | const DG_PERMIL: i64 = 1000 |
| 30 | const DG_NSAMP: i64 = 512 |
| 31 | const DG_DT_US: i64 = 1000 |
| 37 | const DG_LOG2_ERR_PERMIL: i64 = RD_LOG2_ERR_PERMIL |
| 38 | const DG_LN2_PERMIL: i64 = RD_LN2_PERMIL |
| 39 | const DG_TWOPI_PERMIL: i64 = RD_TWOPI_PERMIL |
| 48 | const DG_GRID_NSAMP: i64 = 16384 |
| 53 | const DG_GRID_DT_DIV: i64 = 1000 |
| 54 | const DG_GRID_K0: i64 = 16 |
| 55 | const DG_GRID_K_STEP: i64 = 4 |
| 56 | const DG_GRID_NK: i64 = 3 |
| 57 | const DG_GRID_NZ: i64 = 6 |
| 68 | const DG_GRID_X0: i64 = 1000000 |
| 72 | const DG_GRID_MIN_PEAK_QUANTA: i64 = 1000 |
| 82 | const DG_GRID_QUANT: i64 = DG_GRID_MIN_PEAK_QUANTA |
| 85 | const DG_GRID_MIN_HALVES: i64 = 2 |
| 95 | const DG_TOL_PROBE_A: i64 = 1000000 |
| 96 | const DG_TOL_PROBE_B: i64 = 1000 |
| 97 | const DG_TOL_PROBE_B_SMALL: i64 = 10 |
| 98 | const DG_TOL_PROBE_HALVES_LONG: i64 = 16 |
| 99 | const DG_TOL_PROBE_HALVES_SHORT: i64 = 2 |
| 101 | const DG_GRID_Z_LINEAR_LIMIT: i64 = 50 |
| 102 | const DG_GRID_Z_LIGHT: i64 = 100 |
| 103 | const DG_GRID_Z_VIDEO_FIXTURE: i64 = 200 |
| 104 | const DG_GRID_Z_TISSUE_BAND_LOW: i64 = 350 |
| 105 | const DG_GRID_Z_TISSUE_BAND_MID: i64 = 450 |
| 106 | const DG_GRID_Z_TISSUE_BAND_HIGH: i64 = 600 |
| 117 | const DG_GRID_TARGET_SPP: i64 = 15 |
| 118 | const DG_EULER_ZETA_DEN: i64 = 2 |
| 119 | const DG_EULER_PER_DEN: i64 = 24 |
| 125 | const DG_LOBE_N: i64 = 128 |
| 126 | const DG_LOBE_AMP0: i64 = 1024 |
| 127 | const DG_LOBE_DECAY_DIV: i64 = 2 |
| 128 | const DG_LOBE_HEAD: i64 = 8 // the truncated opening lobe, before the first crossing |
| 129 | const DG_LOBE_LEN: i64 = 12 // the periodic half period |
| 130 | const DG_LOBE_ODD: i64 = 20 // the intruder: eight samples off, far beyond a one-sample window |
functions
| 132 | func dg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } called by 1: main |
| 136 | func dg_sim(sig: *i64, n: i64, k_q16: i64, c_q16: i64, x0_q16: i64, dt_q16: i64) -> i64 called by 1: main |
| 153 | func dg_sim_lobes(sig: *i64, n: i64, l0: i64, l1: i64, l2: i64, l3: i64) -> i64 called by 1: main |
| 177 | func dg_sim_rigid(sig: *i64, n: i64) -> i64 called by 1: main |
| 183 | func main(argc: i64, argv: *i64) -> i64 |