Browse Source

quadrature: some methods are now static

Signed-off-by: Christoph Ruegg <git@cdrnet.ch>
pull/2/head
Christoph Ruegg 17 years ago
parent
commit
f2e442d54a
  1. 20
      src/Managed.UnitTests/IntegrationTests/IntegrationTest.cs
  2. 7
      src/Managed/Integration/Algorithms/DoubleExponentialTransformation.cs
  3. 10
      src/Managed/Integration/Algorithms/NewtonCotesTrapeziumRule.cs
  4. 6
      src/Managed/Integration/Algorithms/SimpsonRule.cs

20
src/Managed.UnitTests/IntegrationTests/IntegrationTest.cs

@ -82,11 +82,9 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
[Test]
public void TrapeziumRuleSupportsTwoPointIntegration()
{
var algorithm = new NewtonCotesTrapeziumRule();
Assert.AreApproximatelyEqual(
TargetAreaA,
algorithm.IntegrateTwoPoint(TargetFunctionA, StartA, StopA),
NewtonCotesTrapeziumRule.IntegrateTwoPoint(TargetFunctionA, StartA, StopA),
0.4 * TargetAreaA,
"Direct (1 Partition)");
}
@ -99,11 +97,9 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
[Row(1000, 1.5e-6)]
public void TrapeziumRuleSupportsCompositeIntegration(int partitions, double maxRelativeError)
{
var algorithm = new NewtonCotesTrapeziumRule();
Assert.AreApproximatelyEqual(
TargetAreaA,
algorithm.IntegrateComposite(TargetFunctionA, StartA, StopA, partitions),
NewtonCotesTrapeziumRule.IntegrateComposite(TargetFunctionA, StartA, StopA, partitions),
maxRelativeError * TargetAreaA,
"Composite {0} Partitions", partitions);
}
@ -114,11 +110,9 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
[Row(1e-10)]
public void TrapeziumRuleSupportsAdaptiveIntegration(double targetRelativeError)
{
var algorithm = new NewtonCotesTrapeziumRule();
Assert.AreApproximatelyEqual(
TargetAreaA,
algorithm.IntegrateAdaptive(TargetFunctionA, StartA, StopA, targetRelativeError),
NewtonCotesTrapeziumRule.IntegrateAdaptive(TargetFunctionA, StartA, StopA, targetRelativeError),
targetRelativeError * TargetAreaA,
"Adaptive {0}", targetRelativeError);
}
@ -126,11 +120,9 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
[Test]
public void SimpsonRuleSupportsThreePointIntegration()
{
var algorithm = new SimpsonRule();
Assert.AreApproximatelyEqual(
TargetAreaA,
algorithm.IntegrateThreePoint(TargetFunctionA, StartA, StopA),
SimpsonRule.IntegrateThreePoint(TargetFunctionA, StartA, StopA),
0.2 * TargetAreaA,
"Direct (2 Partitions)");
}
@ -143,11 +135,9 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
[Row(1000, 5e-11)]
public void SimpsonRuleSupportsCompositeIntegration(int partitions, double maxRelativeError)
{
var algorithm = new SimpsonRule();
Assert.AreApproximatelyEqual(
TargetAreaA,
algorithm.IntegrateComposite(TargetFunctionA, StartA, StopA, partitions),
SimpsonRule.IntegrateComposite(TargetFunctionA, StartA, StopA, partitions),
maxRelativeError * TargetAreaA,
"Composite {0} Partitions", partitions);
}

7
src/Managed/Integration/Algorithms/DoubleExponentialTransformation.cs

@ -491,11 +491,6 @@ namespace MathNet.Numerics.Integration.Algorithms
/// </summary>
private const int NumberOfMaximumLevels = 10;
/// <summary>
/// Internal Trapezium Rule.
/// </summary>
private readonly NewtonCotesTrapeziumRule _trapezium = new NewtonCotesTrapeziumRule();
/// <summary>
/// Abscissa vector per level provider.
/// </summary>
@ -526,7 +521,7 @@ namespace MathNet.Numerics.Integration.Algorithms
_levelWeights = ProvideLevelWeights();
}
return _trapezium.IntegrateAdaptiveTransformedOdd(
return NewtonCotesTrapeziumRule.IntegrateAdaptiveTransformedOdd(
f,
intervalBegin,
intervalEnd,

10
src/Managed/Integration/Algorithms/NewtonCotesTrapeziumRule.cs

@ -38,7 +38,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <remarks>
/// <a href="http://en.wikipedia.org/wiki/Trapezium_rule">Wikipedia - Trapezium Rule</a>
/// </remarks>
public class NewtonCotesTrapeziumRule
public static class NewtonCotesTrapeziumRule
{
/// <summary>
/// Direct 2-point approximation of the definite integral in the provided interval by the trapezium rule.
@ -47,7 +47,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param>
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateTwoPoint(
public static double IntegrateTwoPoint(
Func<double, double> f,
double intervalBegin,
double intervalEnd)
@ -63,7 +63,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <param name="numberOfPartitions">Number of composite subdivision partitions.</param>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateComposite(
public static double IntegrateComposite(
Func<double, double> f,
double intervalBegin,
double intervalEnd,
@ -96,7 +96,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <param name="targetRelativeError">The expected relative accuracy of the approximation.</param>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateAdaptive(
public static double IntegrateAdaptive(
Func<double, double> f,
double intervalBegin,
double intervalEnd,
@ -138,7 +138,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="levelOneStep">First Level Step</param>
/// <param name="targetRelativeError">The expected relative accuracy of the approximation.</param>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateAdaptiveTransformedOdd(
public static double IntegrateAdaptiveTransformedOdd(
Func<double, double> f,
double intervalBegin,
double intervalEnd,

6
src/Managed/Integration/Algorithms/SimpsonRule.cs

@ -35,7 +35,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <summary>
/// Approximation algorithm for definite integrals by Simpson's rule.
/// </summary>
public class SimpsonRule
public static class SimpsonRule
{
/// <summary>
/// Direct 3-point approximation of the definite integral in the provided interval by Simpson's rule.
@ -44,7 +44,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="intervalBegin">Where the interval starts, inclusive and finite.</param>
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateThreePoint(
public static double IntegrateThreePoint(
Func<double, double> f,
double intervalBegin,
double intervalEnd)
@ -61,7 +61,7 @@ namespace MathNet.Numerics.Integration.Algorithms
/// <param name="intervalEnd">Where the interval stops, inclusive and finite.</param>
/// <param name="numberOfPartitions">Even number of composite subdivision partitions.</param>
/// <returns>Approximation of the finite integral in the given interval.</returns>
public double IntegrateComposite(
public static double IntegrateComposite(
Func<double, double> f,
double intervalBegin,
double intervalEnd,

Loading…
Cancel
Save