evaluate static method

Float64List evaluate(
  1. Float64List x,
  2. Float64List coeffs
)

Evaluates a polynomial in the original x-domain using Horner's method.

coeffs must be ordered from constant term to highest degree term.

Implementation

static Float64List evaluate(Float64List x, Float64List coeffs) {
  final out = Float64List(x.length);
  for (int i = 0; i < x.length; i++) {
    double acc = 0.0;
    for (int j = coeffs.length - 1; j >= 0; j--) {
      acc = acc * x[i] + coeffs[j];
    }
    out[i] = acc;
  }
  return out;
}