/**
 * Horner evaluation of a cubic polynomial stored at coeffs[base..base+3]:
 *
 *   p(x) = coeffs[base]
 *        + coeffs[base+1] * x
 *        + coeffs[base+2] * x^2
 *        + coeffs[base+3] * x^3
 *
 * The `base` offset lets callers pack many cubics into one flat buffer
 * (e.g. one cubic per dimension at base = 4*d).
 *
 * @param {number[]|Float32Array|Float64Array} coeffs
 * @param {number} base index of the constant term (coefficient of x^0)
 * @param {number} x
 * @returns {number}
 */
export function polynomial_cubic_horner_eval(coeffs, base, x) {
    return coeffs[base] + x * (coeffs[base + 1] + x * (coeffs[base + 2] + x * coeffs[base + 3]));
}
