Class FieldPolynomialSplineFunction<T extends CalculusFieldElement<T>>
- Type Parameters:
T- the type of the field elements
- All Implemented Interfaces:
CalculusFieldUnivariateFunction<T>
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:
- The knot array is searched to find the segment to which
xbelongs. Ifxis less than the smallest knot point or greater than the largest one, anIllegalArgumentExceptionis thrown. - Let
jbe the index of the largest knot point that is less than or equal tox. The value returned ispolynomials[j](x - knot[j])
- Since:
- 1.5
-
Constructor Summary
ConstructorsConstructorDescriptionFieldPolynomialSplineFunction(T[] knots, FieldPolynomialFunction<T>[] polynomials) Construct a polynomial spline function with the given segment delimiters and interpolating polynomials. -
Method Summary
Modifier and TypeMethodDescriptiongetField()Get theFieldto which the instance belongs.T[]getKnots()Get an array copy of the knot points.intgetN()Get the number of spline segments.Get a copy of the interpolating polynomials array.booleanisValidPoint(T x) Indicates whether a point is within the interpolation range.Get the derivative of the polynomial spline function.value(double v) Compute the value for the function.Compute the value for the function.
-
Constructor Details
-
FieldPolynomialSplineFunction
public FieldPolynomialSplineFunction(T[] knots, FieldPolynomialFunction<T>[] polynomials) throws MathIllegalArgumentException, NullArgumentException 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:
NullArgumentException- if either of the input arrays isnull.MathIllegalArgumentException- if knots has length less than 2.MathIllegalArgumentException- ifpolynomials.length != knots.length - 1.MathIllegalArgumentException- if theknotsarray is not strictly increasing.
-
-
Method Details
-
getField
Get theFieldto which the instance belongs.- Returns:
Fieldto which the instance belongs
-
value
Compute the value for the function. SeeFieldPolynomialSplineFunctionfor details on the algorithm for computing the value of the function.- Parameters:
v- Point for which the function value should be computed.- Returns:
- the value.
- Throws:
MathIllegalArgumentException- ifvis outside of the domain of the spline function (smaller than the smallest knot point or larger than the largest knot point).
-
value
Compute the value for the function. SeeFieldPolynomialSplineFunctionfor details on the algorithm for computing the value of the function.- Specified by:
valuein interfaceCalculusFieldUnivariateFunction<T extends CalculusFieldElement<T>>- Parameters:
v- Point for which the function value should be computed.- Returns:
- the value.
- Throws:
MathIllegalArgumentException- ifvis outside of the domain of the spline function (smaller than the smallest knot point or larger than the largest knot point).
-
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
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
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
Indicates whether a point is within the interpolation range.- Parameters:
x- Point.- Returns:
trueifxis a valid point.
-
polynomialSplineDerivative
Get the derivative of the polynomial spline function.- Returns:
- the derivative function.
-