Package org.opensourcephysics.numerics
Class CubicSpline
java.lang.Object
org.opensourcephysics.numerics.CubicSpline
- All Implemented Interfaces:
Function
Class description
-
Constructor Summary
ConstructorsConstructorDescriptionCubicSpline
(double[] xdata, double[] ydata) Constructs a natural CubicSpline interpolating function from the given data.CubicSpline
(double[] xdata, double[] ydata, double startDyDx, double endDyDx) Constructs a constrained CubicSpline interpolating function from the given data. -
Method Summary
Modifier and TypeMethodDescriptiondouble
evaluate
(double x) Computes the interpolated y value for a given x value.void
update
(double[] xdata, double[] ydata) Update the natural spline data and recompute the coefficients.void
update
(double[] xdata, double[] ydata, double startDyDx, double endDyDx) Update the constrained spline data and recompute the coefficients.
-
Constructor Details
-
CubicSpline
public CubicSpline(double[] xdata, double[] ydata) Constructs a natural CubicSpline interpolating function from the given data. X data array must be sorted in increasing or decreasing value. The checkSorting method in the Util package can be used to check the sorting of an array.- Parameters:
xdata
- double[]ydata
- double[]
-
CubicSpline
public CubicSpline(double[] xdata, double[] ydata, double startDyDx, double endDyDx) Constructs a constrained CubicSpline interpolating function from the given data. X data array must be sorted in increasing or decreasing value. The checkSorting method in the Util package can be used to check the sorting of an array.- Parameters:
xdata
- double[]ydata
- double[]startDyDx
- double derivative at 0endDyDx
- double derivative at n-1
-
-
Method Details
-
update
public void update(double[] xdata, double[] ydata, double startDyDx, double endDyDx) Update the constrained spline data and recompute the coefficients.- Parameters:
xdata
-ydata
-
-
update
public void update(double[] xdata, double[] ydata) Update the natural spline data and recompute the coefficients.- Parameters:
xdata
-ydata
-
-
evaluate
public double evaluate(double x) Computes the interpolated y value for a given x value. -
firstDerivative
-
secondDerivative
-