|
NuMFor cf0f85d (2025-09-27)
Numerical (Modern) Fortran. Library for Simple Numerical computing
|
fitpack provides a framework for fitting and interpolation using B-Splines. Description: Submodule interpolate More...
Data Types | |
| interface | splev |
| splev Computes a B-spline or its derivatives. More... | |
| interface | splint |
| splint Evaluates the definite integral of a B-spline. More... | |
| type | univspline |
| Type used to keep all information on spline fitting. More... | |
Functions/Subroutines | |
| subroutine, public | splprep (x, u, tck, w, ulim, k, task, upar, s, t, per, ier) |
| splprep Computes the B-spline representation of an N-dimensional curve. | |
| subroutine, public | splrep (x, y, w, xb, xe, k, task, s, t, per, tck, ier) |
splrep Finds the B-spline representation of 1-D curve. Given the set of data points (x[i], y[i]) determine a smooth spline approximation of degree k on the interval xb <= x <= xe. | |
| real(dp) function, dimension(:), allocatable, public | splroot (tck) |
| splroot Computes the roots of a cubic B-spline. | |
fitpack provides a framework for fitting and interpolation using B-Splines. Description: Submodule interpolate
It uses routines from a slightly cleaned-up f90 version of FITPACK by P. Diercxx
| type fitpack::univspline |
Type used to keep all information on spline fitting.
| subroutine, public splprep | ( | real(dp), dimension(:, :), intent(in) | x, |
| real(dp), dimension(:), intent(inout) | u, | ||
| type(univspline), intent(out) | tck, | ||
| real(dp), dimension(size(x(1, :))), intent(in), optional, target | w, | ||
| real(dp), dimension(2), intent(inout), optional | ulim, | ||
| integer, intent(in), optional | k, | ||
| integer, intent(in), optional | task, | ||
| logical, intent(in), optional | upar, | ||
| real(dp), intent(in), optional | s, | ||
| real(dp), dimension(:), intent(in), optional | t, | ||
| logical, intent(in), optional | per, | ||
| integer, intent(out), optional | ier ) |
splprep Computes the B-spline representation of an N-dimensional curve.
Given a list of N rank-1 arrays, x, which represent a curve in N-dimensional space parametrized by u, find a smooth approximating spline curve g(u). Uses the routine parcur from (slightly modified) FITPACK.
| [in] | x | 2D-Array representing the curve in an n-dimensional space |
| [in,out] | u | An array with parameters. The routine will fill it if upar is False or not present. |
| [in] | w | Strictly positive rank-1 array of weights the same size as u. |
| [in,out] | ulim | Lower and upper limits of the interval to approximate (ulim(1) <= u(1) and ulim(2) >= u(m) ) |
| [in] | k | The degree of the spline fit. It is recommended to use cubic splines. Even values of k should be avoided especially with small s values. 1 <= k <= 5 |
| [in] | task | {1, 0, -1},\
|
| [in] | s | A smoothing condition. The amount of smoothness is determined by satisfying the conditions:sum((w * (y - g))**2) <= s where g(x) is the smoothed interpolation of (x,y).The user can use s to control the tradeoff between closeness and smoothness of fit. Larger s means more smoothing while smaller values of s indicate less smoothing. Recommended values of s depend on the weights, w.If the weights represent the inverse of the standard-deviation of y, then a good s value should be found in the range s = 0.0 (interpolating) if no weights are supplied. |
| [in] | t | Input knots (interior knots only) needed for task = -1. If given then task is automatically set to -1. |
| [in] | upar | Flag indicating if u is given or must be automatically calculated. Default .False. |
| [in] | per | Flag indicating if data are considered periodic |
| [out] | tck | Coefficients, knots, and additional information for interpolation/fitting. On output the following values of tck will be set:
|
For tasks -1, or 1, on input the user may provide values for: wrk and iwrk: (but are usually set by a previous call)
| [out] | ier | Error code |
Full example in Submodule interpolate
| subroutine, public splrep | ( | real(dp), dimension(:), intent(in) | x, |
| real(dp), dimension(size(x)), intent(in) | y, | ||
| real(dp), dimension(size(x)), intent(in), optional | w, | ||
| real(dp), intent(in), optional | xb, | ||
| real(dp), intent(in), optional | xe, | ||
| integer, intent(in), optional | k, | ||
| integer, intent(in), optional | task, | ||
| real(dp), intent(in), optional | s, | ||
| real(dp), dimension(:), intent(in), optional | t, | ||
| logical, intent(in), optional | per, | ||
| type(univspline), intent(out) | tck, | ||
| integer, intent(out), optional | ier ) |
splrep Finds the B-spline representation of 1-D curve. Given the set of data points (x[i], y[i]) determine a smooth spline approximation of degree k on the interval xb <= x <= xe.
| [in] | x | Values of independent variable |
| [in] | y | The data points y=f(x) |
| [in] | w | Strictly positive rank-1 array of weights the same size as x and y. The weights are used in computing the weighted least-squares spline fit. If the errors in the y values have standard-deviation given by the vector d, then w should be 1/d. |
| [in] | xb | Lower limit of the interval to approximate (xb <= x(1)) |
| [in] | xe | Upper limit of the interval to approximate (xe >= x(size(x))). |
| [in] | k | The degree of the spline fit. It is recommended to use cubic splines. Even values of k should be avoided especially with small s values. 1 <= k <= 5 |
| [in] | task | {1, 0, -1},
|
| [in] | s | A smoothing condition. The amount of smoothness is determined by satisfying the conditions:sum((w * (y - g))**2) <= s where g(x) is the smoothed interpolation of (x,y). The user can use s to control the tradeoff between closeness and smoothness of fit. Larger s means more smoothing while smaller values of s indicate less smoothing. Recommended values of s depend on the weights, w.If the weights represent the inverse of the standard-deviation of y, then a good s value should be found in the range s = 0.0 (interpolating) if no weights are supplied. |
| [in] | t | Input knots (interior knots only) for task = -1. If given then task is automatically set to -1. |
| [in] | per | Flag indicating if data are considered periodic |
| [out] | tck | Coefficients, knots, and additional information for interpolation/fitting. On output the following values will be set:
|
| [out] | ier | Flag of status at output |
Full example in Submodule interpolate
| real(dp) function, dimension(:), allocatable, public splroot | ( | type(univspline), intent(in) | tck | ) |
splroot Computes the roots of a cubic B-spline.
| [in] | tck | UnivSpline object with knots and coefficients of spline |