Const
Integer division
Dividend
Divisor
A modulo (%
) function that follows the same rules as R's %%
for negative x
const x = [-3, -2, -1, 0, 1, 2, 3];
x.map((el: number) => x % 3); // [-0, -2, -1, 0, 1, 2, 0]
x.map((el: number) => modr(x, 3)); // [-0, 1, 2, 0, 1, 2, 0]
Dividend
Divisor
(Partial) sum over a single dimensional array
Array to be summed over
Index within x
to start at
Index within x
to finish at
(Partial) sum over a matrix
Matrix to be summed over, stored as a flat array in column-major format
Row index within x
to start at
Row within x
to finish at
Column index within x
to start at
Column within x
to finish at
Number of rows (length of dimension 1)
(Partial) sum over a 3d array (tensor)
Array to be summed over, stored as a flat array
First dimension index within x
to start at
First within x
to finish at
Second dimension index within x
to start at
Second dimension within x
to finish at
Third dimension index within x
to start at
Third dimension within x
to finish at
Length of dimension 1
Length of the product of the first two dimensions
Round a number. This function differs from Math.round
in two
respects - it can round to a number of digits with the optional
digits
argument:
round2(1.2345, 2) // 1.23
It follows the "round half to even" rounding rule, which avoids some biases
const x = [-2.5, -1.5, -0.5, 0.5, 1.5, 2.5];
x.map(Math.round); // [ -2, -1, -0, 1, 2, 3 ]
x.map(round2); // [ -2 -2 0 0 2 2 ]
Number to be rounded
Optional
digits: numberOptional number of digits for x
to be rounded to
(default is zero)
Validate that a provided set of parameters pars
contains only the
values in allowed
, handling this as requested by
unusedUserAction
User-provided parameters for the model
Names of allowed user parameters
String, describing the action to take
if there are unknown values in pars
- possible values are
"error", "ignore", "warning" and "message"
Set an array parameter with known (fixed) size provided by the user. This function will throw if the parameter violates the constraint, or if none is provided and no value for this parameter has previously been set.
User-provided parameters for the model
Name of the parameter to set
Array of dimension sizes; this must be a vector of n + 1
values for a tensor of rank n
(e.g., length 3 for a matrix),
with the first value containing the total length of the vector and
the remaining values being the length of each dimension. The first
number will therefore be the product of the remaining numbers.
The minimum allowed value for the parameter; use
-Infinity
there is no minimum
The maximum allowed value for the parameter; use
Infinity
there is no maximum
Check that the provided value is an integer
Set an array parameter with known (fixed) size provided by the user. This function will throw if the parameter violates the constraint, or if none is provided and no value for this parameter has previously been set.
This is the method used where the odin model contains
x[, ] <- user()
dim(x) <- user()
which means that the extents are set based on the given array
(rather than some known value within size) and we report the values
back into the size
variable and odin will then generate code that
sets the appropriate sizes into internal
later - we might move
that into here later.
User-provided parameters for the model
Name of the parameter to set
Array of dimension sizes; this must be a vector of n + 1
values for a tensor of rank n
(e.g., length 3 for a
matrix). This array will be written into on return with the size of
the recieved array.
The minimum allowed value for the parameter; use
-Infinity
there is no minimum
The maximum allowed value for the parameter; use
Infinity
there is no maximum
Check that the provided value is a parameter
Set a scalar parameter provided by the user. This function will throw if the parameter violates the constraint, or if none is provided and no default is given and no value for this parameter has previously been set.
User-provided parameters for the model
Name of the parameter to set
The model's internal data; the parameter will be updated here
The minimum allowed value for the parameter; use
-Infinity
if there is no minimum
The maximum allowed value for the parameter; use
Infinity
if there is no maximum
Check that the provided value is an integer
Generated using TypeDoc
Support code available during model construction and update, (eventually) mirroring the interface in odin-js.