Builtin Library
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:totalis a live count bounded by the places the run holds,indicescarries it, and nothing is read back.
Outputs
indices(Column<Int>). The kept places in order,totalof them.total(Number, or a live count withdevice). 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 })