Esempio n. 1
0
 internal static double PowerOverFactorial(double x, double nu)
 {
     if (nu < 16.0)
     {
         return(Math.Pow(x, nu) / AdvancedMath.Gamma(nu + 1.0));
     }
     else
     {
         return(Stirling.PowerFactor(x, nu));
     }
 }
Esempio n. 2
0
        // This function computes x^n / n! or x^{\nu} / \Gamma(\nu + 1), which can easily become
        // Infinity/Infinity=NaN for large n if computed naively.

        internal static double PowerOverFactorial(double x, int n)
        {
            if (n <= 16)
            {
                // For maximum range, we should evaluate this using Lanczos, but
                // since we know we don't call it for x large enough for x^n to overflow,
                // this is safer and faster.
                return(MoreMath.Pow(x, n) / AdvancedIntegerMath.Factorial(n));
            }
            else
            {
                return(Stirling.PowerFactor(x, n));
            }
        }