code wiki / _hdl_build / nx_synth_fit.nx

nx_synth_fit.nx

buildroot/runtime/_hdl_build/nx_synth_fit.nx

3441 B59 linesdepth 2pulls 2 transitivereach 7 importersview sourcekind librarytopic synth
docsdependenciesstructsconstsfunctions

about

nx_synth_fit.nx -- shared synthesis-fit CORE (no main): the power-sum basis model + iterated-local-search coefficient fit + keep-if-generalizes, used by the grammar-expansion / primitive-miner / NL-miner gates. NO LLM. All identifiers sf_-prefixed so importers never collide. (DRY: extracted from nx_grammar_expand / nx_primitive_miner; future migration of those two to import this is the clean follow-up.) license_tier: ORIGINAL

dependencies 1 imports · 7 importers

nx_syscalls.nx nx_synth_fit.nx nx_authoring_triangulation.nx nx_autonomy_create.nx nx_autonomy_expand.nx nx_autonomy_grow_loop.nx nx_autonomy_selfgrow.nx nx_nl_concept_miner_gate.nx nx_wakesleep_scale_gate.nx

imports: nx_syscalls.nx

imported by: nx_authoring_triangulation.nxnx_autonomy_create.nxnx_autonomy_expand.nxnx_autonomy_grow_loop.nxnx_autonomy_selfgrow.nxnx_nl_concept_miner_gate.nxnx_wakesleep_scale_gate.nx

structs

none

consts

6const K_MAGIC_1103515245: i64 = 1103515245
7const K_MAGIC_12345: i64 = 12345
8const K_MAGIC_2147483647: i64 = 2147483647
9const K_MAGIC_300000: i64 = 300000

functions

11func sf_lcg(st: *i64) -> i64 { st[0]=((K_MAGIC_1103515245*st[0])+K_MAGIC_12345)&K_MAGIC_2147483647; return st[0] }
called by 2: sf_rand_coefsf_fit
12func sf_rand_coef(st: *i64) -> i64 { return (0-9)+(sf_lcg(st)%19) } // coeff in [-9,9]
called by 1: sf_fit calls 1: sf_lcg
13func sf_pow_i(i: i64, k: i64) -> i64 { var r: i64=1; var c: i64=0; while c<k { r=r*i; c=c+1 } return r }
called by 2: sf_powsummain
14func sf_powsum(k: i64, x: i64) -> i64 { var s: i64=0; var i: i64=1; while i<=x { s=s+sf_pow_i(i,k); i=i+1 } return s }
16func sf_model(c: *i64, candk: i64, x: i64) -> i64
called by 3: mainsf_merrsf_keep calls 1: sf_powsum
21func sf_merr(c: *i64, candk: i64, xs: *i64, ys: *i64, n: i64) -> i64
called by 1: sf_fit calls 1: sf_model
27func sf_fit(candk: i64, xs: *i64, ys: *i64, n: i64, seed: i64, best: *i64) -> i64
55func sf_keep(candk: i64, xs: *i64, ys: *i64, n: i64, hx0: i64, hy0: i64, hx1: i64, hy1: i64) -> i64