def natural_dot
bendtorch-core@0.1.0.0 · src/tensor/matmul.bend:114
import bendtorch-core@0.1.0.0/src/tensor/matmul.bend as Matmul
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
114def natural_dot(fuel: Nat, +left: Shape.Shape, +right: Shape.Shape, a: Core.Tensor<left>, b: Core.Tensor<right>,
115 +row: U32, +column: U32, +cursor: Nat, accumulator: F32) ->
116 Result<&2, &1, Error, Core.Tensor<left> & Core.Tensor<right> & F32>:
117 match fuel:
118 case 0n:
119 Done{(a, b, accumulator)}
120 case 1n+tail:
121 +index = U32.from_nat(cursor)
122 dot_decided(left, right,
123 a => b => value => natural_dot(tail, left, right, a, b, row, column, 1n+cursor, value),
124 a, b, row, column, cursor, index, accumulator, Shape.bool_case(Nat.is_eq(U32.to_nat(index), cursor)))