Variable baseConst

base: { delay: ((solution: Solution, t: number, index: number[], state: number[]) => void); interpolate: { alloc: ((method: string, t: number[], y: number[]) => InterpolatorBase); checkY: ((dimArg: number[], dimTarget: number[], nameArg: string, nameTarget: string) => void); times: ((start: number[], end: number[]) => InterpolateTimes) }; maths: { intdivr: ((x: number, y: number) => number); modr: ((x: number, y: number) => number); odinSum1: ((x: number[], from: number, to: number) => number); odinSum2: ((x: number[], iFrom: number, iTo: number, jFrom: number, jTo: number, dim1: number) => number); odinSum3: ((x: number[], iFrom: number, iTo: number, jFrom: number, jTo: number, kFrom: number, kTo: number, dim1: number, dim12: number) => number); round2: ((x: number, digits?: number) => number) }; user: { checkUser: ((pars: UserType, allowed: string[], unusedUserAction: string) => void); setUserArrayFixed: ((pars: UserType, name: string, internal: InternalStorage, size: number[], min: number, max: number, isInteger: boolean) => void); setUserArrayVariable: ((pars: UserType, name: string, internal: InternalStorage, size: number[], min: number, max: number, isInteger: boolean) => void); setUserScalar: ((pars: UserType, name: string, internal: InternalStorage, defaultValue: null | number, min: number, max: number, isInteger: boolean) => void) } } = ...

