public void LogTest()
{
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 =
{
0.000000000000000e+00, -0.04987244125983974, -8.537409000331581e-02,
-1.081748095078605e-01, -1.196129141723713e-01, -1.207822376352452e-01,
-1.125917656967558e-01, -9.580769740706588e-02, -7.108387291437214e-02,
-3.898427592308334e-02, 0.000000000000000e+00, 7.873750832738625e-01,
4.283967655031580e+00, 1.691310846763928e+02, 1.595355632621249e+02,
3.329764168475224e+00, 5.662562059857142e+00, 1.017884345724507e+01,
4.254247307394230e+02, 6.075627024736053e+03, Double.PositiveInfinity,
-1.547531196513472e+02, 2.296618910207815e+00, 2.205050877768351e+00,
2.196251395487650e+00, Double.PositiveInfinity, 5.204655969482103e+09,
5.317485404177827e-01
};
for (int i = 0; i < x.Length; i++)
{
double xi = x[i];
double expectedi = expected[i];
if (Double.IsNaN(expectedi) || Double.IsInfinity(expectedi))
{
bool thrown = false;
try { Gamma.Function(xi); }
catch { thrown = true; }
Assert.IsTrue(thrown);
}
else
{
double actual = Gamma.Log(xi);
Assert.AreEqual(expectedi, actual, System.Math.Abs(expectedi) * 1e-14);
}
}
}