def MatT.matmul.sq

bend-tensors@0.0.0.2 · bend_tensors.bend:828

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

828# a * b for square operands of one depth: the same recursion with one
829# depth riding instead of three, which measures 3x faster per node
830def MatT.matmul.sq(+d: Nat, +a: MatT(d, d), +b: MatT(d, d)) -> MatT(d, d):
831  match d:
832    case 0n:
833      MatB{x} = a
834      MatB{y} = b
835      MatB{Blk.matmul(x, y)}
836    case 1n+p:
837      MatQ{a0, a1, a2, a3} = a
838      MatQ{b0, b1, b2, b3} = b
839      p0 q0 p1 q1 p2 q2 p3 q3 = MatT.matmul.sq(p, a0, b0) MatT.matmul.sq(p, a1, b2) MatT.matmul.sq(p, a0, b1) MatT.matmul.sq(p, a1, b3) MatT.matmul.sq(p, a2, b0) MatT.matmul.sq(p, a3, b2) MatT.matmul.sq(p, a2, b1) MatT.matmul.sq(p, a3, b3)
840      MatT.add4(p, p, p0, q0, p1, q1, p2, q2, p3, q3)

Uses (6)

Used by (2)