Browse Source

Interpolation: use more common terms in Interpolate facade

optimization-3
Christoph Ruegg 13 years ago
parent
commit
749fc5709b
  1. 2
      src/Examples/Interpolation/LinearBetweenPoints.cs
  2. 87
      src/Numerics/Interpolate.cs

2
src/Examples/Interpolation/LinearBetweenPoints.cs

@ -71,7 +71,7 @@ namespace Examples.InterpolationExamples
Console.WriteLine(); Console.WriteLine();
// 2. Create a linear spline interpolation based on arbitrary points // 2. Create a linear spline interpolation based on arbitrary points
var method = Interpolate.LinearBetweenPoints(points, values); var method = Interpolate.LinearSpline(points, values);
Console.WriteLine(@"2. Create a linear spline interpolation based on arbitrary points"); Console.WriteLine(@"2. Create a linear spline interpolation based on arbitrary points");
Console.WriteLine(); Console.WriteLine();

87
src/Numerics/Interpolate.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2010 Math.NET // Copyright (c) 2009-2013 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -50,53 +50,59 @@ namespace MathNet.Numerics
/// </returns> /// </returns>
public static IInterpolation Common(IList<double> points, IList<double> values) public static IInterpolation Common(IList<double> points, IList<double> values)
{ {
return RationalWithoutPoles(points, values); return new FloaterHormannRationalInterpolation(points, values);
} }
/// <summary> /// <summary>
/// Create a linear spline interpolation based on arbitrary points. /// Create a floater hormann rational pole-free interpolation based on arbitrary points.
/// </summary> /// </summary>
/// <param name="points">The sample points t. Optimized for arrays.</param> /// <param name="points">The sample points t. Supports both lists and arrays.</param>
/// <param name="values">The sample point values x(t). Optimized for arrays.</param> /// <param name="values">The sample point values x(t). Supports both lists and arrays.</param>
/// <returns> /// <returns>
/// An interpolation scheme optimized for the given sample points and values, /// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations /// which can then be used to compute interpolations and extrapolations
/// on arbitrary points. /// on arbitrary points.
/// </returns> /// </returns>
/// <remarks> public static IInterpolation RationalWithoutPoles(IList<double> points, IList<double> values)
/// The value pairs do not have to be sorted, but if they are not sorted ascendingly
/// and the passed x and y arguments are arrays, they will be sorted inplace and thus modified.
/// </remarks>
public static IInterpolation LinearBetweenPoints(IEnumerable<double> points, IEnumerable<double> values)
{ {
return LinearSpline.Interpolate(points, values); return new FloaterHormannRationalInterpolation(points, values);
} }
/// <summary> /// <summary>
/// Create an Akima cubic spline interpolation based on arbitrary points. Akima splines are robust to outliers. /// Create a burlisch stoer rational interpolation based on arbitrary points.
/// </summary> /// </summary>
/// <param name="points">The sample points t. Optimized for arrays.</param> /// <param name="points">The sample points t. Supports both lists and arrays.</param>
/// <param name="values">The sample point values x(t). Optimized for arrays.</param> /// <param name="values">The sample point values x(t). Supports both lists and arrays.</param>
/// <returns> /// <returns>
/// An interpolation scheme optimized for the given sample points and values, /// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations /// which can then be used to compute interpolations and extrapolations
/// on arbitrary points. /// on arbitrary points.
/// </returns> /// </returns>
/// <remarks> public static IInterpolation RationalWithPoles(IList<double> points, IList<double> values)
/// The value pairs do not have to be sorted, but if they are not sorted ascendingly
/// and the passed x and y arguments are arrays, they will be sorted inplace and thus modified.
/// </remarks>
public static IInterpolation CubicBetweenPointsRobust(IEnumerable<double> points, IEnumerable<double> values)
{ {
return CubicSpline.InterpolateAkima(points, values); return new BulirschStoerRationalInterpolation(points, values);
} }
/// <summary> /// <summary>
/// Create a hermite cubic spline interpolation based on arbitrary points and their slopes/first derivative. /// Create a barycentric polynomial interpolation where the given sample points are equidistant.
/// </summary>
/// <param name="points">The sample points t, must be equidistant. Supports both lists and arrays.</param>
/// <param name="values">The sample point values x(t). Supports both lists and arrays.</param>
/// <returns>
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
/// </returns>
public static IInterpolation PolynomialEquidistant(IList<double> points, IList<double> values)
{
return new EquidistantPolynomialInterpolation(points, values);
}
/// <summary>
/// Create a piecewise linear spline interpolation based on arbitrary points.
/// </summary> /// </summary>
/// <param name="points">The sample points t. Optimized for arrays.</param> /// <param name="points">The sample points t. Optimized for arrays.</param>
/// <param name="values">The sample point values x(t). Optimized for arrays.</param> /// <param name="values">The sample point values x(t). Optimized for arrays.</param>
/// <param name="firstDerivatives">The slope at the sample points. Optimized for arrays.</param>
/// <returns> /// <returns>
/// An interpolation scheme optimized for the given sample points and values, /// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations /// which can then be used to compute interpolations and extrapolations
@ -106,43 +112,48 @@ namespace MathNet.Numerics
/// The value pairs do not have to be sorted, but if they are not sorted ascendingly /// The value pairs do not have to be sorted, but if they are not sorted ascendingly
/// and the passed x and y arguments are arrays, they will be sorted inplace and thus modified. /// and the passed x and y arguments are arrays, they will be sorted inplace and thus modified.
/// </remarks> /// </remarks>
public static IInterpolation CubicBetweenPointsWithDerivatives(IEnumerable<double> points, IEnumerable<double> values, IEnumerable<double> firstDerivatives) public static IInterpolation LinearSpline(IEnumerable<double> points, IEnumerable<double> values)
{ {
return CubicSpline.InterpolateHermite(points, values, firstDerivatives); return Interpolation.LinearSpline.Interpolate(points, values);
} }
/// <summary> /// <summary>
/// Create a floater hormann rational pole-free interpolation based on arbitrary points. /// Create an piecewise cubic Akima spline interpolation based on arbitrary points. Akima splines are robust to outliers.
/// </summary> /// </summary>
/// <param name="points">The sample points t. Supports both lists and arrays.</param> /// <param name="points">The sample points t. Optimized for arrays.</param>
/// <param name="values">The sample point values x(t). Supports both lists and arrays.</param> /// <param name="values">The sample point values x(t). Optimized for arrays.</param>
/// <returns> /// <returns>
/// An interpolation scheme optimized for the given sample points and values, /// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations /// which can then be used to compute interpolations and extrapolations
/// on arbitrary points. /// on arbitrary points.
/// </returns> /// </returns>
public static IInterpolation RationalWithoutPoles(IList<double> points, IList<double> values) /// <remarks>
/// The value pairs do not have to be sorted, but if they are not sorted ascendingly
/// and the passed x and y arguments are arrays, they will be sorted inplace and thus modified.
/// </remarks>
public static IInterpolation CubicSplineRobust(IEnumerable<double> points, IEnumerable<double> values)
{ {
var method = new FloaterHormannRationalInterpolation(); return Interpolation.CubicSpline.InterpolateAkima(points, values);
method.Initialize(points, values);
return method;
} }
/// <summary> /// <summary>
/// Create a burlish stoer rational interpolation based on arbitrary points. /// Create a piecewise cubic Hermite spline interpolation based on arbitrary points and their slopes/first derivative.
/// </summary> /// </summary>
/// <param name="points">The sample points t. Supports both lists and arrays.</param> /// <param name="points">The sample points t. Optimized for arrays.</param>
/// <param name="values">The sample point values x(t). Supports both lists and arrays.</param> /// <param name="values">The sample point values x(t). Optimized for arrays.</param>
/// <param name="firstDerivatives">The slope at the sample points. Optimized for arrays.</param>
/// <returns> /// <returns>
/// An interpolation scheme optimized for the given sample points and values, /// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations /// which can then be used to compute interpolations and extrapolations
/// on arbitrary points. /// on arbitrary points.
/// </returns> /// </returns>
public static IInterpolation RationalWithPoles(IList<double> points, IList<double> values) /// <remarks>
/// The value pairs do not have to be sorted, but if they are not sorted ascendingly
/// and the passed x and y arguments are arrays, they will be sorted inplace and thus modified.
/// </remarks>
public static IInterpolation CubicSplineWithDerivatives(IEnumerable<double> points, IEnumerable<double> values, IEnumerable<double> firstDerivatives)
{ {
var method = new BulirschStoerRationalInterpolation(); return Interpolation.CubicSpline.InterpolateHermite(points, values, firstDerivatives);
method.Initialize(points, values);
return method;
} }
} }
} }

Loading…
Cancel
Save