def pacc

bendtorch@1.3.0.0 · main.bend:2489

import bendtorch@1.3.0.0/main.bend as Bendtorch
import Base

2489# o[j·c + d] += a[0·t + j]·b[0·bs + bc + d] + ... + a[(t-1)·t + j]·b[(t-1)·bs + bc + d], for idx = j·c + d from idx on
2490# (dK += Gᵀ·Q and dV += Pᵀ·dO): each sum left to right from +0.0, then added into the group's running sum
2491def pacc(left: Nat, +idx: U32, +c: U32, +t: Nat, +bs: U32, +bc: U32, o: Array<F32>, r: D2) -> PO:
2492  match left r:
2493    case 0n D2{a, b, +s}:
2494      PO{a, b, acc_set(idx, s, Array.get(F32, o, idx))}
2495    case 1n+n D2{a, b, +s}:
2496      pacc(n, (idx + 1 : U32), c, t, bs, bc, acc_set(idx, s, Array.get(F32, o, idx)), dot0(t, U32.div((idx + 1 : U32), c), (bc + U32.mod((idx + 1 : U32), c) : U32), U32.from_nat(t), bs, a, b))

Uses (13)

Used by (2)