Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

geometry.kept

The places of a run that a mask keeps, in order, the number of them as a Number, and for every place how many kept places stand before it.

Built from core.points (the mask written on it as a column of 0 and 1, so a field is given the length of the run), geometry.offsets (the prefix sum of those flags), geometry.first (the total read back as a Number; with device, op.device.bound keeps it a live count) and core.scatter (each kept place sends its own number to the slot its rank names).

Inputs

  • mask (Column or Field). A place is kept where the value is not 0.
  • count (Number). How many places the run holds.
  • device (Bool, default false). True keeps the number of places kept on the device: total is a live count bounded by the places the run holds, indices carries it, and nothing is read back.

Outputs

  • indices (Column<Int>). The kept places in order, total of them.
  • total (Number, or a live count with device). How many places are kept.
  • before (Column<Int>). For each place, how many kept places stand before it: a kept place's rank among the kept places.
local picked = g.geometry.kept({ mask = g.math.mod(g.field.index({ domain = 6 }), 2), count = 6 })