code wiki / _hdl_build / nx_evo_lcm.nx

nx_evo_lcm.nx

buildroot/runtime/_hdl_build/nx_evo_lcm.nx

7818 B158 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic evo
docsdependenciesstructsconstsfunctions

about

nx_evo_lcm.nx -- COMPOUNDING derivation toward self-sufficiency ("adam+eve making kids, their kids making kids"): derive lcm by COMPOSING the already-DERIVED gcd (a prior kid) as a primitive. lcm(a,b) = a*b / gcd(a,b). The op-set gives the search the inputs a,b, multiply, and a DIV-by-gcd op that calls gcd_evolved -- the structure the SEARCH derived earlier (nx_evo_gcd, body [1 3 0 2]), inlined verbatim. So the derived gcd (KID) becomes the building block for deriving lcm (GRANDKID) -- the lineage growing on itself, not a one-off. Self-verifies the derived lcm vs true lcm across a grid. I author the MACHINE (substrate); the SEARCH composes lcm; full self-sufficiency (team authors the machine + an unattended loop) is the horizon this steps toward. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_evo_lcm.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap lm_randfill lm_rand lcm_fit lm_a lm_b lcm_eval gcd_evolved lm_abs lcm_true lm_euclid lm_tourney lm_rand ↻ lm_rand ↻ lcm_eval ↻ lm_a ↻ lm_b ↻ lcm_true ↻ lm_p sys_write lm_pn nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap sys_exit

structs

none

consts

12const LCM_MAGIC_2862933555777941757: i64 = 2862933555777941757
13const LCM_MAGIC_3037000493: i64 = 3037000493
14const LCM_MAGIC_2000000: i64 = 2000000
15const LCM_MAGIC_1000000: i64 = 1000000
16const LCM_MAGIC_2654435761: i64 = 2654435761
17const LCM_MAGIC_12345: i64 = 12345
18const LCM_MAGIC_1000000000: i64 = 1000000000
20const LCM_LEN: i64 = 4
21const EVO_P: i64 = 256
22const EVO_G: i64 = 2000
23const EVO_T: i64 = 5
24const NTRAIN: i64 = 6
25const NHELD: i64 = 4

functions

27func lm_rand(state: *i64) -> i64 { state[0] = state[0] * LCM_MAGIC_2862933555777941757 + LCM_MAGIC_3037000493; return (state[0] >> 17) & 0x3fffffff }
28func lm_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x }
called by 1: lcm_fit
31func gcd_evolved(a: i64, b: i64) -> i64
called by 1: lcm_eval
45func lm_euclid(a: i64, b: i64) -> i64 { var x: i64 = a; var y: i64 = b; while y != 0 { let t: i64 = x % y; x = y; y = t } return x }
called by 1: lcm_true
46func lcm_true(a: i64, b: i64) -> i64 { let g: i64 = lm_euclid(a, b); if g == 0 { return 0 } return (a * b) / g }
called by 2: lcm_fitmain calls 1: lm_euclid
49func lm_a(i: i64) -> i64 { if i == 0 { return 6 } if i == 1 { return 4 } if i == 2 { return 3 } if i == 3 { return 8 } if i == 4 { return 9 } if i == 5 { return 10 } if i == 6 { return 7 } if i == 7 { return 12 } if i == 8 { return 5 } return 14 }
called by 2: lcm_fitmain
50func lm_b(i: i64) -> i64 { if i == 0 { return 4 } if i == 1 { return 6 } if i == 2 { return 5 } if i == 3 { return 12 } if i == 4 { return 6 } if i == 5 { return 15 } if i == 6 { return 3 } if i == 7 { return 8 } if i == 8 { return 10 } return 21 }
called by 2: lcm_fitmain
53func lcm_eval(pop: *i64, base: i64, a: i64, b: i64) -> i64
called by 2: lcm_fitmain calls 1: gcd_evolved
67func lcm_fit(pop: *i64, base: i64) -> i64
called by 1: main calls 5: lm_alm_blcm_evallm_abslcm_true
80func lm_randfill(pop: *i64, base: i64, state: *i64) -> i64 { var j: i64 = 0; while j < LCM_LEN { pop[base + j] = lm_rand(state) % 6; j = j + 1 } return 0 }
called by 1: main calls 1: lm_rand
81func lm_tourney(fit: *i64, state: *i64) -> i64
called by 1: main calls 1: lm_rand
86func lm_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
91func lm_pn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
93func main() -> i64