public void StirlingNumbers1RowSum()
 {
     foreach (int n in TestUtilities.GenerateIntegerValues(1, 100, 4))
     {
         double sum = 0.0;
         foreach (double s in AdvancedIntegerMath.StirlingNumbers1(n))
         {
             sum += s;
         }
         Assert.IsTrue(TestUtilities.IsNearlyEqual(sum, AdvancedIntegerMath.Factorial(n)));
     }
 }
        public void StirlingNumberMatrixInverse()
        {
            int n = 8;

            SquareMatrix S1 = new SquareMatrix(n);

            for (int i = 0; i < n; i++)
            {
                double[] s = AdvancedIntegerMath.StirlingNumbers1(i);
                for (int j = 0; j < s.Length; j++)
                {
                    if ((i - j) % 2 == 0)
                    {
                        S1[i, j] = s[j];
                    }
                    else
                    {
                        S1[i, j] = -s[j];
                    }
                }
            }

            SquareMatrix S2 = new SquareMatrix(n);

            for (int i = 0; i < n; i++)
            {
                double[] s = AdvancedIntegerMath.StirlingNumbers2(i);
                for (int j = 0; j < s.Length; j++)
                {
                    S2[i, j] = s[j];
                }
            }

            SquareMatrix S12 = S1 * S2;

            SquareMatrix I = new SquareMatrix(n);

            for (int i = 0; i < n; i++)
            {
                I[i, i] = 1.0;
            }

            Assert.IsTrue(TestUtilities.IsNearlyEqual(S12, I));
        }