def array_sum

bendtorch-core@0.1.0.0 · src/tensor/reduction.bend:82

import bendtorch-core@0.1.0.0/src/tensor/reduction.bend as Reduction
import Base

82# The first `fuel` words of the array from slot `cursor`, added to
83# `accumulator` left to right: the F32 adds of `natural_sum_loop`, in the
84# same order.
85def array_sum(fuel: Nat, +cursor: Nat, accumulator: F32, array: Array<F32>) -> F32 & Array<F32>:
86  match fuel:
87    case 0n:
88      (accumulator, array)
89    case 1n+rest:
90      array_run(rest, cursor, accumulator, Array.get(F32, array, U32.from_nat(cursor)))

Uses (8)

Used by (7)