/// <summary>Initializes a new instance of the <see cref="Algorithm"/> class. /// </summary> /// <param name="gaussLaguerreConstantAbscissasIntegrator">The <see cref="GaussLaguerreConstAbscissaIntegrator"/> object which serves as factory for the current object.</param> internal Algorithm(GaussLaguerreConstAbscissaIntegrator gaussLaguerreConstantAbscissasIntegrator) { m_IntegratorFactory = gaussLaguerreConstantAbscissasIntegrator; if (m_IntegratorFactory.m_AlphaIsZero == true) { WeightFunction = OneDimNumericalIntegrator.WeightFunction.Create(x => Math.Exp(-x)); } else { WeightFunction = OneDimNumericalIntegrator.WeightFunction.Create(x => Math.Exp(-x) * Math.Pow(x, m_IntegratorFactory.Alpha)); } }
public void GetValue_ZeroAlphaExpOfMinusX_BenchmarkResult( [Values(100, 125)] int order) { var gaussLaguerreConstantAbscissasIntegrator = new GaussLaguerreConstAbscissaIntegrator(order); var numericalIntegrator = gaussLaguerreConstantAbscissasIntegrator.Create(); numericalIntegrator.FunctionToIntegrate = (x, k) => Math.Exp(-x); // i.e. \int_0^\infty e^{-2*x} = 1/2 double expected = 0.5; double actual = numericalIntegrator.GetValue(); Assert.That(actual, Is.EqualTo(expected).Within(1E-6), String.Format("1-dimensional integrator {0}.", numericalIntegrator.Factory.Name)); }
public void GetValue_One_BenchmarkResult( [Values(5, 10, 22)] int alpha, [Values(100, 125)] int order) { var gaussLaguerreConstantAbscissasIntegrator = new GaussLaguerreConstAbscissaIntegrator(alpha, order); var numericalIntegrator = gaussLaguerreConstantAbscissasIntegrator.Create(); numericalIntegrator.FunctionToIntegrate = (x, k) => 1.0; double expected = GetFaculty(alpha); // 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)); }