I do not understand number two:
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 x belongs. If x is less than the smallest knot point or greater than the largest one, an IllegalArgumentException is thrown.
- 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])
The polynomial array is always one value less than the knot array right? So the second section does not always work? Is there a better way to state number 2?
That just says that if x
belongs to the interval [knot[j], knot[j+1]]
, then the corresponding y
value will be computed as polynomials[j](x - knot[j])
. If your polynomials
array's last index is n
then the last knot
interval will be [knot[n], knot[n+1]]
, meaning the last index of the knot
array is n+1
(so 2 will always hold).