nx_intlog.nx
buildroot/runtime/nx_intlog.nx
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
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
| 67 | const RRF_K_STD: i64 = 60 |
| 68 | const BM25Q_K_Q10: i64 = 1228 |
| 84 | const CS_SIDE_BELOW: i64 = 0 |
| 85 | const CS_SIDE_ABOVE: i64 = 1 |
| 86 | const 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
| 8 | func ilog2_1024(x0: i64) -> i64 |
| 33 | func idf_q10(bign: i64, nt: i64) -> i64 |
| 41 | func tfsat_q10(tf: i64) -> i64 called by 1: main |
| 49 | func tfnorm_q10(tf: i64, normq10: i64) -> i64 |
| 69 | func qtfsat_q10(qtf: i64) -> i64 |
| 75 | func idf_bm25q(idf: i64, qtf: i64) -> i64 |
| 87 | func cs_crossover(corpus_tokens: i64, crossover_tokens: i64) -> i64 |