//
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections.Generic;
using IStation.Numerics.Interpolation;
namespace IStation.Numerics
{
///
/// Interpolation Factory.
///
public static class Interpolate
{
///
/// Creates an interpolation based on arbitrary points.
///
/// The sample points t.
/// The sample point values x(t).
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.Barycentric.InterpolateRationalFloaterHormannSorted
/// instead, which is more efficient.
///
public static IInterpolation Common(IEnumerable points, IEnumerable values)
{
return Barycentric.InterpolateRationalFloaterHormann(points, values);
}
///
/// Create a Floater-Hormann rational pole-free interpolation based on arbitrary points.
///
/// The sample points t.
/// The sample point values x(t).
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.Barycentric.InterpolateRationalFloaterHormannSorted
/// instead, which is more efficient.
///
public static IInterpolation RationalWithoutPoles(IEnumerable points, IEnumerable values)
{
return Barycentric.InterpolateRationalFloaterHormann(points, values);
}
///
/// Create a Bulirsch Stoer rational interpolation based on arbitrary points.
///
/// The sample points t.
/// The sample point values x(t).
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.BulirschStoerRationalInterpolation.InterpolateSorted
/// instead, which is more efficient.
///
public static IInterpolation RationalWithPoles(IEnumerable points, IEnumerable values)
{
return BulirschStoerRationalInterpolation.Interpolate(points, values);
}
///
/// Create a barycentric polynomial interpolation where the given sample points are equidistant.
///
/// The sample points t, must be equidistant.
/// The sample point values x(t).
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.Barycentric.InterpolatePolynomialEquidistantSorted
/// instead, which is more efficient.
///
public static IInterpolation PolynomialEquidistant(IEnumerable points, IEnumerable values)
{
return Barycentric.InterpolatePolynomialEquidistant(points, values);
}
///
/// Create a Neville polynomial interpolation based on arbitrary points.
/// If the points happen to be equidistant, consider to use the much more robust PolynomialEquidistant instead.
/// Otherwise, consider whether RationalWithoutPoles would not be a more robust alternative.
///
/// The sample points t.
/// The sample point values x(t).
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.NevillePolynomialInterpolation.InterpolateSorted
/// instead, which is more efficient.
///
public static IInterpolation Polynomial(IEnumerable points, IEnumerable values)
{
return NevillePolynomialInterpolation.Interpolate(points, values);
}
///
/// Create a piecewise linear interpolation based on arbitrary points.
///
/// The sample points t.
/// The sample point values x(t).
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.LinearSpline.InterpolateSorted
/// instead, which is more efficient.
///
public static IInterpolation Linear(IEnumerable points, IEnumerable values)
{
return Interpolation.LinearSpline.Interpolate(points, values);
}
///
/// Create piecewise log-linear interpolation based on arbitrary points.
///
/// The sample points t.
/// The sample point values x(t).
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.LogLinear.InterpolateSorted
/// instead, which is more efficient.
///
public static IInterpolation LogLinear(IEnumerable points, IEnumerable values)
{
return Interpolation.LogLinear.Interpolate(points, values);
}
///
/// Create an piecewise natural cubic spline interpolation based on arbitrary points,
/// with zero secondary derivatives at the boundaries.
///
/// The sample points t.
/// The sample point values x(t).
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.CubicSpline.InterpolateNaturalSorted
/// instead, which is more efficient.
///
public static IInterpolation CubicSpline(IEnumerable points, IEnumerable values)
{
return Interpolation.CubicSpline.InterpolateNatural(points, values);
}
///
/// Create a piecewise cubic Akima spline interpolation based on arbitrary points.
/// Akima splines are robust to outliers.
///
/// The sample points t.
/// The sample point values x(t).
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.CubicSpline.InterpolateAkimaSorted
/// instead, which is more efficient.
///
public static IInterpolation CubicSplineRobust(IEnumerable points, IEnumerable values)
{
return Interpolation.CubicSpline.InterpolateAkima(points, values);
}
///
/// Create a piecewise cubic monotone spline interpolation based on arbitrary points.
/// This is a shape-preserving spline with continuous first derivative.
///
/// The sample points t.
/// The sample point values x(t).
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.CubicSpline.InterpolatePchipSorted
/// instead, which is more efficient.
///
public static IInterpolation CubicSplineMonotone(IEnumerable points, IEnumerable values)
{
return Interpolation.CubicSpline.InterpolatePchip(points, values);
}
///
/// Create a piecewise cubic Hermite spline interpolation based on arbitrary points
/// and their slopes/first derivative.
///
/// The sample points t.
/// The sample point values x(t).
/// The slope at the sample points. Optimized for arrays.
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.CubicSpline.InterpolateHermiteSorted
/// instead, which is more efficient.
///
public static IInterpolation CubicSplineWithDerivatives(IEnumerable points, IEnumerable values, IEnumerable firstDerivatives)
{
return Interpolation.CubicSpline.InterpolateHermite(points, values, firstDerivatives);
}
///
/// Create a step-interpolation based on arbitrary points.
///
/// The sample points t.
/// The sample point values x(t).
///
/// An interpolation scheme optimized for the given sample points and values,
/// which can then be used to compute interpolations and extrapolations
/// on arbitrary points.
///
///
/// if your data is already sorted in arrays, consider to use
/// IStation.Numerics.Interpolation.StepInterpolation.InterpolateSorted
/// instead, which is more efficient.
///
public static IInterpolation Step(IEnumerable points, IEnumerable values)
{
return StepInterpolation.Interpolate(points, values);
}
}
}