Browse Source

Switched to using properties for the order and InvervalBegin/IntervalEnd.

netstandard
Larz White 11 years ago
parent
commit
f3632a1cac
  1. 24
      src/Numerics/Integration/GaussLegendreRule.cs
  2. 10
      src/UnitTests/IntegrationTests/IntegrationTest.cs

24
src/Numerics/Integration/GaussLegendreRule.cs

@ -74,28 +74,34 @@ namespace MathNet.Numerics.Integration
/// <summary>
/// Getter for the order.
/// </summary>
/// <returns>The order, which defines an Nth order Gauss-Legendre rule. The order also defines the number of abscissas and weights for the rule.</returns>
public int GetOrder()
public int Order
{
return gaussLegendrePoint.Order;
get
{
return gaussLegendrePoint.Order;
}
}
/// <summary>
/// Getter for the InvervalBegin.
/// </summary>
/// <returns>Where the interval starts, inclusive and finite.</returns>
public double GetIntervalBegin()
public double IntervalBegin
{
return gaussLegendrePoint.IntervalBegin;
get
{
return gaussLegendrePoint.IntervalBegin;
}
}
/// <summary>
/// Getter for the InvervalEnd.
/// </summary>
/// <returns>Where the interval stops, inclusive and finite.</returns>
public double GetIntervalEnd()
public double IntervalEnd
{
return gaussLegendrePoint.IntervalEnd;
get
{
return gaussLegendrePoint.IntervalEnd;
}
}
/// <summary>

10
src/UnitTests/IntegrationTests/IntegrationTest.cs

@ -273,12 +273,12 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
[TestCase(20)]
[TestCase(21)]
[TestCase(22)]
public void TestGaussLegendreRuleGetAbscissasGetWeightsGetOrderViaIntegration(int order)
public void TestGaussLegendreRuleGetAbscissasGetWeightsOrderViaIntegration(int order)
{
GaussLegendreRule gaussLegendre = new GaussLegendreRule(StartA, StopA, order);
double appoximateArea = 0;
for (int i = 0; i < gaussLegendre.GetOrder(); i++)
for (int i = 0; i < gaussLegendre.Order; i++)
{
appoximateArea += gaussLegendre.GetWeight(i) * TargetFunctionA(gaussLegendre.GetAbscissa(i));
}
@ -295,18 +295,18 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
{
const int order = 19;
GaussLegendreRule gaussLegendre = new GaussLegendreRule(StartA, StopA, order);
Assert.AreEqual(gaussLegendre.GetIntervalBegin(), StartA);
Assert.AreEqual(gaussLegendre.IntervalBegin, StartA);
}
/// <summary>
/// Gauss-Legendre rule supports obtaining IntervalEnd.
/// </summary>
[TestCase]
public void TestGaussLegendreRuleGetIntervalEnd()
public void TestGaussLegendreRuleIntervalEnd()
{
const int order = 19;
GaussLegendreRule gaussLegendre = new GaussLegendreRule(StartA, StopA, order);
Assert.AreEqual(gaussLegendre.GetIntervalEnd(), StopA);
Assert.AreEqual(gaussLegendre.IntervalEnd, StopA);
}
}
}
Loading…
Cancel
Save