code wiki / _hdl_build / nx_intfp_log_gate.nx

nx_intfp_log_gate.nx

buildroot/runtime/_hdl_build/nx_intfp_log_gate.nx

3336 B54 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/prooftopic intfp
docsdependenciesstructsconstsfunctions

about

nx_intfp_log_gate.nx -- integer natural LOG (fp_log) in Q20, completing the sovereign transcendental set (exp, rsqrt, log all integer, no float). log(x) = log2(x)*ln2 ; log2(x) = e + log2(m) where x=2^e*m, m in [1,2), and log2(1+u) via a quartic minimax poly. Enables: true in-stack cross-entropy/perplexity VALUES (not just gradients), DPO softplus, eval loss. Verified vs known ln() values; then a cross-entropy-value demo. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_intfp_log_gate.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main w sys_write showln fp_log w ↻ wsi sys_write ↻ sys_mmap fp_log ↻ wsi ↻

structs

none

consts

10const S: i64 = 1048576 // Q20

functions

7func w(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 2: showlnmain calls 1: sys_write
8func wsi(v: i64) -> i64 { if v<0 { sys_write(1,"-" as *u8,1); v=0-v } var m: i64=v; if m==0 { sys_write(1,"0" as *u8,1); return 0 } let t: *u8=sys_mmap(24); var k: i64=0; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} let o: *u8=sys_mmap(24); var q: i64=k-1; var i: i64=0; while q>=0{o[i]=t[q];i=i+1;q=q-1} sys_write(1,o,i); return 0 }
called by 2: showlnmain calls 2: sys_writesys_mmap
14func fp_log(xq: i64) -> i64
called by 2: showlnmain
26func showln(name: *u8, xq: i64, want_milli: i64) -> i64
called by 1: main calls 3: fp_logwwsi
31func main() -> i64