avg

koadrobot/aritmatics/avg

Calculate average of inputs. (di-do is temp values for variadic)
avg
@/avg
Calculate average of inputs. (di-do is temp values for variadic)
dinumber
Unused temp input.
X0number
Input
X1number (variadic)
avg
di
X0
X1
…
do
AVG
AVGnumber
Average value of Inputs.
donumber
Unused temp output.
To use the node in your project you should have the koadrobot/aritmatics library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD dirtieness disable

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    Number dumyIn = getValue<input_di>(ctx);
    Number x0 = getValue<input_X0>(ctx);
    Number x1 = getValue<input_X1>(ctx);
    Number out = ((dumyIn * x0) + x1)/(dumyIn + 1);
    emitValue<output_do>(ctx, dumyIn + 1);
    emitValue<output_AVG>(ctx, out);
}

Tabular tests

diX0X1doAVG
12423