Skip to content

spline_interp

Fabian Kindermann edited this page Apr 2, 2021 · 5 revisions
subroutine spline_interp(x, c)

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 subroutine spline_interp determines the parameters of 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 , see grid_Cons_Equi or grid_Cons_Grow. To this end, it calculates an array of coefficients c that contains all necessary information about the spline function. Note that for the calculation of these coefficients, no information about the interpolation nodes is needed. Note further, that this subroutine can interpolate data from one up to seven dimensions. Click on the respective number of dimensions you want to use for interpolation in order to get a description of the input and output variables.

One-dimensional spline interpolation

Input arguments:

  • real*8 :: yi(:)
    A one-dimensional array containing the interpolation data at the (equidistant or growing) nodes . Note that no information about the nodes needs to be supplied at this point.

Output arguments:

  • real*8 :: c(:)
    A one-dimensional array into which the subroutine spline_interp stores all necessary information about the interpolating spline function. Note that the array c must have exactly two more elements than the array yi, meaning that when the input data is defined as yi(0:n), then the coefficients need to be of length c(0:n+2)

Two-dimensional spline interpolation

Input arguments:

  • real*8 :: yi(:, :)
    A two-dimensional array containing the interpolation data at the (equidistant or growing) node combinations . Note that no information about the nodes needs to be supplied at this point.

Output arguments:

  • real*8 :: c(:, :)
    A two-dimensional array into which the subroutine spline_interp stores all necessary information about the interpolating spline function. Note that in each dimension, the array c must have exactly two more elements than the array yi, meaning that when the input data is defined as yi(0:n), then the coefficients need to be of length c(0:n+2)

Three-dimensional spline interpolation

Input arguments:

  • real*8 :: yi(:, :, :)
    A three-dimensional array containing the interpolation data at the (equidistant or growing) node combinations . Note that no information about the nodes needs to be supplied at this point.

Output arguments:

  • real*8 :: c(:, :, :)
    A three-dimensional array into which the subroutine spline_interp stores all necessary information about the interpolating spline function. Note that in each dimension, the array c must have exactly two more elements than the array yi, meaning that when the input data is defined as yi(0:n), then the coefficients need to be of length c(0:n+2)

Four-dimensional spline interpolation

Input arguments:

  • real*8 :: yi(:, :, :, :)
    A four-dimensional array containing the interpolation data at the (equidistant or growing) node combinations . Note that no information about the nodes needs to be supplied at this point.

Output arguments:

  • real*8 :: c(:, :, :, :)
    A four-dimensional array into which the subroutine spline_interp stores all necessary information about the interpolating spline function. Note that in each dimension, the array c must have exactly two more elements than the array yi, meaning that when the input data is defined as yi(0:n), then the coefficients need to be of length c(0:n+2)

Five-dimensional spline interpolation

Input arguments:

  • real*8 :: yi(:, :, :, :, :)
    A five-dimensional array containing the interpolation data at the (equidistant or growing) node combinations . Note that no information about the nodes needs to be supplied at this point.

Output arguments:

  • real*8 :: c(:, :, :, :, :)
    A five-dimensional array into which the subroutine spline_interp stores all necessary information about the interpolating spline function. Note that in each dimension, the array c must have exactly two more elements than the array yi, meaning that when the input data is defined as yi(0:n), then the coefficients need to be of length c(0:n+2)

Six-dimensional spline interpolation

Input arguments:

  • real*8 :: yi(:, :, :, :, :, :)
    A six-dimensional array containing the interpolation data at the (equidistant or growing) node combinations . Note that no information about the nodes needs to be supplied at this point.

Output arguments:

  • real*8 :: c(:, :, :, :, :, :)
    A six-dimensional array into which the subroutine spline_interp stores all necessary information about the interpolating spline function. Note that in each dimension, the array c must have exactly two more elements than the array yi, meaning that when the input data is defined as yi(0:n), then the coefficients need to be of length c(0:n+2)

Seven-dimensional spline interpolation

Input arguments:

  • real*8 :: yi(:, :, :, :, :, :, :)
    A seven-dimensional array containing the interpolation data at the (equidistant or growing) node combinations . Note that no information about the nodes needs to be supplied at this point.

Output arguments:

  • real*8 :: c(:, :, :, :, :, :, :)
    A seven-dimensional array into which the subroutine spline_interp stores all necessary information about the interpolating spline function. Note that in each dimension, the array c must have exactly two more elements than the array yi, meaning that when the input data is defined as yi(0:n), then the coefficients need to be of length c(0:n+2)

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_06.f90
    • prog08_07.f90
    • prog09_01.f90
    • prog09_02.f90
    • prog09_03.f90
    • prog09_04.f90
    • prog09_05.f90
    • prog09_06.f90
    • prog09_07.f90
Clone this wiki locally