diff --git a/src/Managed/Interpolation/Algorithms/BarycentricInterpolation.cs b/src/Managed/Interpolation/Algorithms/BarycentricInterpolation.cs
index 4539d92e..ec391de9 100644
--- a/src/Managed/Interpolation/Algorithms/BarycentricInterpolation.cs
+++ b/src/Managed/Interpolation/Algorithms/BarycentricInterpolation.cs
@@ -64,7 +64,7 @@ namespace MathNet.Numerics.Interpolation.Algorithms
///
/// Initializes a new instance of the BarycentricInterpolation class.
///
- /// Sample Points t
+ /// Sample Points t (no sorting assumed)
/// Sample Values x(t)
/// Barycentric weights w(t)
public BarycentricInterpolation(
@@ -95,7 +95,7 @@ namespace MathNet.Numerics.Interpolation.Algorithms
}
///
- /// Initialize the interpolation method with the given sample set.
+ /// Initialize the interpolation method with the given sample set (no sorting assumed).
///
/// Sample Points t
/// Sample Values x(t)
@@ -153,7 +153,7 @@ namespace MathNet.Numerics.Interpolation.Algorithms
return this.values[0];
}
- // evaluate closest point and offset from that point
+ // evaluate closest point and offset from that point (no sorting assumed)
int closestPoint = 0;
double offset = t - this.points[0];
for (int i = 1; i < this.points.Count; i++)
diff --git a/src/Managed/Interpolation/Algorithms/LinearSplineInterpolation.cs b/src/Managed/Interpolation/Algorithms/LinearSplineInterpolation.cs
index 187444b9..2fe4f5b9 100644
--- a/src/Managed/Interpolation/Algorithms/LinearSplineInterpolation.cs
+++ b/src/Managed/Interpolation/Algorithms/LinearSplineInterpolation.cs
@@ -55,8 +55,8 @@ namespace MathNet.Numerics.Interpolation.Algorithms
///
/// Initializes a new instance of the LinearSplineInterpolation class.
///
- /// Sample Points t
- /// Sample Values x(samplePoints)
+ /// Sample Points t, sorted ascending.
+ /// Sample Values x(t)
public LinearSplineInterpolation(
IList samplePoints,
IList sampleValues)
@@ -85,9 +85,9 @@ namespace MathNet.Numerics.Interpolation.Algorithms
}
///
- /// Initialize the interpolation method with the given spline coefficients.
+ /// Initialize the interpolation method with the given spline coefficients (sorted by the sample points t).
///
- /// Sample Points t
+ /// Sample Points t, sorted ascending.
/// Sample Values x(t)
public void Initialize(
IList samplePoints,
@@ -114,22 +114,16 @@ namespace MathNet.Numerics.Interpolation.Algorithms
}
double[] coefficients = new double[4 * (samplePoints.Count - 1)];
- double[] sortedPoints = new double[samplePoints.Count];
- samplePoints.CopyTo(sortedPoints, 0);
- double[] sortedValues = new double[sampleValues.Count];
- sampleValues.CopyTo(sortedValues, 0);
-
- /* TODO: Sorting.Sort(sortedPoints, sortedValues); */
- for (int i = 0, j = 0; i < sortedPoints.Length - 1; i++, j += 4)
+ for (int i = 0, j = 0; i < samplePoints.Count - 1; i++, j += 4)
{
- coefficients[j] = sortedValues[i];
- coefficients[j + 1] = (sortedValues[i + 1] - sortedValues[i]) / (sortedPoints[i + 1] - sortedPoints[i]);
+ coefficients[j] = sampleValues[i];
+ coefficients[j + 1] = (sampleValues[i + 1] - sampleValues[i]) / (samplePoints[i + 1] - samplePoints[i]);
coefficients[j + 2] = 0;
coefficients[j + 3] = 0;
}
- this.spline.Initialize(sortedPoints, coefficients);
+ this.spline.Initialize(samplePoints, coefficients);
}
///
diff --git a/src/Managed/Interpolation/Algorithms/RationalPoleFreeInterpolation.cs b/src/Managed/Interpolation/Algorithms/RationalPoleFreeInterpolation.cs
index 0be10937..f03c2a5d 100644
--- a/src/Managed/Interpolation/Algorithms/RationalPoleFreeInterpolation.cs
+++ b/src/Managed/Interpolation/Algorithms/RationalPoleFreeInterpolation.cs
@@ -90,7 +90,7 @@ namespace MathNet.Numerics.Interpolation.Algorithms
///
/// The interpolation scheme order will be set to 3.
///
- /// Sample Points t
+ /// Sample Points t (no sorting assumed)
/// Sample Values x(t)
public void Initialize(
IList samplePoints,
@@ -100,7 +100,7 @@ namespace MathNet.Numerics.Interpolation.Algorithms
}
///
- /// Initialize the interpolation method with the given sample set.
+ /// Initialize the interpolation method with the given sample set (no sorting assumed).
///
/// Sample Points t
/// Sample Values x(t)
diff --git a/src/Managed/Interpolation/Algorithms/SplineInterpolation.cs b/src/Managed/Interpolation/Algorithms/SplineInterpolation.cs
index 586b1fee..ffc5d5bb 100644
--- a/src/Managed/Interpolation/Algorithms/SplineInterpolation.cs
+++ b/src/Managed/Interpolation/Algorithms/SplineInterpolation.cs
@@ -64,8 +64,8 @@ namespace MathNet.Numerics.Interpolation.Algorithms
///
/// Initializes a new instance of the SplineInterpolation class.
///
- /// Sample Points t (length: N)
- /// Spline Coefficients (length: 4*(N-1))
+ /// Sample Points t (length: N), sorted ascending.
+ /// Spline Coefficients (length: 4*(N-1)).
public SplineInterpolation(
IList samplePoints,
IList splineCoefficients)
@@ -93,10 +93,10 @@ namespace MathNet.Numerics.Interpolation.Algorithms
}
///
- /// Initialize the interpolation method with the given spline coefficients.
+ /// Initialize the interpolation method with the given spline coefficients (sorted by the sample points t).
///
- /// Sample Points t (length: N)
- /// Spline Coefficients (length: 4*(N-1))
+ /// Sample Points t (length: N), sorted ascending.
+ /// Spline Coefficients (length: 4*(N-1)).
public void Initialize(
IList samplePoints,
IList splineCoefficients)
diff --git a/src/Managed/Interpolation/Interpolation.cs b/src/Managed/Interpolation/Interpolation.cs
index 190572d1..0edcb4cc 100644
--- a/src/Managed/Interpolation/Interpolation.cs
+++ b/src/Managed/Interpolation/Interpolation.cs
@@ -54,9 +54,9 @@ namespace MathNet.Numerics.Interpolation
}
///
- /// Create a linear spline interpolation based on arbitrary points.
+ /// Create a linear spline interpolation based on arbitrary points (sorted ascending).
///
- /// The sample points t. Supports both lists and arrays.
+ /// The sample points t, sorted ascending. Supports both lists and arrays.
/// The sample point values x(t). Supports both lists and arrays.
///
/// An interpolation scheme optimized for the given sample points and values,