org.apache.commons.math3.analysis.interpolation

## Class BicubicSplineInterpolatingFunction

- java.lang.Object
- - org.apache.commons.math3.analysis.interpolation.BicubicSplineInterpolatingFunction

All Implemented Interfaces:
  BivariateFunction

    public class BicubicSplineInterpolatingFunction
    extends java.lang.Object
    implements BivariateFunction

Function that implements the bicubic spline interpolation.

Since:
  2.1
Version:
  $Id: BicubicSplineInterpolatingFunction.java 1379904 2012-09-01 23:54:52Z erans $

### Field Summary

Fields
`private static double[][]` `AINV` Matrix to compute the spline coefficients from the function values and function derivatives values
`private BivariateFunction[][][]` `partialDerivatives` Partial derivatives The value of the first index determines the kind of derivatives: 0 = first partial derivatives wrt x 1 = first partial derivatives wrt y 2 = second partial derivatives wrt x 3 = second partial derivatives wrt y 4 = cross partial derivatives
`private BicubicSplineFunction[][]` `splines` Set of cubic splines patching the whole data grid
`private double[]` `xval` Samples x-coordinates
`private double[]` `yval` Samples y-coordinates

### Constructor Summary

Constructors
Constructor and Description
`BicubicSplineInterpolatingFunction(double[] x, double[] y, double[][] f, double[][] dFdX, double[][] dFdY, double[][] d2FdXdY)`

### Method Summary

Methods
`private void` `computePartialDerivatives()` Compute all partial derivatives.
`private double[]` `computeSplineCoefficients(double[] beta)` Compute the spline coefficients from the list of function values and function partial derivatives values at the four corners of a grid element.
`private double` `partialDerivative(int which, double x, double y)`
`double` `partialDerivativeX(double x, double y)`
`double` `partialDerivativeXX(double x, double y)`
`double` `partialDerivativeXY(double x, double y)`
`double` `partialDerivativeY(double x, double y)`
`double` `partialDerivativeYY(double x, double y)`
`private int` `searchIndex(double c, double[] val)`
`double` `value(double x, double y)` Compute the value for the function.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### AINV

    private static final double[][] AINV

Matrix to compute the spline coefficients from the function values and function derivatives values

#### xval

    private final double[] xval

Samples x-coordinates

#### yval

    private final double[] yval

Samples y-coordinates

#### splines

    private final BicubicSplineFunction[][] splines

Set of cubic splines patching the whole data grid

#### partialDerivatives

    private BivariateFunction[][][] partialDerivatives

Partial derivatives The value of the first index determines the kind of derivatives: 0 = first partial derivatives wrt x 1 = first partial derivatives wrt y 2 = second partial derivatives wrt x 3 = second partial derivatives wrt y 4 = cross partial derivatives

### Constructor Detail

#### BicubicSplineInterpolatingFunction

    public BicubicSplineInterpolatingFunction(double[] x,
                                      double[] y,
                                      double[][] f,
                                      double[][] dFdX,
                                      double[][] dFdY,
                                      double[][] d2FdXdY)
                                       throws DimensionMismatchException,
                                              NoDataException,
                                              NonMonotonicSequenceException

Parameters:
  `x` - Sample values of the x-coordinate, in increasing order.
  `y` - Sample values of the y-coordinate, in increasing order.
  `f` - Values of the function on every grid point.
  `dFdX` - Values of the partial derivative of function with respect to x on every grid point.
  `dFdY` - Values of the partial derivative of function with respect to y on every grid point.
  `d2FdXdY` - Values of the cross partial derivative of function on every grid point.
Throws:
  `DimensionMismatchException` - if the various arrays do not contain the expected number of elements.
  `NonMonotonicSequenceException` - if `x` or `y` are not strictly increasing.
  `NoDataException` - if any of the arrays has zero length.

### Method Detail

#### value

    public double value(double x,
               double y)
                 throws OutOfRangeException

Compute the value for the function.

