code wiki / (root) / nx_dot_product.nx

nx_dot_product.nx source

↩ module page · 25 lines · 688 B

1// nx_dot_product.nx -- integer vector inner product. 2// 3// genealogy_id: gibbs_1881_vector_analysis 4// lineage_id: linear_algebra 5// license: public_domain 6// complexity: O(n). 7 8// nx_safety_envelope: 9// intended_use: AUTO_APPLIED -- primitive-specific tuning queued 10// sil_target: SIL1 11// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail] 12// verdict: NOT_YET_EVALUATED 13 14import "nx_syscalls.nx" 15import "nx_tier.nx" 16 17func nx_dot_product(a: *nx_int, b: *nx_int, n: nx_idx) -> nx_int { 18 var acc: nx_int = 0 19 var i: nx_idx = 0 20 while i < n { 21 acc = acc + a[i] * b[i] 22 i = i + 1 23 } 24 return acc 25}