From 5e0874c46e73fb9dae4c1f9229f2e58360606a05 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Mon, 6 Jul 2009 22:20:55 +0800 Subject: [PATCH] interpolation: minor refactoring Signed-off-by: Christoph Ruegg --- .../InterpolationTests/InterpolationContract.cs | 11 ++++++----- .../InterpolationTests/InterpolationTest.cs | 8 ++++---- .../Algorithms/LinearSplineInterpolation.cs | 2 +- src/Managed/Interpolation/Interpolation.cs | 1 - 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Managed.UnitTests/InterpolationTests/InterpolationContract.cs b/src/Managed.UnitTests/InterpolationTests/InterpolationContract.cs index 2cf1a96b..83985501 100644 --- a/src/Managed.UnitTests/InterpolationTests/InterpolationContract.cs +++ b/src/Managed.UnitTests/InterpolationTests/InterpolationContract.cs @@ -31,9 +31,9 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests using System; using System.Collections.Generic; using Gallio.Framework.Assertions; + using Interpolation; using MbUnit.Framework; using MbUnit.Framework.ContractVerifiers; - using Interpolation; internal class InterpolationContract : AbstractContract where TInterpolation : IInterpolation @@ -51,7 +51,7 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests yield return CreateFactoryReturnsCorrectTypeTest("FactoryReturnsCorrectType"); yield return CreateConsistentCapabilityBehaviorTest("ConsistentCapabilityBehavior"); yield return CreateInterpolationMatchesNodePointsTest("InterpolationMatchesNodePoints"); - yield return CreateCanDealWithLinearSamplesTest("CanDealWithLinearSamples"); + yield return CreateLinearBehaviorTest("LinearBehavior"); } private Test CreateFactoryReturnsCorrectTypeTest(string name) @@ -135,7 +135,7 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests }); } - private Test CreateCanDealWithLinearSamplesTest(string name) + private Test CreateLinearBehaviorTest(string name) { return new TestCase(name, () => { @@ -156,6 +156,8 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests values[i] = yOffset + i; } + var interpolation = Factory(points, values); + // build linear test vectors randomly between the sample points double[] testPoints = new double[order + 1]; double[] testValues = new double[order + 1]; @@ -175,8 +177,7 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests } } - var interpolation = Factory(points, values); - + // verify interpolation with test samples for (int i = 0; i < testPoints.Length; i++) { Assert.AreApproximatelyEqual( diff --git a/src/Managed.UnitTests/InterpolationTests/InterpolationTest.cs b/src/Managed.UnitTests/InterpolationTests/InterpolationTest.cs index 9be797d8..03204ac5 100644 --- a/src/Managed.UnitTests/InterpolationTests/InterpolationTest.cs +++ b/src/Managed.UnitTests/InterpolationTests/InterpolationTest.cs @@ -29,23 +29,23 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests { using System; - using MbUnit.Framework; - using MbUnit.Framework.ContractVerifiers; using Interpolation; using Interpolation.Algorithms; + using MbUnit.Framework; + using MbUnit.Framework.ContractVerifiers; [TestFixture] public class InterpolationTest { [VerifyContract] - public readonly IContract LinearSplineTests = new InterpolationContract() + public readonly IContract LinearSplineContractTests = new InterpolationContract() { Factory = Interpolation.CreateLinearBetweenPoints, Order = new[] { 2, 3, 6 } }; [VerifyContract] - public readonly IContract RationalPoleFreeTests = new InterpolationContract() + public readonly IContract RationalPoleFreeContractTests = new InterpolationContract() { Factory = Interpolation.CreateRationalPoleFree, Order = new[] { 1, 2, 6 } diff --git a/src/Managed/Interpolation/Algorithms/LinearSplineInterpolation.cs b/src/Managed/Interpolation/Algorithms/LinearSplineInterpolation.cs index 56eb7935..e14f7475 100644 --- a/src/Managed/Interpolation/Algorithms/LinearSplineInterpolation.cs +++ b/src/Managed/Interpolation/Algorithms/LinearSplineInterpolation.cs @@ -88,7 +88,7 @@ namespace MathNet.Numerics.Interpolation.Algorithms /// Initialize the interpolation method with the given spline coefficients. /// /// Sample Points t - /// Sample Values x(samplePoints) + /// Sample Values x(t) public void Initialize( IList samplePoints, IList sampleValues) diff --git a/src/Managed/Interpolation/Interpolation.cs b/src/Managed/Interpolation/Interpolation.cs index 8123f2dc..190572d1 100644 --- a/src/Managed/Interpolation/Interpolation.cs +++ b/src/Managed/Interpolation/Interpolation.cs @@ -28,7 +28,6 @@ namespace MathNet.Numerics.Interpolation { - using System; using System.Collections.Generic; using Algorithms;