Type declaration

  • delay: ((solution: Solution, t: number, index: number[], state: number[]) => void)
      • (solution: Solution, t: number, index: number[], state: number[]): void
      • Parameters

        • solution: Solution
        • t: number
        • index: number[]
        • state: number[]

        Returns void

  • interpolate: { alloc: ((method: string, t: number[], y: number[]) => InterpolatorBase); checkY: ((dimArg: number[], dimTarget: number[], nameArg: string, nameTarget: string) => void); times: ((start: number[], end: number[]) => InterpolateTimes) }
    • alloc: ((method: string, t: number[], y: number[]) => InterpolatorBase)
        • (method: string, t: number[], y: number[]): InterpolatorBase
        • Allocate a new interpolation function object

          Parameters

          • method: string

            Interpolation method to use; one of constant, linear or spline

          • t: number[]

            Array of interpolation times

          • y: number[]

            Array of interpolation response variables

          Returns InterpolatorBase

    • checkY: ((dimArg: number[], dimTarget: number[], nameArg: string, nameTarget: string) => void)
        • (dimArg: number[], dimTarget: number[], nameArg: string, nameTarget: string): void
        • Check that interpolation values are reasonable; this is called before allocation, once per model initialisation or parameter setting

          Parameters

          • dimArg: number[]
          • dimTarget: number[]
          • nameArg: string
          • nameTarget: string

          Returns void

    • times: ((start: number[], end: number[]) => InterpolateTimes)
  • maths: { intdivr: ((x: number, y: number) => number); modr: ((x: number, y: number) => number); odinSum1: ((x: number[], from: number, to: number) => number); odinSum2: ((x: number[], iFrom: number, iTo: number, jFrom: number, jTo: number, dim1: number) => number); odinSum3: ((x: number[], iFrom: number, iTo: number, jFrom: number, jTo: number, kFrom: number, kTo: number, dim1: number, dim12: number) => number); round2: ((x: number, digits?: number) => number) }
    • intdivr: ((x: number, y: number) => number)
        • (x: number, y: number): number
        • Integer division

          Parameters

          • x: number

            Dividend

          • y: number

            Divisor

          Returns number

    • modr: ((x: number, y: number) => number)
        • (x: number, y: number): number
        • 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]

          Parameters

          • x: number

            Dividend

          • y: number

            Divisor

          Returns number

    • odinSum1: ((x: number[], from: number, to: number) => number)
        • (x: number[], from: number, to: number): number
        • (Partial) sum over a single dimensional array

          Parameters

          • x: number[]

            Array to be summed over

          • from: number

            Index within x to start at

          • to: number

            Index within x to finish at

          Returns number

    • odinSum2: ((x: number[], iFrom: number, iTo: number, jFrom: number, jTo: number, dim1: number) => number)
        • (x: number[], iFrom: number, iTo: number, jFrom: number, jTo: number, dim1: number): number
        • (Partial) sum over a matrix

          Parameters

          • x: number[]

            Matrix to be summed over, stored as a flat array in column-major format

          • iFrom: number

            Row index within x to start at

          • iTo: number

            Row within x to finish at

          • jFrom: number

            Column index within x to start at

          • jTo: number

            Column within x to finish at

          • dim1: number

            Number of rows (length of dimension 1)

          Returns number

    • odinSum3: ((x: number[], iFrom: number, iTo: number, jFrom: number, jTo: number, kFrom: number, kTo: number, dim1: number, dim12: number) => number)
        • (x: number[], iFrom: number, iTo: number, jFrom: number, jTo: number, kFrom: number, kTo: number, dim1: number, dim12: number): number
        • (Partial) sum over a 3d array (tensor)

          Parameters

          • x: number[]

            Array to be summed over, stored as a flat array

          • iFrom: number

            First dimension index within x to start at

          • iTo: number

            First within x to finish at

          • jFrom: number

            Second dimension index within x to start at

          • jTo: number

            Second dimension within x to finish at

          • kFrom: number

            Third dimension index within x to start at

          • kTo: number

            Third dimension within x to finish at

          • dim1: number

            Length of dimension 1

          • dim12: number

            Length of the product of the first two dimensions

          Returns number

    • round2: ((x: number, digits?: number) => number)
        • (x: number, digits?: number): number
        • 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 ]

          Parameters

          • x: number

            Number to be rounded

          • Optional digits: number

            Optional number of digits for x to be rounded to (default is zero)

          Returns number

  • user: { checkUser: ((pars: UserType, allowed: string[], unusedUserAction: string) => void); setUserArrayFixed: ((pars: UserType, name: string, internal: InternalStorage, size: number[], min: number, max: number, isInteger: boolean) => void); setUserArrayVariable: ((pars: UserType, name: string, internal: InternalStorage, size: number[], min: number, max: number, isInteger: boolean) => void); setUserScalar: ((pars: UserType, name: string, internal: InternalStorage, defaultValue: null | number, min: number, max: number, isInteger: boolean) => void) }
    • checkUser: ((pars: UserType, allowed: string[], unusedUserAction: string) => void)
        • (pars: UserType, allowed: string[], unusedUserAction: string): void
        • Validate that a provided set of parameters pars contains only the values in allowed, handling this as requested by unusedUserAction

          Parameters

          • pars: UserType

            User-provided parameters for the model

          • allowed: string[]

            Names of allowed user parameters

          • unusedUserAction: string

            String, describing the action to take if there are unknown values in pars - possible values are "error", "ignore", "warning" and "message"

          Returns void

    • setUserArrayFixed: ((pars: UserType, name: string, internal: InternalStorage, size: number[], min: number, max: number, isInteger: boolean) => void)
        • (pars: UserType, name: string, internal: InternalStorage, size: number[], min: number, max: number, isInteger: boolean): void
        • 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.

          Parameters

          • pars: UserType

            User-provided parameters for the model

          • name: string

            Name of the parameter to set

          • internal: InternalStorage
          • size: number[]

            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.

          • min: number

            The minimum allowed value for the parameter; use -Infinity there is no minimum

          • max: number

            The maximum allowed value for the parameter; use Infinity there is no maximum

          • isInteger: boolean

            Check that the provided value is an integer

          Returns void

    • setUserArrayVariable: ((pars: UserType, name: string, internal: InternalStorage, size: number[], min: number, max: number, isInteger: boolean) => void)
        • (pars: UserType, name: string, internal: InternalStorage, size: number[], min: number, max: number, isInteger: boolean): void
        • 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.

          Parameters

          • pars: UserType

            User-provided parameters for the model

          • name: string

            Name of the parameter to set

          • internal: InternalStorage
          • size: number[]

            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.

          • min: number

            The minimum allowed value for the parameter; use -Infinity there is no minimum

          • max: number

            The maximum allowed value for the parameter; use Infinity there is no maximum

          • isInteger: boolean

            Check that the provided value is a parameter

          Returns void

    • setUserScalar: ((pars: UserType, name: string, internal: InternalStorage, defaultValue: null | number, min: number, max: number, isInteger: boolean) => void)
        • (pars: UserType, name: string, internal: InternalStorage, defaultValue: null | number, min: number, max: number, isInteger: boolean): void
        • 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.

          Parameters

          • pars: UserType

            User-provided parameters for the model

          • name: string

            Name of the parameter to set

          • internal: InternalStorage

            The model's internal data; the parameter will be updated here

          • defaultValue: null | number
          • min: number

            The minimum allowed value for the parameter; use -Infinity if there is no minimum

          • max: number

            The maximum allowed value for the parameter; use Infinity if there is no maximum

          • isInteger: boolean

            Check that the provided value is an integer

          Returns void

Generated using TypeDoc