nx_vec_index.nx
buildroot/runtime/nx_vec_index.nx
about
nx_vec_index.nx -- R3 rung 1: a SOVEREIGN integer dense-vector store + exact cosine k-NN = the MILVUS/ANN
replacement (deep-searcher rides Milvus; depstack census graded VDB=BEHIND). No-float: vectors are integer,
normalized to fixed scale S with fixed-point precision P via integer isqrt (Newton), similarity = integer
dot of unit vectors -> cosine in PERMILLE (0..1000, sign-preserving). Exact brute-force k-NN (correct;
approximate HNSW is a SCALE optimization, deferred). HONEST SCOPE: this is the STORE+SEARCH half. The trained
EMBEDDER that turns text->vector (the Jina-Embeddings replacement, EMB axis) is R3b -- distributional/trained,
NOT built here. main() = KAT gate with a negative control (an orthogonal doc must NOT outrank a parallel one).
license_tier: ORIGINAL expect_exit: 0
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 K_MAGIC_1000000: i64 = 1000000 |
| 11 | const K_MAGIC_8192: i64 = 8192 |
functions
| 13 | func vw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 14 | func vn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 } |
| 17 | func isqrt(n: i64) -> i64 called by 1: vec_normalize |
| 26 | func vec_dot(a: *i64, ao: i64, b: *i64, bo: i64, d: i64) -> i64 |
| 32 | func vec_norm2(a: *i64, ao: i64, d: i64) -> i64 called by 1: vec_normalize |
| 39 | func vec_normalize(src: *i64, so: i64, dst: *i64, doff: i64, d: i64, S: i64, P: i64) -> i64 |
| 49 | func cos_permille(u: *i64, ao: i64, bo: i64, d: i64, S: i64) -> i64 |
| 55 | func vidx_top1(unit: *i64, ndoc: i64, d: i64, q: *i64, S: i64) -> i64 |
| 67 | func chk(label: *u8, got: i64, exp: i64, tot: *i64) -> i64 |
| 73 | func main() -> i64 |