Skip to content

spline_eval

Fabian Kindermann edited this page Apr 1, 2021 · 11 revisions
function spline_eval(x, c, left, right, growth)

Description:

The subroutine spline interpolates one or multi-dimensional data using piecewise third order polynomial or spline function. It does so in one step, meaning that it calculates the parameters defining the interpolating spline and directly uses them to evaluate the resulting spline function at one or several points. Sometimes, it however proves useful to separate the steps of determining the spline and evaluating it. This can be the case when the same spline function shall be used several times in different locations of a program.

The subroutine spline_interp together with the function spline_eval therefore decompose the spline interpolation process into two steps. The function spline_eval evaluates the cubic spline function that interpolates the data that is located on either an equidistant grid of nodes or one with nodes of growing distance at a certain point x. To this end, it the coefficient array c that was determined with the subroutine spline_interp. Note that this function can interpolate data from one up to seven dimensions. If interpolation data is supplied for more than one dimension, it must be located on a rectilinear grid that is created from the Tensor product of equidistant or growing nodes along each dimension. More specifically, for interpolation in dimension, the interpolation data is

Along each dimension , the points form an equidistant or growing grid. Click on the respective number of dimensions you want to use for interpolation in order to get a description of the input variables needed for this function.

  • One-dimensional spline interpolation

    Input arguments:

    • real*8 :: x
      The point where to evaluate the interpolating spline. Note that this function does not support calculating spline values for multiple points at once. To do so, you have to call the function several times.
    • real*8 :: c(:)
      A one-dimensional array containing the spline coefficients that correspond to the interpolation data at the (equidistant or growing) nodes . These coefficients can be calculated using the subroutine spline_interp. Note that the nodes themselves need not be supplied, but they are rather defined by the input variables left, right and growth.
    • real*8 :: left
      The left interval endpoint of the (equidistant or growing) grid .
    • real*8 :: right
      The right interval endpoint of the (equidistant or growing) grid .

    Optional arguments:

    • real*8 :: growth
      If the gridpoints for which the interpolation data are supplied have a growing distance, you can supply the growth rate through this optional variable. If nothing is passed to the function, it will assume that the interpolation nodes are equidistant.

    Return Value:

    • real*8 :: spline
      The value of the interpolating spline function at the point supplied in x.
  • Two-dimensional spline interpolation

    Input arguments:

    • real*8 :: x(2)
      The point where to evaluate the interpolating spline. This needs to be a one-dimensional array of length 2 through which coordinates along each of the interpolation dimensions are supplied. Note that this function does not support calculating spline values for multiple points at once. To do so, you have to call the function several times.
    • real*8 :: c(:, :)
      A two-dimensional array containing the spline coefficients that correspond to the interpolation data at the (equidistant or growing) node combinations . These coefficients can be calculated using the subroutine spline_interp. Note that the nodes themselves need not be supplied, but they are rather defined by the input variables left, right and growth.
    • real*8 :: left(2)
      The left interval endpoint of the (equidistant or growing) grid in each interpolation dimension.
    • real*8 :: right(2)
      The right interval endpoint of the (equidistant or growing) grid in each interpolation dimension.

    Optional arguments:

    • real*8 :: growth(2)
      If the gridpoints for which the interpolation data are supplied have a growing distance, you can supply the growth rate for each dimension through this optional variable. If nothing is passed to the function, it will assume that the interpolation nodes are equidistant.

    Return Value:

    • real*8 :: spline
      The value of the interpolating spline function at the point supplied in x.
  • Three-dimensional spline interpolation

    Input arguments:

    • real*8 :: x(3)
      The point where to evaluate the interpolating spline. This needs to be a one-dimensional array of length 3 through which coordinates along each of the interpolation dimensions are supplied. Note that this function does not support calculating spline values for multiple points at once. To do so, you have to call the function several times.
    • real*8 :: c(:, :, :)
      A three-dimensional array containing the spline coefficients that correspond to the interpolation data at the (equidistant or growing) node combinations . These coefficients can be calculated using the subroutine spline_interp. Note that the nodes themselves need not be supplied, but they are rather defined by the input variables left, right and growth.
    • real*8 :: left(3)
      The left interval endpoint of the (equidistant or growing) grid in each interpolation dimension.
    • real*8 :: right(3)
      The right interval endpoint of the (equidistant or growing) grid in each interpolation dimension.

    Optional arguments:

    • real*8 :: growth(3)
      If the gridpoints for which the interpolation data are supplied have a growing distance, you can supply the growth rate for each dimension through this optional variable. If nothing is passed to the function, it will assume that the interpolation nodes are equidistant.

    Return Value:

    • real*8 :: spline
      The value of the interpolating spline function at the point supplied in x.
  • Four-dimensional spline interpolation

    Input arguments:

    • real*8 :: x(4)
      The point where to evaluate the interpolating spline. This needs to be a one-dimensional array of length 4 through which coordinates along each of the interpolation dimensions are supplied. Note that this function does not support calculating spline values for multiple points at once. To do so, you have to call the function several times.
    • real*8 :: c(:, :, :, :)
      A four-dimensional array containing the spline coefficients that correspond to the interpolation data at the (equidistant or growing) node combinations . These coefficients can be calculated using the subroutine spline_interp. Note that the nodes themselves need not be supplied, but they are rather defined by the input variables left, right and growth.
    • real*8 :: left(4)
      The left interval endpoint of the (equidistant or growing) grid in each interpolation dimension.
    • real*8 :: right(4)
      The right interval endpoint of the (equidistant or growing) grid in each interpolation dimension.

    Optional arguments:

    • real*8 :: growth(4)
      If the gridpoints for which the interpolation data are supplied have a growing distance, you can supply the growth rate for each dimension through this optional variable. If nothing is passed to the function, it will assume that the interpolation nodes are equidistant.

    Return Value:

    • real*8 :: spline
      The value of the interpolating spline function at the point supplied in x.
  • Five-dimensional spline interpolation

    Input arguments:

    • real*8 :: x(5)
      The point where to evaluate the interpolating spline. This needs to be a one-dimensional array of length 5 through which coordinates along each of the interpolation dimensions are supplied. Note that this function does not support calculating spline values for multiple points at once. To do so, you have to call the function several times.
    • real*8 :: c(:, :, :, :, :)
      A five-dimensional array containing the spline coefficients that correspond to the interpolation data at the (equidistant or growing) node combinations . These coefficients can be calculated using the subroutine spline_interp. Note that the nodes themselves need not be supplied, but they are rather defined by the input variables left, right and growth.
    • real*8 :: left(5)
      The left interval endpoint of the (equidistant or growing) grid in each interpolation dimension.
    • real*8 :: right(5)
      The right interval endpoint of the (equidistant or growing) grid in each interpolation dimension.

    Optional arguments:

    • real*8 :: growth(5)
      If the gridpoints for which the interpolation data are supplied have a growing distance, you can supply the growth rate for each dimension through this optional variable. If nothing is passed to the function, it will assume that the interpolation nodes are equidistant.

    Return Value:

    • real*8 :: spline
      The value of the interpolating spline function at the point supplied in x.
  • Six-dimensional spline interpolation

    Input arguments:

    • real*8 :: x(6)
      The point where to evaluate the interpolating spline. This needs to be a one-dimensional array of length 6 through which coordinates along each of the interpolation dimensions are supplied. Note that this function does not support calculating spline values for multiple points at once. To do so, you have to call the function several times.
    • real*8 :: c(:, :, :, :, :, :)
      A six-dimensional array containing the spline coefficients that correspond to the interpolation data at the (equidistant or growing) node combinations . These coefficients can be calculated using the subroutine spline_interp. Note that the nodes themselves need not be supplied, but they are rather defined by the input variables left, right and growth.
    • real*8 :: left(6)
      The left interval endpoint of the (equidistant or growing) grid in each interpolation dimension.
    • real*8 :: right(6)
      The right interval endpoint of the (equidistant or growing) grid in each interpolation dimension.

    Optional arguments:

    • real*8 :: growth(6)
      If the gridpoints for which the interpolation data are supplied have a growing distance, you can supply the growth rate for each dimension through this optional variable. If nothing is passed to the function, it will assume that the interpolation nodes are equidistant.

    Return Value:

    • real*8 :: spline
      The value of the interpolating spline function at the point supplied in x.
  • Seven-dimensional spline interpolation

    Input arguments:

    • real*8 :: x(7)
      The point where to evaluate the interpolating spline. This needs to be a one-dimensional array of length 7 through which coordinates along each of the interpolation dimensions are supplied. Note that this function does not support calculating spline values for multiple points at once. To do so, you have to call the function several times.
    • real*8 :: c(:, :, :, :, :, :, :)
      A seven-dimensional array containing the spline coefficients that correspond to the interpolation data at the (equidistant or growing) node combinations . These coefficients can be calculated using the subroutine spline_interp. Note that the nodes themselves need not be supplied, but they are rather defined by the input variables left, right and growth.
    • real*8 :: left(7)
      The left interval endpoint of the (equidistant or growing) grid in each interpolation dimension.
    • real*8 :: right(7)
      The right interval endpoint of the (equidistant or growing) grid in each interpolation dimension.

    Optional arguments:

    • real*8 :: growth(7)
      If the gridpoints for which the interpolation data are supplied have a growing distance, you can supply the growth rate for each dimension through this optional variable. If nothing is passed to the function, it will assume that the interpolation nodes are equidistant.

    Return Value:

    • real*8 :: spline
      The value of the interpolating spline function at the point supplied in x.

References

  • For further reading refer to:
    • Süli, E. & Mayers, D. F. (2003). An Introduction to Numerical Analysis. Cambridge: Cambridge University Press.
    • Powell, M.J.D. (1996). Approximation Theory and Methods. Cambridge: Cambridge University Press.
    • Habermann, C. & Kindermann, F. (2007). Multidimensional spline interpolation: Theory and applications. Computational Economics, 30(2), 153-169.
  • This routine is used in the following programs:
    • prog02_18.f90
    • prog02_19.f90
    • prog08_05.f90
    • prog08_05m.f90
    • prog08_06.f90
    • prog08_06m.f90
    • prog08_07.f90
    • prog09_01.f90
    • prog09_01m.f90
    • prog09_02.f90
    • prog09_02m.f90
    • prog09_03.f90
    • prog09_03m.f90
    • prog09_04.f90
    • prog09_04m.f90
    • prog09_05.f90
    • prog09_05m.f90
    • prog09_06.f90
    • prog09_06m.f90
    • prog09_07.f90
    • prog09_07m.f90
Clone this wiki locally