@Test public void testPolyVal1d() throws Exception { double[] coeff = {1, 2, 3}; double[] input = {5, 7, 9}; double[] solutionArray_EXPECTED = {86, 162, 262}; for (int i = 0; i < solutionArray_EXPECTED.length; i++) { double solution_EXPECTED = solutionArray_EXPECTED[i]; Assert.assertEquals(solution_EXPECTED, PolyUtils.polyVal1D(input[i], coeff), DELTA_02); } }
public static double polyVal1D(double x, double[] coeffs) { double sum = 0.0; for (int d = coeffs.length - 1; d >= 0; --d) { sum *= x; sum += coeffs[d]; } return sum; }
PolyUtils { public static double polyVal1D(double x, double[] coeffs) { double sum = 0.0; for (int d = coeffs.length - 1; d >= 0; --d) { sum *= x; sum += coeffs[d]; } return sum; } }
PolyUtils { public static double polyVal1D(double x, double[] coeffs) { double sum = 0.0; for (int d = coeffs.length - 1; d >= 0; --d) { sum *= x; sum += coeffs[d]; } return sum; }  }
PolyUtils { public static double polyVal1D(double x, double[] coeffs) { double sum = 0.0; for (int d = coeffs.length - 1; d >= 0; --d) { sum *= x; sum += coeffs[d]; } return sum; }  static double normalize2(double data, final int min, final int max); static double normalize2(double data, final double min, final double max); static DoubleMatrix normalize(DoubleMatrix t); static int degreeFromCoefficients(int numOfCoefficients); static int numberOfCoefficients(final int degree); static double[] polyFitNormalized(DoubleMatrix t, DoubleMatrix y, final int degree); static double[] polyFit2D(final DoubleMatrix x, final DoubleMatrix y, final DoubleMatrix z, final int degree); static double[] polyFit(DoubleMatrix t, DoubleMatrix y, final int degree); static double polyVal1D(double x, double[] coeffs); static double[][] polyval(final double[] x, final double[] y, final double coeff[], int degree); static DoubleMatrix polyval(final DoubleMatrix x, final DoubleMatrix y, final DoubleMatrix coeff, int degree); static double polyval(final double x, final double y, final DoubleMatrix coeff, int degree); static double polyval(final double x, final double y, final double[] coeff); static double polyval(final double x, final double y, final double[] coeff, int degree); }
PolyUtils { public static double polyVal1D(double x, double[] coeffs) { double sum = 0.0; for (int d = coeffs.length - 1; d >= 0; --d) { sum *= x; sum += coeffs[d]; } return sum; }  static double normalize2(double data, final int min, final int max); static double normalize2(double data, final double min, final double max); static DoubleMatrix normalize(DoubleMatrix t); static int degreeFromCoefficients(int numOfCoefficients); static int numberOfCoefficients(final int degree); static double[] polyFitNormalized(DoubleMatrix t, DoubleMatrix y, final int degree); static double[] polyFit2D(final DoubleMatrix x, final DoubleMatrix y, final DoubleMatrix z, final int degree); static double[] polyFit(DoubleMatrix t, DoubleMatrix y, final int degree); static double polyVal1D(double x, double[] coeffs); static double[][] polyval(final double[] x, final double[] y, final double coeff[], int degree); static DoubleMatrix polyval(final DoubleMatrix x, final DoubleMatrix y, final DoubleMatrix coeff, int degree); static double polyval(final double x, final double y, final DoubleMatrix coeff, int degree); static double polyval(final double x, final double y, final double[] coeff); static double polyval(final double x, final double y, final double[] coeff, int degree);  }