GaussIntegrator { public double integrate(UnivariateFunction f) { double s = 0; double c = 0; for (int i = 0; i < points.length; i++) { final double x = points[i]; final double w = weights[i]; final double y = w * f.value(x) - c; final double t = s + y; c = (t - s) - y; s = t; } return s; } GaussIntegrator(double[] points,
                           double[] weights);  GaussIntegrator(Pair<double[], double[]> pointsAndWeights); double integrate(UnivariateFunction f); int getNumberOfPoints(); double getPoint(int index); double getWeight(int index);  }
@Test public void testIntegrate() { final double[] points = { 0, 1, 2, 3, 4, 5 }; final double[] weights = { 1, 1, 1, 1, 1, 1 }; final GaussIntegrator integrator = new GaussIntegrator(new Pair<double[], double[]>(points, weights)); final double val = 123.456; final UnivariateFunction c = new Constant(val); final double s = integrator.integrate(c); Assert.assertEquals(points.length * val, s, 0d); }