Slice.source: def of bendtorch-core@0.1.0.0 Import: import bendtorch-core@0.1.0.0/src/tensor/slice.bend as Slice Lines 203-209 of bendtorch-core@0.1.0.0/src/tensor/slice.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/tensor/slice.bend&start_line=203&end_line=209 import Base # The input index output cell `position` reads: position is (o * length + k) # * inner + r, and it reads (o * extent + start + k * step) * inner + r. def source(+plan: Plan, +position: Nat) -> Nat: Plan{+outer, +extent, +inner, +start, +step, +length} = plan +row = Nat.div(position, inner) +o = Nat.div(row, length) Nat.add(Nat.mul(Nat.add(Nat.mul(o, extent), Nat.add(start, Nat.mul(Nat.mod(row, length), step))), inner), Nat.mod(position, inner)) Uses (6): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mod https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mul https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/slice.bend&name=Plan