1 package JSci.tests; 2 3 import JSci.maths.*; 4 5 9 public class SpecialTest extends junit.framework.TestCase { 10 public static void main(String arg[]) { 11 junit.textui.TestRunner.run(SpecialTest.class); 12 } 13 public SpecialTest(String name) { 14 super(name); 15 } 16 19 public void testGammaFunctional() { 20 for(int i=0; i<10; i++) { 21 double x = SpecialMath.GAMMA_X_MAX_VALUE*Math.random(); 22 double expected = x*SpecialMath.gamma(x); 23 double ans = SpecialMath.gamma(x+1.0); 24 assertEquals(expected, ans, 1.0e-10*Math.abs(expected)); 25 } 26 } 27 30 public void testGammaDuplication() { 31 for(int i=0; i<10; i++) { 32 double x = Math.sqrt(SpecialMath.GAMMA_X_MAX_VALUE)*Math.random(); 33 double expected = Math.pow(4.0, x)/(2.0*Math.sqrt(Math.PI))*SpecialMath.gamma(x)*SpecialMath.gamma(x+0.5); 34 double ans = SpecialMath.gamma(2.0*x); 35 assertEquals(expected, ans, 1.0e-10*Math.abs(expected)); 36 } 37 } 38 } 39 40 | Popular Tags |