def MatT.map

bend-tensors@0.0.0.2 · bend_tensors.bend:725

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

725def MatT.map(~f: F32 -> F32, +r: Nat, +c: Nat, m: MatT(r, c)) -> MatT(r, c):
726  match r c:
727    case 0n 0n:
728      MatB{b} = m
729      MatB{Blk.map(~f, b)}
730    case 1n+p 0n:
731      MatR{t, b} = m
732      x y = MatT.map(~f, p, 0n, t) MatT.map(~f, p, 0n, b)
733      MatR{x, y}
734    case 0n 1n+q:
735      MatC{l, r2} = m
736      x y = MatT.map(~f, 0n, q, l) MatT.map(~f, 0n, q, r2)
737      MatC{x, y}
738    case 1n+p 1n+q:
739      MatQ{a, b, c2, d} = m
740      w x y z = MatT.map(~f, p, q, a) MatT.map(~f, p, q, b) MatT.map(~f, p, q, c2) MatT.map(~f, p, q, d)
741      MatQ{w, x, y, z}

Uses (8)

Used by (2)