Class AkimaSplineInterpolator

  • All Implemented Interfaces:
    UnivariateInterpolator

    public class AkimaSplineInterpolator
    extends java.lang.Object
    implements UnivariateInterpolator
    Computes a cubic spline interpolation for the data set using the Akima algorithm, as originally formulated by Hiroshi Akima in his 1970 paper "A New Method of Interpolation and Smooth Curve Fitting Based on Local Procedures." J. ACM 17, 4 (October 1970), 589-602. DOI=10.1145/321607.321609 http://doi.acm.org/10.1145/321607.321609

    This implementation is based on the Akima implementation in the CubicSpline class in the Math.NET Numerics library. The method referenced is CubicSpline.InterpolateAkimaSorted

    The interpolate method returns a PolynomialSplineFunction consisting of n cubic polynomials, defined over the subintervals determined by the x values, x[0] < x[i] ... < x[n]. The Akima algorithm requires that n >= 5.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int MINIMUM_NUMBER_POINTS
      The minimum number of points that are needed to compute the function.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private double differentiateThreePoint​(double[] xvals, double[] yvals, int indexOfDifferentiation, int indexOfFirstSample, int indexOfSecondsample, int indexOfThirdSample)
      Three point differentiation helper, modeled off of the same method in the Math.NET CubicSpline class.
      PolynomialSplineFunction interpolate​(double[] xvals, double[] yvals)
      Computes an interpolating function for the data set.
      private PolynomialSplineFunction interpolateHermiteSorted​(double[] xvals, double[] yvals, double[] firstDerivatives)
      Creates a Hermite cubic spline interpolation from the set of (x,y) value pairs and their derivatives.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MINIMUM_NUMBER_POINTS

        private static final int MINIMUM_NUMBER_POINTS
        The minimum number of points that are needed to compute the function.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AkimaSplineInterpolator

        public AkimaSplineInterpolator()
    • Method Detail

      • differentiateThreePoint

        private double differentiateThreePoint​(double[] xvals,
                                               double[] yvals,
                                               int indexOfDifferentiation,
                                               int indexOfFirstSample,
                                               int indexOfSecondsample,
                                               int indexOfThirdSample)
        Three point differentiation helper, modeled off of the same method in the Math.NET CubicSpline class. This is used by both the Apache Math and the Math.NET Akima Cubic Spline algorithms
        Parameters:
        xvals - x values to calculate the numerical derivative with
        yvals - y values to calculate the numerical derivative with
        indexOfDifferentiation - index of the elemnt we are calculating the derivative around
        indexOfFirstSample - index of the first element to sample for the three point method
        indexOfSecondsample - index of the second element to sample for the three point method
        indexOfThirdSample - index of the third element to sample for the three point method
        Returns:
        the derivative
      • interpolateHermiteSorted

        private PolynomialSplineFunction interpolateHermiteSorted​(double[] xvals,
                                                                  double[] yvals,
                                                                  double[] firstDerivatives)
        Creates a Hermite cubic spline interpolation from the set of (x,y) value pairs and their derivatives. This is modeled off of the InterpolateHermiteSorted method in the Math.NET CubicSpline class.
        Parameters:
        xvals - x values for interpolation
        yvals - y values for interpolation
        firstDerivatives - first derivative values of the function
        Returns:
        polynomial that fits the function