Repository navigation
Utils.Function.evaluatePolySegment
commons-math-interpolation / Utils / evaluatePolySegment
function evaluatePolySegment(
xVals,
segmentCoeffs,
x
): number;Defined in: Utils.ts:53
Evaluates a piecewise polynomial function (e.g. a spline) at the specified argument value.
The segment is selected by the position of x within the knots xVals:
segment i is used for xVals[i] <= x < xVals[i + 1].
Arguments below xVals[0] are evaluated with the first segment and arguments at or above
the start of the last segment are evaluated with the last segment (extrapolation).
ArrayLike<number>
The x values of the knots, in strictly increasing order.
xVals[i] is the start point of segment i.
Normally it contains one element more than segmentCoeffs (the end point of the last segment).
ArrayLike<number>[]
The polynomial coefficients of the segments, in ascending order (constant term first).
The polynomials are relative to the segment start, i.e. segment i is evaluated as a polynomial
of x - xVals[i].
Must contain at least one segment.
number
The argument value.
number
The value of the piecewise polynomial function at x, or NaN if x is NaN.