Class PolynomialSplineFunction

  • All Implemented Interfaces:
    UnivariateDifferentiableFunction, FieldUnivariateFunction, UnivariateFunction

    public class PolynomialSplineFunction
    extends Object
    implements UnivariateDifferentiableFunction, FieldUnivariateFunction
    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])
    • Method Detail

      • value

        public double value​(double v)
        Compute the value for the function. See PolynomialSplineFunction for details on the algorithm for computing the value of the function.
        Specified by:
        value in interface UnivariateFunction
        Parameters:
        v - Point for which the function value should be computed.
        Returns:
        the value.
        Throws:
        MathIllegalArgumentException - if v is outside of the domain of the spline function (smaller than the smallest knot point or larger than the largest knot point).
      • polynomialSplineDerivative

        public PolynomialSplineFunction polynomialSplineDerivative()
        Get the derivative of the polynomial spline function.
        Returns:
        the derivative function.
      • value

        public <T extends Derivative<T>> T value​(T t)
        Compute the value for the function.
        Specified by:
        value in interface UnivariateDifferentiableFunction
        Type Parameters:
        T - the type of the field elements
        Parameters:
        t - the point for which the function value should be computed
        Returns:
        the value
      • value

        public <T extends CalculusFieldElement<T>> T value​(T t)
        Compute the value of the function.
        Specified by:
        value in interface FieldUnivariateFunction
        Type Parameters:
        T - the type of the field elements
        Parameters:
        t - Point at which the function value should be computed.
        Returns:
        the value of the function.
      • getN

        public int getN()
        Get the number of spline segments. It is also the number of polynomials and the number of knot points - 1.
        Returns:
        the number of spline segments.
      • getPolynomials

        public PolynomialFunction[] getPolynomials()
        Get a copy of the interpolating polynomials array. It 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()
        Get an array copy of the knot points. It returns a fresh copy of the array. Changes made to the copy will not affect the knots property.
        Returns:
        the knot points.
      • isValidPoint

        public boolean isValidPoint​(double x)
        Indicates whether a point is within the interpolation range.
        Parameters:
        x - Point.
        Returns:
        true if x is a valid point.