LaguerrePolynomialFunction extends OrthogonalPolynomialFunctionGenerator { @Override public DoubleFunction1D[] getPolynomials(final int n) { return getPolynomials(n, 0); }  @Override DoubleFunction1D[] getPolynomials(final int n); @Override Pair<DoubleFunction1D, DoubleFunction1D>[] getPolynomialsAndFirstDerivative(final int n); DoubleFunction1D[] getPolynomials(final int n, final double alpha); Pair<DoubleFunction1D, DoubleFunction1D>[] getPolynomialsAndFirstDerivative(final int n, final double alpha);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testBadN1() { LAGUERRE.getPolynomials(-3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testBadN2() { LAGUERRE.getPolynomials(-3, 1); }
@Test public void test() { DoubleFunction1D[] l = LAGUERRE.getPolynomials(0); assertEquals(l.length, 1); final double x = 1.23; assertEquals(l[0].evaluate(x), 1, EPS); l = LAGUERRE.getPolynomials(1); assertEquals(l.length, 2); assertEquals(l[1].evaluate(x), 1 - x, EPS); for (int i = 0; i <= 6; i++) { l = LAGUERRE.getPolynomials(i); for (int j = 0; j <= i; j++) { assertEquals(L[j].evaluate(x), l[j].evaluate(x), EPS); } } }
@Test public void testAlpha1() { DoubleFunction1D[] l1, l2; final double x = 2.34; for (int i = 0; i <= 6; i++) { l1 = LAGUERRE.getPolynomials(i, 0); l2 = LAGUERRE.getPolynomials(i); for (int j = 0; j <= i; j++) { assertEquals(l1[j].evaluate(x), l2[j].evaluate(x), EPS); } } final double alpha = 3.45; l1 = LAGUERRE.getPolynomials(6, alpha); final DoubleFunction1D f0 = new DoubleFunction1D() { @Override public Double evaluate(final Double d) { return 1.; } }; final DoubleFunction1D f1 = new DoubleFunction1D() { @Override public Double evaluate(final Double d) { return 1 + alpha - d; } }; final DoubleFunction1D f2 = new DoubleFunction1D() { @Override public Double evaluate(final Double d) { return d * d / 2 - (alpha + 2) * d + (alpha + 2) * (alpha + 1) / 2.; } }; final DoubleFunction1D f3 = new DoubleFunction1D() { @Override public Double evaluate(final Double d) { return -d * d * d / 6 + (alpha + 3) * d * d / 2 - (alpha + 2) * (alpha + 3) * d / 2 + (alpha + 1) * (alpha + 2) * (alpha + 3) / 6; } }; assertEquals(l1[0].evaluate(x), f0.evaluate(x), EPS); assertEquals(l1[1].evaluate(x), f1.evaluate(x), EPS); assertEquals(l1[2].evaluate(x), f2.evaluate(x), EPS); assertEquals(l1[3].evaluate(x), f3.evaluate(x), EPS); }