Crystallography/Mathematics/GammaFunction.cs
/// <summary>
/// Returns the natural logarithm of Gamma for a real value > 0
/// </summary>
/// <param name="xx">A real value for Gamma calculation</param>
/// <returns>A value ln|Gamma(xx))| for xx > 0</returns>
Returns the natural logarithm of Gamma for a real value > 0
Returns the natural logarithm of Gamma for a real value > 0
public static double GammaLn(double xx)
        {
            double x, y, ser, temp;
            double[] coefficient = new double[]{76.18009172947146,-86.50535032941677,
                                                   24.01409824083091,-1.231739572450155,0.1208650973866179e-2,-0.5395239384953e-5};
            int j;
            y = x = xx;
            temp = x + 5.5;
            temp -= ((x + 0.5) * Math.Log(temp));
            ser = 1.000000000190015;
            for (j = 0; j <= 5; j++)
                ser += (coefficient[j] / ++y);
            return -temp + Math.Log(2.50662827463100005 * ser / x);
        }
public static double GammaLn ( double xx ) { double x , y , ser , temp ; double [ ] coefficient = new double [ ] { 76.18009172947146 , - 86.50535032941677 , 24.01409824083091 , - 1.231739572450155 , 0.1208650973866179e-2 , - 0.5395239384953e-5 } ; int j ; y = x = xx ; temp = x + 5.5 ; temp -= ( ( x + 0.5 ) * Math . Log ( temp ) ) ; ser = 1.000000000190015 ; for ( j = 0 ; j <= 5 ; j ++ ) ser += ( coefficient [ j ] / ++ y ) ; return - temp + Math . Log ( 2.50662827463100005 * ser / x ) ; }
Returns the natural logarithm of Gamma for a real value > 0
Returns the natural logarithm of Gamma for a real value > 0
// TODO: check
A value ln|Gamma(xx))| for xx > 0
A value ln|Gamma ( xx )) | for xx > 0
xx
double
A real value for Gamma calculation
A real value for Gamma calculation