nx_sum_pairwise_max.nx source
↩ module page · 31 lines · 1016 B
1// nx_sum_pairwise_max.nx -- AUTO-GENERATED from shape `array_accumulate_pair`.
2//
3// Shape: walks two arrays of length n in lockstep, accumulates a
4// single scalar. INIT is the starting accumulator; STEP is the per-
5// element update (may reference `acc`, `av`, `bv`, `i`).
6//
7// genealogy_id: synthesized_from_corpus
8// lineage_id: array_accumulate_pair
9// license: public_domain
10// complexity: O(n)
11
12// nx_safety_envelope:
13// intended_use: AUTO_APPLIED -- primitive-specific tuning queued
14// sil_target: SIL1
15// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail]
16// verdict: NOT_YET_EVALUATED
17
18import "nx_syscalls.nx"
19import "nx_tier.nx"
20
21func nx_sum_pairwise_max(a: *nx_int, b: *nx_int, n: nx_idx) -> nx_int {
22 var acc: nx_int = 0
23 var i: nx_idx = 0
24 while i < n {
25 let av: nx_int = a[i]
26 let bv: nx_int = b[i]
27 if av > bv { acc = acc + av } if av <= bv { acc = acc + bv }
28 i = i + 1
29 }
30 return acc
31}