Exemplo n.º 1
0
 /// <summary>Initializes a new instance of the <see cref="Algorithm"/> class.
 /// </summary>
 /// <param name="gaussLaguerreIntegrator">The <see cref="GaussLaguerreIntegrator"/> object which serves as factory for the current object.</param>
 internal Algorithm(GaussLaguerreIntegrator gaussLaguerreIntegrator)
 {
     m_IntegratorFactory = gaussLaguerreIntegrator;
     if (gaussLaguerreIntegrator.m_AlphaIsZero == true)
     {
         WeightFunction = OneDimNumericalIntegrator.WeightFunction.Create(x => Math.Exp(-x));
     }
     else
     {
         WeightFunction = OneDimNumericalIntegrator.WeightFunction.Create(x => Math.Pow(x, m_IntegratorFactory.Alpha) * Math.Exp(-x));
     }
 }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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()));
        }