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> /// <summary>
/// Getter for the order. /// Getter for the order.
/// </summary> /// </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 Order
public int GetOrder()
{ {
return gaussLegendrePoint.Order; get
{
return gaussLegendrePoint.Order;
}
} }
/// <summary> /// <summary>
/// Getter for the InvervalBegin. /// Getter for the InvervalBegin.
/// </summary> /// </summary>
/// <returns>Where the interval starts, inclusive and finite.</returns> public double IntervalBegin
public double GetIntervalBegin()
{ {
return gaussLegendrePoint.IntervalBegin; get
{
return gaussLegendrePoint.IntervalBegin;
}
} }
/// <summary> /// <summary>
/// Getter for the InvervalEnd. /// Getter for the InvervalEnd.
/// </summary> /// </summary>
/// <returns>Where the interval stops, inclusive and finite.</returns> public double IntervalEnd
public double GetIntervalEnd()
{ {
return gaussLegendrePoint.IntervalEnd; get
{
return gaussLegendrePoint.IntervalEnd;
}
} }
/// <summary> /// <summary>

10
src/UnitTests/IntegrationTests/IntegrationTest.cs

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