예제 #1
0
        public void Test_Iterations(int startIteration, int numberOfIterations, double expected)
        {
            var pi = new Nilikantha();

            pi.Iterations(startIteration, numberOfIterations);
            Assert.That(Math.Abs(expected - pi.Calculate()), Is.LessThan(0.000000001));
        }
예제 #2
0
        public void Test_NumberOfIterations(int iterations, double expected)
        {
            var pi = new Nilikantha();

            pi.NumberOfIterations = iterations;
            Assert.That(Math.Abs(expected - pi.Calculate()), Is.LessThan(0.000000001));
        }
        public double Get(int iterations, string modelToUse)
        {
            IterativeMethod pi = null;

            switch (modelToUse)
            {
            case "Gregory-Leibniz":
                pi = new Gregory_Leibniz();
                break;

            case "Nilikantha":
                pi = new Nilikantha();
                break;

            default:
                throw new System.Exception($"Could not find [{modelToUse}] model.");
            }
            pi.NumberOfIterations = iterations;
            return(pi.Calculate());
        }