code wiki / (root) / nx_intlog.nx

nx_intlog.nx

buildroot/runtime/nx_intlog.nx

5374 B92 linesdepth 2pulls 2 transitivereach 89 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_intlog.nx -- INTEGER fixed-point base-2 logarithm (no floats anywhere -- the ecosystem's no-float doctrine). ilog2_1024(x) returns round(1024 * log2(x)) for x >= 1 via msb + 10 mantissa-squaring refinement steps (each step decides one fractional bit; y stays < 2^17 so y*y < 2^34 -- no overflow). The BM25/IDF ranking rung composes this: idf_q10(N, n_t) = ilog2_1024(N+1) - ilog2_1024(n_t) >= 0-ish, clamped at 0 (a term in every doc carries ~no signal -- correct BM25 behavior). license_tier: ORIGINAL

dependencies 1 imports · 9 importers

nx_syscalls.nx nx_intlog.nx nx_abstat_lib.nx nx_beir_eval.nx nx_crawl_sufficiency.nx nx_didyoumean.nx nx_docportal_search_seg.nx nx_intlog_gate.nx nx_logadd_lib.nx nx_search_census.nx nx_web_relevance_bench.nx

imports: nx_syscalls.nx

imported by: nx_abstat_lib.nxnx_beir_eval.nxnx_crawl_sufficiency.nxnx_didyoumean.nxnx_docportal_search_seg.nxnx_intlog_gate.nxnx_logadd_lib.nxnx_search_census.nxnx_web_relevance_bench.nx

structs

none

consts

67const RRF_K_STD: i64 = 60
68const BM25Q_K_Q10: i64 = 1228
84const CS_SIDE_BELOW: i64 = 0
85const CS_SIDE_ABOVE: i64 = 1
86const CS_SIDE_UNMEASURED: i64 = 0 - 1 // THREE STATES, NOT TWO (the contract nx_qrels_bench carried first, 2026-09-04): an unmeasured corpus or threshold can never read BELOW -- abstain, never acquit

functions

8func ilog2_1024(x0: i64) -> i64
33func idf_q10(bign: i64, nt: i64) -> i64
41func tfsat_q10(tf: i64) -> i64
called by 1: main
49func tfnorm_q10(tf: i64, normq10: i64) -> i64
69func qtfsat_q10(qtf: i64) -> i64
called by 2: idf_bm25qmain
75func idf_bm25q(idf: i64, qtf: i64) -> i64
87func cs_crossover(corpus_tokens: i64, crossover_tokens: i64) -> i64
called by 3: mainqb_mainmain