Builtin Library
README.md
core.scatter (procNode)
Fold a column into the places an index names: every element sends its value to the element its index names, and each receiver folds what reached it.
Three scatter kernel runs (init, fold, finish) over columns of the result's type. The same answer every run for the folds that do not depend on arrival order.
Inputs
values(Column). The column sent.index(Column<Int>). For each element, the place it is sent to; an index outside the result sends nowhere.size(Number). Default0. How many places there are.fold(one of add, mean, min, max, set). Default"add". How values that meet fold: added up, averaged, the least, the greatest, or the one from the greatest source index.fill(Value, optional). What a place nothing reached holds; zero when left out. With afillthe answer is a Field over the places.count(Number, optional). How many elements are sent: the length ofvalueswhen left out. Avaluesthat is a field over the elements has no length of its own, so the count is stated here, the length of theindexcolumn.
Outputs
value: the folded column,sizeelements of the type ofvalues.
Example
local values = g.core.column({ values = { 1, 2, 3 }, type = "Float" })
local index = g.core.column({ values = { 0, 0, 1 } })
local totals = g.core.scatter({ values = values, index = index, size = 3, fold = "add" })
Values 1 and 2 meet at place 0 and 3 lands at place 1: the column holds 3, 3, 0.