Top Description Fields Constructors Methods
org.apache.commons.math3.analysis.polynomials

public Class PolynomialSplineFunction

extends Object
implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.analysis.DifferentiableUnivariateFunction, org.apache.commons.math3.analysis.UnivariateFunction, org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction
Imports
java.util.Arrays, org.apache.commons.math3.analysis.DifferentiableUnivariateFunction, .UnivariateFunction, org.apache.commons.math3.analysis.differentiation.DerivativeStructure, .UnivariateDifferentiableFunction, org.apache.commons.math3.exception.DimensionMismatchException, .NonMonotonicSequenceException, .NullArgumentException, .NumberIsTooSmallException, .OutOfRangeException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.util.MathArrays

Deprecated

as a consequence of DifferentiableUnivariateFunction being deprecated. See corresponding docs for further information.

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.

Note

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])

Field Summary

Modifier and TypeField and Description
private final double[]
knots

Spline segment interval delimiters (knots).

private final int
n

Number of spline segments.

private final PolynomialFunction[]
polynomials

Deprecated as a consequence of PolynomialFunction being deprecated.
The polynomial functions that make up the spline.

Constructor Summary

AccessConstructor and Description
public
PolynomialSplineFunction(double[]
Spline segment interval delimiters.
knots
,
PolynomialFunction[]
Polynomial functions that make up the spline.
polynomials
)
Deprecated as a consequence of PolynomialFunction being deprecated.

Construct a polynomial spline function with the given segment delimiters and interpolating polynomials.

Method Summary

Modifier and TypeMethod and Description
public UnivariateFunction

Returns:

the derivative function.
derivative
()

Implements org.apache.commons.math3.analysis.DifferentiableUnivariateFunction.derivative.

Get the derivative of the polynomial spline function.

public double[]

Returns:

the knot points.
getKnots
()

Get an array copy of the knot points.

public int

Returns:

the number of spline segments.
getN
()

Get the number of spline segments.

public PolynomialFunction[]

Returns:

the interpolating polynomials.
getPolynomials
()
Deprecated as a consequence of PolynomialFunction being deprecated.

Get a copy of the interpolating polynomials array.

public boolean

Returns:

true if x is a valid point.
isValidPoint
(double
Point.
x
)

Indicates whether a point is within the interpolation range.

public PolynomialSplineFunction

Returns:

the derivative function.
polynomialSplineDerivative
()
Deprecated as a consequence of PolynomialSplineFunction being deprecated.

Get the derivative of the polynomial spline function.

public double

Returns:

the value.
value
(double
Point for which the function value should be computed.
v
)

Implements org.apache.commons.math3.analysis.UnivariateFunction.value.

Compute the value for the function.

public DerivativeStructure
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

knotsback to summary
private final double[] knots

Spline segment interval delimiters (knots). Size is n + 1 for n segments.

nback to summary
private final int n

Number of spline segments. It is equal to the number of polynomials and to the number of partition points - 1.

polynomialsback to summary
private final PolynomialFunction[] polynomials

Deprecated

as a consequence of PolynomialFunction being deprecated. See corresponding docs for further information.

The polynomial functions that make up the spline. The first element determines the value of the spline over the first subinterval, the second over the second, etc. Spline function values are determined by evaluating these functions at (x - knot[i]) where i is the knot segment to which x belongs.

Constructor Detail

PolynomialSplineFunctionback to summary
public PolynomialSplineFunction(double[] knots, PolynomialFunction[] polynomials) throws NullArgumentException, NumberIsTooSmallException, DimensionMismatchException, NonMonotonicSequenceException

Deprecated

as a consequence of PolynomialFunction being deprecated. See corresponding docs for further information.

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:double[]

Spline segment interval delimiters.

polynomials:PolynomialFunction[]

Polynomial functions that make up the spline.

Exceptions
NullArgumentException:
if either of the input arrays is null.
NumberIsTooSmallException:
if knots has length less than 2.
DimensionMismatchException:
if polynomials.length != knots.length - 1.
NonMonotonicSequenceException:
if the knots array is not strictly increasing.

Method Detail

derivativeback to summary
public UnivariateFunction derivative()

Implements org.apache.commons.math3.analysis.DifferentiableUnivariateFunction.derivative.

Get the derivative of the polynomial spline function.

Returns:UnivariateFunction

the derivative function.

getKnotsback to summary
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:double[]

the knot points.

getNback to summary
public int getN()

Get the number of spline segments. It is also the number of polynomials and the number of knot points - 1.

Returns:int

the number of spline segments.

getPolynomialsback to summary
public PolynomialFunction[] getPolynomials()

Deprecated

as a consequence of PolynomialFunction being deprecated. See corresponding docs for further information.

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:PolynomialFunction[]

the interpolating polynomials.

isValidPointback to summary
public boolean isValidPoint(double x)

Indicates whether a point is within the interpolation range.

Parameters
x:double

Point.

Returns:boolean

true if x is a valid point.

polynomialSplineDerivativeback to summary
public PolynomialSplineFunction polynomialSplineDerivative()

Deprecated

as a consequence of PolynomialSplineFunction being deprecated. See corresponding docs for further information.

Get the derivative of the polynomial spline function.

Returns:PolynomialSplineFunction

the derivative function.

valueback to summary
public double value(double v)

Implements org.apache.commons.math3.analysis.UnivariateFunction.value.

Compute the value for the function. See PolynomialSplineFunction for details on the algorithm for computing the value of the function.

Parameters
v:double

Point for which the function value should be computed.

Returns:double

the value.

Exceptions
OutOfRangeException:
if v is outside of the domain of the spline function (smaller than the smallest knot point or larger than the largest knot point).
valueback to summary
public DerivativeStructure value(final DerivativeStructure t)

Implements org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction.value.

Doc from org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction.value.

Simple mathematical function.

UnivariateDifferentiableFunction classes compute both the value and the first derivative of the function.

Parameters
t:DerivativeStructure

function input value

Returns:DerivativeStructure

function result

Since
3.1