Accord.Tests.Math.GammaTest.FunctionTest C# (CSharp) Method

FunctionTest() private method

private FunctionTest ( ) : void
return void
        public void FunctionTest()
        {
            double[] x = 
            {
                1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0,
                3.1, 5.7, 56.2, 53.8, 5.1, 6.5, 8.8, 114.2, 1024.6271,
               -2, -52.1252, -0.10817480950786047, -0.11961291417237133,
                -0.12078223763524518, 0, 281982742.12985912, 0.5212392
            };

            double[] expected =    
            {
                  1.000000000000000e+00, 0.9513507698668732, 9.181687423997607e-01,
                  8.974706963062772e-01, 8.872638175030753e-01, 8.862269254527581e-01,
                  8.935153492876903e-01, 9.086387328532904e-01, 9.313837709802427e-01, 
                  9.617658319073874e-01, 1.000000000000000e+00, 2.197620278392477e+00,
                  7.252763452022295e+01, 2.835938400359957e+73, 1.929366760161528e+69,
                  2.793175373836837e+01, 2.878852778150444e+02, 2.633998635450860e+04,
                  5.749274244634086e+184, Double.PositiveInfinity, Double.NaN,
                 -6.188338737526232e-68, -9.940515795403039e+00,  -9.070713053754153e+00,
                 -8.991245623853780e+00, Double.NaN, Double.PositiveInfinity, 1.701905559094028e+00

            };

            for (int i = 0; i < x.Length; i++)
            {
                double xi = x[i];
                double expectedi = expected[i];

                if (Double.IsNaN(expectedi))
                {
                    bool thrown = false;
                    try { Gamma.Function(xi); }
                    catch { thrown = true; }
                    Assert.IsTrue(thrown);
                }
                else
                {
                    double actual = Gamma.Function(xi);
                    if (Double.IsNaN(actual))
                        throw new Exception();
                    Assert.AreEqual(expectedi, actual, System.Math.Abs(expectedi) * 1e-12);
                }
            }
        }