def MatT.sum

bend-tensors@0.0.0.2 · bend_tensors.bend:923

import bend-tensors@0.0.0.2/bend_tensors.bend as BendTensors
import Base

923# the sum of every cell
924def MatT.sum(+r: Nat, +c: Nat, m: MatT(r, c)) -> F32:
925  match r c:
926    case 0n 0n:
927      MatB{b} = m
928      Blk.sum(b)
929    case 1n+p 0n:
930      MatR{t, b} = m
931      x y = MatT.sum(p, 0n, t) MatT.sum(p, 0n, b)
932      (x + y : F32)
933    case 0n 1n+q:
934      MatC{l, r2} = m
935      x y = MatT.sum(0n, q, l) MatT.sum(0n, q, r2)
936      (x + y : F32)
937    case 1n+p 1n+q:
938      MatQ{a, b, c2, d} = m
939      w x y z = MatT.sum(p, q, a) MatT.sum(p, q, b) MatT.sum(p, q, c2) MatT.sum(p, q, d)
940      ((w + x) + (y + z) : F32)

Uses (9)

Used by (1)