/// <summary>Initializes a new instance of the <see cref="Algorithm"/> class. /// </summary> /// <param name="gaussTschebyscheffConstantAbscissasIntegrator">The <see cref="GaussTschebyscheffConstAbscissaIntegrator"/> object which serves as factory for the current object.</param> internal Algorithm(GaussTschebyscheffConstAbscissaIntegrator gaussTschebyscheffConstantAbscissasIntegrator) { m_IntegratorFactory = gaussTschebyscheffConstantAbscissasIntegrator; WeightFunction = OneDimNumericalIntegrator.WeightFunction.Create(x => 1.0 / Math.Sqrt(1.0 - x * x)); m_EvaluationPoints = GaussianQuadrature.Tschebyscheff.GetValue(m_IntegratorFactory.Order, out m_Weight); }
public void GetValue_OneOverWeightfunction_BenchmarkResult( [Values(100, 125)] int order) { var gaussTschebyscheffIntegrator = new GaussTschebyscheffConstAbscissaIntegrator(order); var numericalIntegrator = gaussTschebyscheffIntegrator.Create(); double lowerBound = -1.0; double upperBound = 1.0; Assert.That(numericalIntegrator.TrySetBounds(lowerBound, upperBound) == true, String.Format("1-dimensional Integrator {0} does not support individual lower/upper bounds", numericalIntegrator.Factory.Name.String)); numericalIntegrator.FunctionToIntegrate = (x, k) => Math.Sqrt(1.0 - x * x); // for Tschebyscheff Integrator, the integrator is 1 in this case! double expected = upperBound - lowerBound; double actual = numericalIntegrator.GetValue(); Assert.That(actual, Is.EqualTo(expected).Within(1E-4), String.Format("1-dimensional integrator {0}.", numericalIntegrator.Factory.Name)); }
public void GetValue_OneOverWeightfunction_BenchmarkResult( [Values(100, 150)] int order, [Values(-1.0, 2.5)] double lowerBound, [Values(1.0, 6.4)] double upperBound) { var gaussTschebyscheffIntegrator = new GaussTschebyscheffConstAbscissaIntegrator(order); var numericalIntegrator = gaussTschebyscheffIntegrator.Create(); Assert.That(numericalIntegrator.TrySetBounds(lowerBound, upperBound) == true, String.Format("1-dimensional Integrator {0} does not support individual lower/upper bounds", numericalIntegrator.Factory.Name.String)); numericalIntegrator.FunctionToIntegrate = (x, k) => 1.0 / numericalIntegrator.WeightFunction.GetValue(x); double expected = upperBound - lowerBound; double actual = numericalIntegrator.GetValue(); Assert.That(actual, Is.EqualTo(expected).Within(1E-3), String.Format("1-dimensional integrator {0}.", numericalIntegrator.Factory.Name)); }
public void GetValue_ThreeTimesXToThePowerOf3_BenchmarkResult( [Values(80, 100, 125)] int order) { var gaussTschebyscheffIntegrator = new GaussTschebyscheffConstAbscissaIntegrator(order); var numericalIntegrator = gaussTschebyscheffIntegrator.Create(); double lowerBound = -1.0; double upperBound = 1.0; Assert.That(numericalIntegrator.TrySetBounds(lowerBound, upperBound) == true, String.Format("1-dimensional Integrator {0} does not support individual lower/upper bounds", numericalIntegrator.Factory.Name.String)); numericalIntegrator.FunctionToIntegrate = (x, k) => 3.0 * x * x * x; double a = 1.0; // see §21.5.25 in "Taschenbuch der Mathematik", Bronstein, Semendjajew, Musiol, Mühlig, 1995 double expected = 3.0 / 5.0 * Math.Sqrt(Math.Pow(a * a - upperBound * upperBound, 5)) - a * a * Math.Sqrt(Math.Pow(a * a - upperBound * upperBound, 3)) - 3.0 / 5.0 * Math.Sqrt(Math.Pow(a * a - lowerBound * lowerBound, 5)) - a * a * Math.Sqrt(Math.Pow(a * a - lowerBound * lowerBound, 3)); double actual = numericalIntegrator.GetValue(); Assert.That(actual, Is.EqualTo(expected).Within(1E-6), String.Format("1-dimensional integrator {0}.", numericalIntegrator.Factory.Name)); }