Browse Source

interpolation test: reorganized to support non-standard-parameter meta algorithms

Signed-off-by: Christoph Ruegg <git@cdrnet.ch>
pull/2/head
Christoph Ruegg 17 years ago
parent
commit
25f3b70a2f
  1. 21
      src/Managed.UnitTests/InterpolationTests/InterpolationContract.cs
  2. 52
      src/Managed.UnitTests/InterpolationTests/InterpolationTest.cs

21
src/Managed.UnitTests/InterpolationTests/InterpolationContract.cs

@ -40,6 +40,7 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests
{
public Func<IList<double>, IList<double>, IInterpolation> Factory { get; set; }
public int[] Order { get; set; }
public bool NonStandardParameters { get; set; }
public bool LinearBehavior { get; set; }
public bool PolynomialBehavior { get; set; }
public bool RationalBehavior { get; set; }
@ -51,24 +52,34 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests
protected override IEnumerable<Test> GetContractVerificationTests()
{
// Infrastructure Tests
yield return CreateFactoryReturnsCorrectTypeTest("FactoryReturnsCorrectType");
yield return CreateConsistentCapabilityBehaviorTest("ConsistentCapabilityBehavior");
yield return CreateInitChecksForNullTest("InitChecksForNull");
yield return CreateInitChecksForMatchingCountTest("InitChecksForMatchingCount");
yield return CreateConstructorInitShortcutTest("ConstructorInitShortcut");
yield return CreateConsistentCapabilityBehaviorTest("ConsistentCapabilityBehavior");
if (!NonStandardParameters)
{
yield return CreateConstructorInitShortcutTest("ConstructorInitShortcut");
}
// Numerics Behavior Tests
yield return CreateInterpolationMatchesNodePointsTest("InterpolationMatchesNodePoints");
if (LinearBehavior)
if (LinearBehavior && !NonStandardParameters)
{
yield return CreateLinearBehaviorTest("LinearBehavior");
}
if (PolynomialBehavior)
if (PolynomialBehavior && !NonStandardParameters)
{
yield return CreatePolynomialBehaviorTest("PolynomialBehavior");
}
if (RationalBehavior)
if (RationalBehavior && !NonStandardParameters)
{
yield return CreateRationalBehaviorTest("RationalBehavior");
}

52
src/Managed.UnitTests/InterpolationTests/InterpolationTest.cs

@ -37,44 +37,66 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests
[TestFixture]
public class InterpolationTest
{
// Direct Algorithms (without precomputations)
[VerifyContract]
public readonly IContract LinearSplineContractTests = new InterpolationContract<LinearSplineInterpolation>()
public readonly IContract NevillePolynomialContractTests = new InterpolationContract<NevillePolynomialInterpolation>()
{
Factory = Interpolate.LinearBetweenPoints,
Order = new[] { 2, 3, 6 },
Factory = (t, x) => new NevillePolynomialInterpolation(t, x),
Order = new[] { 1, 2, 6 },
LinearBehavior = true,
PolynomialBehavior = false,
PolynomialBehavior = true,
RationalBehavior = false
};
[VerifyContract]
public readonly IContract FloaterHormannRationalContractTests = new InterpolationContract<FloaterHormannRationalInterpolation>()
public readonly IContract BulirschStoerRationalContractTests = new InterpolationContract<BulirschStoerRationalInterpolation>()
{
Factory = Interpolate.RationalWithoutPoles,
Factory = Interpolate.RationalWithPoles,
Order = new[] { 1, 2, 6 },
LinearBehavior = true,
LinearBehavior = false,
PolynomialBehavior = true,
RationalBehavior = true
};
// Barycentric Algorithms
[VerifyContract]
public readonly IContract NevillePolynomialContractTests = new InterpolationContract<NevillePolynomialInterpolation>()
public readonly IContract BarycentricContractTests = new InterpolationContract<BarycentricInterpolation>()
{
Factory = (t, x) => new NevillePolynomialInterpolation(t, x),
Factory = (t, x) => new BarycentricInterpolation(t, x, FloaterHormannRationalInterpolation.EvaluateBarycentricWeights(t, x, 2)),
Order = new[] { 1, 2, 6 },
LinearBehavior = true,
PolynomialBehavior = true,
RationalBehavior = false
NonStandardParameters = true,
};
[VerifyContract]
public readonly IContract BulirschStoerRationalContractTests = new InterpolationContract<BulirschStoerRationalInterpolation>()
public readonly IContract FloaterHormannRationalContractTests = new InterpolationContract<FloaterHormannRationalInterpolation>()
{
Factory = Interpolate.RationalWithPoles,
Factory = Interpolate.RationalWithoutPoles,
Order = new[] { 1, 2, 6 },
LinearBehavior = false,
LinearBehavior = true,
PolynomialBehavior = true,
RationalBehavior = true
};
// Spline Algorithms
[VerifyContract]
public readonly IContract SplineContractTests = new InterpolationContract<SplineInterpolation>()
{
Factory = (t, x) => new SplineInterpolation(t, LinearSplineInterpolation.EvaluateSplineCoefficients(t, x)),
Order = new[] { 1, 2, 6 },
NonStandardParameters = true,
};
[VerifyContract]
public readonly IContract LinearSplineContractTests = new InterpolationContract<LinearSplineInterpolation>()
{
Factory = Interpolate.LinearBetweenPoints,
Order = new[] { 2, 3, 6 },
LinearBehavior = true,
PolynomialBehavior = false,
RationalBehavior = false
};
}
}

Loading…
Cancel
Save