Accord.Math.Special.Factorial C# (CSharp) Method

Factorial() public static method

Returns the extended factorial definition of a real number.
public static Factorial ( double n ) : double
n double
return double
        public static double Factorial(double n)
        {
            return Gamma.Function(n + 1.0);
        }

Same methods

Special::Factorial ( int n ) : double

Usage Example

コード例 #1
0
        /// <summary>
        ///   Computes the Basic Spline of order <c>n</c>
        /// </summary>
        public static double BSpline(int n, double x)
        {
            // ftp://ftp.esat.kuleuven.ac.be/pub/SISTA/hamers/PhD_bhamers.pdf
            // http://sepwww.stanford.edu/public/docs/sep105/sergey2/paper_html/node5.html

            if (n == Int32.MaxValue)
            {
                throw new ArgumentOutOfRangeException("n");
            }


            double a = 1.0 / Special.Factorial(n);
            double c;

            bool positive = true;

            for (int k = 0; k <= n + 1; k++)
            {
                c        = Binomial(n + 1, k) * Tools.TruncatedPower(x + (n + 1.0) / 2.0 - k, n);
                a       += positive ? c : -c;
                positive = !positive;
            }

            return(a);
        }
All Usage Examples Of Accord.Math.Special::Factorial