Esempio n. 1
0
        public void GetValue_ExpOfMinusX_BenchmarkResult(
            [Values(5, 10, 22)]
            int alpha,
            [Values(100, 125)]
            int initialOrder,
            [Values(5, 10, 25)]
            int orderStepSize)
        {
            var gaussLaguerreIntegrator = new GaussLaguerreIntegrator(alpha, initialOrder, orderStepSize);
            var numericalIntegrator     = gaussLaguerreIntegrator.Create();

            numericalIntegrator.FunctionToIntegrate = x => Math.Exp(-x);  // i.e. \int_0^\infty exp(-2*x) * x^alpha

            double expected = GetFaculty(alpha) / Math.Pow(2, alpha + 1); // see for example § 21.6.2 "Taschenbuch der Mathematik", Bronstein, Semendjajew, Musiol, Mühlig, 1995
            double actual   = numericalIntegrator.GetValue();

            Assert.That(actual, Is.EqualTo(expected).Within(1E-7).Percent, String.Format("1-dimensional integrator {0}.", numericalIntegrator.Factory.Name));
        }
Esempio n. 2
0
        public void GetValueWithState_One_BenchmarkResult(
            [Values(5, 10, 22)]
            int alpha,
            [Values(100, 125)]
            int initialOrder,
            [Values(5, 10, 25)]
            int orderStepSize)
        {
            var gaussLaguerreIntegrator = new GaussLaguerreIntegrator(alpha, initialOrder, orderStepSize);
            var numericalIntegrator     = gaussLaguerreIntegrator.Create();

            numericalIntegrator.FunctionToIntegrate = x => 1.0;

            double expected = GetFaculty(alpha);  // see for example § 21.6.2 "Taschenbuch der Mathematik", Bronstein, Semendjajew, Musiol, Mühlig, 1995
            double actual;

            OneDimNumericalIntegrator.State state = numericalIntegrator.GetValue(out actual);

            Assert.That(actual, Is.EqualTo(expected).Within(1E-7).Percent, String.Format("1-dimensional integrator {0}; state: {1}.", numericalIntegrator.Factory.Name, state.ToString()));
        }