code wiki / _hdl_build / _gamma_probe.nx

_gamma_probe.nx

buildroot/runtime/_hdl_build/_gamma_probe.nx

5154 B106 linesdepth 8pulls 15 transitivereach 0 importersview sourcekind probetopic gamma
docsdependenciesstructsconstsfunctions

about

_gamma_probe.nx -- DE-RISK the gamma kernel BEFORE building its emitter template (design-intelligence law: validate the hard passage in isolation, don't rush a multiday-bug door open). Computes Gamma(x) in plain f64 via the Stirling lnGamma series with recurrence pull-up, using the EXISTING authored log + exp kernels (kernel COMPOSITION proof), and compares against the known-good bigfloat oracle (bf_gamma_f64) at integer + half-integer grid points. If max_ulp is small, the GAMMA_STIRLING template is safe to author; if not, the probe NAMES the gap (which term count / which domain) -- no emitter built on an unvalidated approach. lnGamma(w) = (w-0.5)*ln(w) - w + 0.5*ln(2pi) + sum_k c_k / w^(2k-1) (w>=8) Gamma(x) = exp(lnGamma(x+m)) / ((x)(x+1)...(x+m-1)) pull up to w=x+m>=8 Uses the spec table _pm_gamma_spec.nx (sovereign consts). Durable: GAMMAPROBE row -> knowledge/status/math_engine.log. Exit 0 = approach validated (max_ulp<=8). license_tier: ORIGINAL

dependencies 10 imports · 0 importers

nx_syscalls.nx nx_f64.nx nx_f64_div.nx nx_f64_cvt.nx nx_bigfloat120.nx nx_bigfloat120_div.nx nx_bigfloat120_gamma.nx _pm_gamma_spec.nx _pe_f64log.nx _pe_f64sinhcosh.nx _gamma_probe.nx

imports: nx_syscalls.nxnx_f64.nxnx_f64_div.nxnx_f64_cvt.nxnx_bigfloat120.nxnx_bigfloat120_div.nxnx_bigfloat120_gamma.nx_pm_gamma_spec.nx_pe_f64log.nx_pe_f64sinhcosh.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gp_p sys_write sys_mmap pm_gamma_spec_fill bf_new sys_mmap ↻ bf_gamma_f64 bf_new ↻ bf_set_f64 bfg_gamma_pos bf_new ↻ bf_set_int bf_copy bf_cmp bf_is_zero bf_mul bf_is_zero ↻ bf_copy ↻ sys_mmap ↻ bf_add bf_is_zero ↻ bf_copy ↻ sys_mmap ↻ bf_shr2 bf_norm bfg_lngamma_big bf_new ↻ bf_set_int ↻ bf_copy ↻ bf_sub bf_is_zero ↻ bf_copy ↻ sys_mmap ↻ bf_shr2 ↻ bf_norm ↻ bfg_ln_big bf_new ↻ bf_copy ↻ bf_set_int ↻

structs

none

consts

none

functions

24func gp_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
25func gp_f(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 1: main calls 1: sys_write
26func gp_n(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
28func gp_exp(v: i64) -> i64 { return nx_f64_add(nx_f64_cosh(v), nx_f64_sinh(v)) }
30func gp_gamma(x: i64, c: *i64) -> i64
66func gp_ulp(a: i64, b: i64) -> i64 { if a >= b { return a - b } return b - a }
called by 1: main
67func main() -> i64