Sort.run.sums: def of bend-parallel@0.1.0.0 Import: import bend-parallel@0.1.0.0/sort.bend as Sort Lines 379-395 of bend-parallel@0.1.0.0/sort.bend: https://jend.leeeet.dev/read.txt?path=bend-parallel@0.1.0.0/sort.bend&start_line=379&end_line=395 import Base import bend-parallel@0.1.0.0/scan.bend as Scan import bend-parallel@0.1.0.0/histogram.bend as Hist # Pass 2a: each group's running column sums (Hist.grp), then 2b. For a # small table (lo), no 2a: 2b sums each column over all the rows. def run.sums(lo: Bool, +d: Nat, +e: Nat, +kb: Nat, +k: U32, pm: Array, cs: Array, os: Array, r: Hist.Two) -> Array & Bufs: match lo: case True{}: Hist.Two{ks, t} = r +g = Nat.min(d, kb) run.scan(True{}, d, e, kb, k, ks, pm, sums(g, False{}, 0, Nat.sub(kb, g), k, 0, U32.shln(1, kb), U32.to_nat((U32.shln(1, d) - 1 : U32)), Array.fork(U32, t), Array.fork(U32, Hist.fit.eq(kb, Array.size(U32, cs))), Array.fork(U32, Hist.fit.eq(kb, Array.size(U32, os))))) case False{}: Hist.Two{ks, t} = r +g = Nat.min(d, kb) +h = Scan.half(d) run.tots(d, e, kb, k, ks, pm, cs, os, Hist.grp(Nat.add(h, g), True{}, 0, g, Nat.sub(kb, g), Nat.sub(d, h), kb, k, Array.fork(U32, t))) Uses (21): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.fork https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.size https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.min https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.shln https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_nat https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/histogram.bend&name=Two https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/histogram.bend&name=fit.eq https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/histogram.bend&name=grp https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/scan.bend&name=half https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=Bufs https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=run.scan https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=run.tots https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=sums