NuMFor 9f2ab49 (2024-04-08)
Numerical (Modern) Fortran. Library for Simple Numerical computing

csplines implements interpolation using cubic splines Description: Submodule interpolate More...

Data Types

interface  csplev
 csplev Performs a spline interpolation in a point or in a table More...
 
interface  csplevder
 csplev Performs a spline interpolation in a point or in a table More...
 
interface  cubicspline
 Type used to keep all information on splines. More...
 

Functions/Subroutines

subroutine, public csplrep (x, y, s1, sn, csp)
 cubic spline interpolation between tabulated data After calling this function the result may be used to evaluate the function as:
ynew= csplev(xnew, csp)

 
type(cubicspline) function, public csplder (csp, m)
 csplder Computes the derivative of the cubic spline
 
type(cubicspline) function, public csplantider (csp, m)
 Computes the antiderivative of the CubicSpline approximation.
 
subroutine, public cspl_clean (r)
 Clean-up a spline representation.
 
subroutine, public cspleps (x, y, err)
 cspleps Estimates the error produced by using a spline approximation
 
real(dp) function, public csplint (xl, xu, csp, extrapolate)
 Definite integral of a cubic spline function.
 
real(dp) function, public csplint_square (xl, xu, csp)
 Integral of the square of a function expressed as a cubic spline.
 
real(dp) function, dimension(:), allocatable, public csplroots (csp)
 csplroots Computes the roots of the Spline approximation
 

Detailed Description

csplines implements interpolation using cubic splines Description: Submodule interpolate

Function/Subroutine Documentation

◆ cspl_clean()

subroutine, public cspl_clean ( type(cubicspline), intent(inout) r)

Clean-up a spline representation.

Parameters
[in,out]rCubicSpline

References basic::print_msg().

Here is the call graph for this function:

◆ csplantider()

type(cubicspline) function, public csplantider ( type(cubicspline), intent(in) csp,
integer, intent(in) m )

Computes the antiderivative of the CubicSpline approximation.

The result is a CubicSpline (not exactly, it is a polynomial of order m+4)

Parameters
[in]cspCubicSpline object holding the spline
[in]morder of integration
Returns
spline holding the antiderivative

References polynomial::polyint().

Here is the call graph for this function:

◆ csplder()

type(cubicspline) function, public csplder ( type(cubicspline), intent(in) csp,
integer, intent(in) m )

csplder Computes the derivative of the cubic spline

Parameters
[in]cspInterpolating object
[in]morder of derivation (must be 1 or 2)
Returns
Spline representation of derivative

References polynomial::polyder(), and basic::print_msg().

Here is the call graph for this function:

◆ cspleps()

subroutine, public cspleps ( real(dp), dimension(:), intent(in) x,
real(dp), dimension(size(x)), intent(in) y,
real(dp), dimension(size(x)), intent(out) err )

cspleps Estimates the error produced by using a spline approximation

This subroutine estimates the error introduced by natural cubic spline interpolation in a table x(i),y(i) (i=1,...,n). the interpolation error in the vicinity of x(k) is approximated by the difference between y(k) and the value obtained from the spline that interpolates the table with the k-th point removed. err is the largest relative error along the table.

Note
Some tests seems to show that the error is about one order of magnitude better than estimated by this routine
Modified from Salvat et al, Comp. Phys. Comm. (1995)
Parameters
[in]xgrid points
[in]yvalue of function at grid points
[out]errVector with error estimates

◆ csplint()

real(dp) function, public csplint ( real(dp), intent(in) xl,
real(dp), intent(in) xu,
class(cubicspline), intent(in) csp,
logical, intent(in), optional extrapolate )

Definite integral of a cubic spline function.

Todo
Testing when extrapolate is True
Parameters
[in]xlLower limit in the integral.
[in]xuUpper limit in the integral.
[in]cspInterpolating object
[in]extrapolateFlag signaling if we extrapolate outside interval
Returns
Value of integral

◆ csplint_square()

real(dp) function, public csplint_square ( real(dp), intent(in) xl,
real(dp), intent(in) xu,
type(cubicspline), intent(in) csp )

Integral of the square of a function expressed as a cubic spline.

Todo
Testing
Parameters
[in]xlLower limit in the integral.
[in]xuUpper limit in the integral.
[in]cspInterpolating object
Returns
Value of integral

◆ csplrep()

subroutine, public csplrep ( real(dp), dimension(:), intent(in) x,
real(dp), dimension(:), intent(in) y,
real(dp), intent(in) s1,
real(dp), intent(in) sn,
type(cubicspline), intent(out) csp )

cubic spline interpolation between tabulated data After calling this function the result may be used to evaluate the function as:
ynew= csplev(xnew, csp)

REF.: M.J. Maron, 'Numerical Analysis: A Practical Approach', Macmillan Publ. Co., New York 1982.

Parameters
[in]xindependent grid points
[in]ycorresponding function values
[in]s1second derivative at x(1)
[in]snsecond derivative at x(n) (Natural spline: s1=sn=0)
[out]cspCoefficients stored in

References basic::print_msg().

Referenced by cubicspline::init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ csplroots()

real(dp) function, dimension(:), allocatable, public csplroots ( class(cubicspline), intent(in) csp)

csplroots Computes the roots of the Spline approximation

Parameters
[in]cspSpline approximation to consider
Returns
Roots (zeros) of the spline function

Examples:

real(dp), dimension(:), allocatable :: zeros
zeros = csp%roots()