Specified by:
  `value` in interface `BivariateFunction`
Parameters:
  `x` - Abscissa for which the function value should be computed.
  `y` - Ordinate for which the function value should be computed.
Returns:
  the value.
Throws:
  `OutOfRangeException`

#### partialDerivativeX

    public double partialDerivativeX(double x,
                            double y)
                              throws OutOfRangeException

Parameters:
  `x` - x-coordinate.
  `y` - y-coordinate.
Returns:
  the value at point (x, y) of the first partial derivative with respect to x.
Throws:
  `OutOfRangeException` - if `x` (resp. `y`) is outside the range defined by the boundary values of `xval` (resp. `yval`).

#### partialDerivativeY

    public double partialDerivativeY(double x,
                            double y)
                              throws OutOfRangeException

Parameters:
  `x` - x-coordinate.
  `y` - y-coordinate.
Returns:
  the value at point (x, y) of the first partial derivative with respect to y.
Throws:
  `OutOfRangeException` - if `x` (resp. `y`) is outside the range defined by the boundary values of `xval` (resp. `yval`).

#### partialDerivativeXX

    public double partialDerivativeXX(double x,
                             double y)
                               throws OutOfRangeException

Parameters:
  `x` - x-coordinate.
  `y` - y-coordinate.
Returns:
  the value at point (x, y) of the second partial derivative with respect to x.
Throws:
  `OutOfRangeException` - if `x` (resp. `y`) is outside the range defined by the boundary values of `xval` (resp. `yval`).

#### partialDerivativeYY

    public double partialDerivativeYY(double x,
                             double y)
                               throws OutOfRangeException

Parameters:
  `x` - x-coordinate.
  `y` - y-coordinate.
Returns:
  the value at point (x, y) of the second partial derivative with respect to y.
Throws:
  `OutOfRangeException` - if `x` (resp. `y`) is outside the range defined by the boundary values of `xval` (resp. `yval`).

#### partialDerivativeXY

    public double partialDerivativeXY(double x,
                             double y)
                               throws OutOfRangeException

Parameters:
  `x` - x-coordinate.
  `y` - y-coordinate.
Returns:
  the value at point (x, y) of the second partial cross-derivative.
Throws:
  `OutOfRangeException` - if `x` (resp. `y`) is outside the range defined by the boundary values of `xval` (resp. `yval`).

#### partialDerivative

    private double partialDerivative(int which,
                           double x,
                           double y)
                              throws OutOfRangeException

Parameters:
  `which` - First index in `partialDerivatives`.
  `x` - x-coordinate.
  `y` - y-coordinate.
Returns:
  the value at point (x, y) of the selected partial derivative.
Throws:
  `OutOfRangeException` - if `x` (resp. `y`) is outside the range defined by the boundary values of `xval` (resp. `yval`).

#### computePartialDerivatives

    private void computePartialDerivatives()

Compute all partial derivatives.

#### searchIndex

    private int searchIndex(double c,
                  double[] val)

Parameters:
  `c` - Coordinate.
  `val` - Coordinate samples.
Returns:
  the index in `val` corresponding to the interval containing `c`, or `-1` if `c` is out of the range defined by the boundary values of `val`.

#### computeSplineCoefficients

    private double[] computeSplineCoefficients(double[] beta)

Compute the spline coefficients from the list of function values and function partial derivatives values at the four corners of a grid element. They must be specified in the following order:

- f(0,0)
- f(1,0)
- f(0,1)
- f(1,1)
- fx(0,0)
- fx(1,0)
- fx(0,1)
- fx(1,1)
- fy(0,0)
- fy(1,0)
- fy(0,1)
- fy(1,1)
- fxy(0,0)
- fxy(1,0)
- fxy(0,1)
- fxy(1,1)

where the subscripts indicate the partial derivative with respect to the corresponding variable(s).

Parameters:
  `beta` - List of function values and function partial derivatives values.
Returns:
  the spline coefficients.