コード例 #1
0
        /// <summary>
        /// Computes RisingFactorial(x:[-170...170], n:[-170...170]) using big integers
        /// </summary>
        /// <returns></returns>
        public TestCase2[] GetRisingFactorialIntData()
        {
            double DoubleMinNormal = Math.Pow(2, -1022);

            int Len  = Math2.FactorialTable.Length - 1;
            var data = new List <TestCase2>(4 * Len * Len);

            for (int x = -Len; x < Len; x++)
            {
                for (int n = -Len; n < Len; n++)
                {
                    // divide by zero
                    if (x > 0 && x + n <= 0)
                    {
                        continue;
                    }

                    // our big integer routines don't work well with denorms
                    double result = BigInt.FactorialRising((BigInteger)x, n);
                    if (Math.Abs(result) < DoubleMinNormal)
                    {
                        result = 0;
                    }

                    data.Add(new TestCase2(x, n, result));
                }
            }

            return(data.ToArray());
        }