code wiki / _hdl_build / nx_intfp_log_gate.nx
nx_intfp_log_gate.nx
buildroot/runtime/_hdl_build/nx_intfp_log_gate.nx
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
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
structs
| none |
consts
| 10 | const S: i64 = 1048576 // Q20 |
functions
| 7 | func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 8 | func 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 } |
| 14 | func fp_log(xq: i64) -> i64 |
| 26 | func showln(name: *u8, xq: i64, want_milli: i64) -> i64 |
| 31 | func main() -> i64 |