1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.math4.legacy.analysis.integration.gauss;
18
19 import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
20 import org.apache.commons.numbers.gamma.Gamma;
21 import org.apache.commons.math4.core.jdkmath.JdkMath;
22 import org.junit.Assert;
23 import org.junit.Test;
24
25
26
27
28 public class LaguerreTest {
29 private static final GaussIntegratorFactory factory = new GaussIntegratorFactory();
30
31 @Test
32 public void testGamma() {
33 final double tol = 1e-13;
34
35 for (int i = 2; i < 10; i += 1) {
36 final double t = i;
37
38 final UnivariateFunction f = new UnivariateFunction() {
39 @Override
40 public double value(double x) {
41 return JdkMath.pow(x, t - 1);
42 }
43 };
44
45 final GaussIntegrator integrator = factory.laguerre(7);
46 final double s = integrator.integrate(f);
47 Assert.assertEquals(1d, Gamma.value(t) / s, tol);
48 }
49 }
50 }