Class PolynomialSplineFunction

  • All Implemented Interfaces:
    DifferentiableUnivariateRealFunction, UnivariateRealFunction

    public class PolynomialSplineFunction
    extends java.lang.Object
    implements DifferentiableUnivariateRealFunction
    Represents a polynomial spline function.

    A polynomial spline function consists of a set of interpolating polynomials and an ascending array of domain knot points, determining the intervals over which the spline function is defined by the constituent polynomials. The polynomials are assumed to have been computed to match the values of another function at the knot points. The value consistency constraints are not currently enforced by PolynomialSplineFunction itself, but are assumed to hold among the polynomials and knot points passed to the constructor.

    N.B.: The polynomials in the polynomials property must be centered on the knot points to compute the spline function values. See below.

    The domain of the polynomial spline function is [smallest knot, largest knot]. Attempts to evaluate the function at values outside of this range generate IllegalArgumentExceptions.

    The value of the polynomial spline function for an argument x is computed as follows:

    1. The knot array is searched to find the segment to which x belongs. If x is less than the smallest knot point or greater than the largest one, an IllegalArgumentException is thrown.
    2. Let j be the index of the largest knot point that is less than or equal to x. The value returned is
      polynomials[j](x - knot[j])

    Version:
    $Revision: 1037327 $ $Date: 2010-11-20 21:57:37 +0100 (sam. 20 nov. 2010) $
    • Constructor Summary

      Constructors 
      Constructor Description
      PolynomialSplineFunction​(double[] knots, PolynomialFunction[] polynomials)
      Construct a polynomial spline function with the given segment delimiters and interpolating polynomials.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      UnivariateRealFunction derivative()
      Returns the derivative of the polynomial spline function as a UnivariateRealFunction
      double[] getKnots()
      Returns an array copy of the knot points.
      int getN()
      Returns the number of spline segments = the number of polynomials = the number of knot points - 1.
      PolynomialFunction[] getPolynomials()
      Returns a copy of the interpolating polynomials array.
      PolynomialSplineFunction polynomialSplineDerivative()
      Returns the derivative of the polynomial spline function as a PolynomialSplineFunction
      double value​(double v)
      Compute the value for the function.
      • Methods inherited from class java.lang.Object

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

      • PolynomialSplineFunction

        public PolynomialSplineFunction​(double[] knots,
                                        PolynomialFunction[] polynomials)
        Construct a polynomial spline function with the given segment delimiters and interpolating polynomials.

        The constructor copies both arrays and assigns the copies to the knots and polynomials properties, respectively.

        Parameters:
        knots - spline segment interval delimiters
        polynomials - polynomial functions that make up the spline
        Throws:
        java.lang.NullPointerException - if either of the input arrays is null
        java.lang.IllegalArgumentException - if knots has length less than 2, polynomials.length != knots.length - 1 , or the knots array is not strictly increasing.
    • Method Detail

      • polynomialSplineDerivative

        public PolynomialSplineFunction polynomialSplineDerivative()
        Returns the derivative of the polynomial spline function as a PolynomialSplineFunction
        Returns:
        the derivative function
      • getN

        public int getN()
        Returns the number of spline segments = the number of polynomials = the number of knot points - 1.
        Returns:
        the number of spline segments
      • getPolynomials

        public PolynomialFunction[] getPolynomials()
        Returns a copy of the interpolating polynomials array.

        Returns a fresh copy of the array. Changes made to the copy will not affect the polynomials property.

        Returns:
        the interpolating polynomials
      • getKnots

        public double[] getKnots()
        Returns an array copy of the knot points.

        Returns a fresh copy of the array. Changes made to the copy will not affect the knots property.

        Returns:
        the knot points