code wiki / (root) / nx_dynaoracle_gate.nx

nx_dynaoracle_gate.nx

buildroot/runtime/nx_dynaoracle_gate.nx

34713 B577 linesdepth 6pulls 9 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gate_verdict.nx nx_ringdown_lib.nx nx_motion.nx nx_dynaoracle_gate.nx

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

main gv_head gv_puts sys_write gv_ctr sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_mmap ↻ dg_sim gv_check gv_puts ↻ dg_abs rd_analyze rd_abs rd_span_fn_tol_permil rd_zeta_permil_span rd_ln_q16 rd_log2_q16 rd_isqrt rd_span_zeta_tol_permil rd_zeta_permil rd_zeta_permil_span ↻ rd_isqrt ↻ dg_sim_rigid rd_span_zeta_tol_permil ↻ rd_zeta_permil_span ↻ rd_zeta_permil ↻

structs

none

consts

28const DG_Q16: i64 = 65536
29const DG_PERMIL: i64 = 1000
30const DG_NSAMP: i64 = 512
31const DG_DT_US: i64 = 1000
37const DG_LOG2_ERR_PERMIL: i64 = RD_LOG2_ERR_PERMIL
38const DG_LN2_PERMIL: i64 = RD_LN2_PERMIL
39const DG_TWOPI_PERMIL: i64 = RD_TWOPI_PERMIL
48const DG_GRID_NSAMP: i64 = 16384
53const DG_GRID_DT_DIV: i64 = 1000
54const DG_GRID_K0: i64 = 16
55const DG_GRID_K_STEP: i64 = 4
56const DG_GRID_NK: i64 = 3
57const DG_GRID_NZ: i64 = 6
68const DG_GRID_X0: i64 = 1000000
72const DG_GRID_MIN_PEAK_QUANTA: i64 = 1000
82const DG_GRID_QUANT: i64 = DG_GRID_MIN_PEAK_QUANTA
85const DG_GRID_MIN_HALVES: i64 = 2
95const DG_TOL_PROBE_A: i64 = 1000000
96const DG_TOL_PROBE_B: i64 = 1000
97const DG_TOL_PROBE_B_SMALL: i64 = 10
98const DG_TOL_PROBE_HALVES_LONG: i64 = 16
99const DG_TOL_PROBE_HALVES_SHORT: i64 = 2
101const DG_GRID_Z_LINEAR_LIMIT: i64 = 50
102const DG_GRID_Z_LIGHT: i64 = 100
103const DG_GRID_Z_VIDEO_FIXTURE: i64 = 200
104const DG_GRID_Z_TISSUE_BAND_LOW: i64 = 350
105const DG_GRID_Z_TISSUE_BAND_MID: i64 = 450
106const DG_GRID_Z_TISSUE_BAND_HIGH: i64 = 600
117const DG_GRID_TARGET_SPP: i64 = 15
118const DG_EULER_ZETA_DEN: i64 = 2
119const DG_EULER_PER_DEN: i64 = 24
125const DG_LOBE_N: i64 = 128
126const DG_LOBE_AMP0: i64 = 1024
127const DG_LOBE_DECAY_DIV: i64 = 2
128const DG_LOBE_HEAD: i64 = 8 // the truncated opening lobe, before the first crossing
129const DG_LOBE_LEN: i64 = 12 // the periodic half period
130const DG_LOBE_ODD: i64 = 20 // the intruder: eight samples off, far beyond a one-sample window

functions

132func dg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 1: main
136func dg_sim(sig: *i64, n: i64, k_q16: i64, c_q16: i64, x0_q16: i64, dt_q16: i64) -> i64
called by 1: main
153func dg_sim_lobes(sig: *i64, n: i64, l0: i64, l1: i64, l2: i64, l3: i64) -> i64
called by 1: main
177func dg_sim_rigid(sig: *i64, n: i64) -> i64
called by 1: main
183func main(argc: i64, argv: *i64) -> i64