|
fitpack
Modern Fortran library for curve and surface fitting with splines
|
Bivariate surface fitter \( z = s(x, y) \) for scattered data. More...


Public Member Functions | |
| procedure | destroy (this) |
| Clean memory. | |
| procedure | new_points (this, x, y, z, w) |
| Set new points. | |
| procedure | new_fit (this, x, y, z, w, smoothing, order) |
| Generate new fit. | |
| procedure | fit (this, smoothing, order, keep_knots) |
| Generate/update fitting curve, with optional smoothing. | |
| procedure | interpolate (this, reset_knots) |
| Fit an interpolating surface ( \( s = 0 \)) through the data points. | |
| procedure | least_squares (this, smoothing, reset_knots) |
| Fit a least-squares surface with fixed knots. | |
| generic | eval (this, x, y, ierr) |
| Evaluate surface at given coordinates. | |
| generic | eval (this, x, y, ierr) |
| Evaluate the surface at a list of scattered \( (x_i, y_i) \) points. | |
| generic | eval_ongrid (this, x, y, ierr) |
| Evaluate surface on a grid. | |
| generic | dfdx (this, x, y, dx, dy, ierr) |
| Evaluate a partial derivative at a single \( (x, y) \) point. | |
| generic | dfdx (this, x, y, dx, dy, ierr) |
| Evaluate partial derivatives at scattered \( (x_i, y_i) \) points. | |
| generic | dfdx_ongrid (this, x, y, dx, dy, ierr) |
| Evaluate derivatives at given coordinates. | |
| procedure | integral (this, lower, upper) |
| Double integration over a rectangular domain. | |
| procedure | cross_section (this, u, along_y, ierr) |
| Extract a 1D cross-section curve from the surface. | |
| procedure | derivative_spline (this, nux, nuy, ierr) |
| Compute the derivative spline coefficients. | |
| procedure | comm_size (this) |
| Parallel communication interface. | |
| procedure | comm_pack (this, buffer) |
| Pack surface data into a communication buffer. | |
| procedure | comm_expand (this, buffer) |
| Expand surface data from a communication buffer. | |
| type(fitpack_surface) function | surf_new_from_points (x, y, z, w, ierr) |
| Construct a surface from scattered data points and perform a default fit. | |
Public Member Functions inherited from fitpack_fitters::fitpack_fitter | |
| procedure, non_overridable | mse (this) |
| MSE accessor (shared by all types) | |
| procedure, non_overridable | core_comm_size (this) |
| Base field helpers for comm (non-overridable, called by subtypes) | |
| procedure, non_overridable | core_comm_pack (this, buffer) |
| Pack base fields into communication buffer. | |
| procedure, non_overridable | core_comm_expand (this, buffer) |
| Expand base fields from communication buffer. | |
| procedure, non_overridable | destroy_base (this) |
| Base field reset (called by subtype destroy methods) | |
| procedure(comm_size_if), deferred | comm_size (this) |
| Deferred communication interface. | |
| procedure(comm_pack_if), deferred | comm_pack (this, buffer) |
| procedure(comm_expand_if), deferred | comm_expand (this, buffer) |
Public Attributes | |
| integer | m = 0 |
| The input data points. | |
| real(fp_real), dimension(:), allocatable | x |
| real(fp_real), dimension(:), allocatable | y |
| real(fp_real), dimension(:), allocatable | z |
| integer, dimension(2) | order = 3 |
| Spline degree. | |
| real(fp_real), dimension(2) | left |
| Interval boundaries. | |
| real(fp_real), dimension(2) | right |
| real(fp_real), dimension(:), allocatable | w |
| integer, dimension(2) | nest = 0 |
| integer | nmax = 0 |
| integer | lwrk2 = 0 |
| real(fp_real), dimension(:), allocatable | wrk2 |
| integer | bc = OUTSIDE_NEAREST_BND |
| integer, dimension(2) | knots = 0 |
| real(fp_real), dimension(:,:), allocatable | t |
Public Attributes inherited from fitpack_fitters::fitpack_fitter | |
| integer(fp_flag) | iopt = IOPT_NEW_SMOOTHING |
| Fitting state flag. | |
| real(fp_real) | smoothing = 1000.0_FP_REAL |
| Smoothing parameter. | |
| real(fp_real) | fp = zero |
| Weighted sum of squared residuals. | |
| real(fp_real), dimension(:), allocatable | c |
| B-spline coefficients. | |
| integer(fp_size) | lwrk = 0 |
| Real workspace and its size. | |
| real(fp_real), dimension(:), allocatable | wrk |
| integer(fp_size) | liwrk = 0 |
| Integer workspace and its size. | |
| integer(fp_size), dimension(:), allocatable | iwrk |
Private Member Functions | |
| procedure, private | surface_eval_one (this, x, y, ierr) |
| Evaluate surface at given coordinates. | |
| procedure, private | surface_eval_many (this, x, y, ierr) |
| Evaluate the surface at a list of scattered \( (x_i, y_i) \) points. | |
| procedure, private | surface_eval_gridded (this, x, y, ierr) |
| Evaluate surface on a grid. | |
| procedure, private | surface_derivatives_gridded (this, x, y, dx, dy, ierr) |
| Evaluate derivatives at given coordinates. | |
| procedure, private | surface_derivatives_many (this, x, y, dx, dy, ierr) |
| Evaluate partial derivatives at scattered \( (x_i, y_i) \) points. | |
| procedure, private | surface_derivatives_one (this, x, y, dx, dy, ierr) |
| Evaluate a partial derivative at a single \( (x, y) \) point. | |
Bivariate surface fitter \( z = s(x, y) \) for scattered data.
Stores the input data points \( (x_i, y_i, z_i) \), optional weights \( w_i \), the fitted tensor-product B-spline representation (knots and coefficients), and the fitting state. The smoothing parameter \( s \) controls the trade-off between closeness of fit and smoothness.
| procedure fitpack_surfaces::fitpack_surface::comm_expand | ( | class(fitpack_surface), intent(inout) | this, |
| real(fp_comm), dimension(:), intent(in) | buffer ) |
Expand surface data from a communication buffer.

| procedure fitpack_surfaces::fitpack_surface::comm_pack | ( | class(fitpack_surface), intent(in) | this, |
| real(fp_comm), dimension(:), intent(out) | buffer ) |
Pack surface data into a communication buffer.
| procedure fitpack_surfaces::fitpack_surface::comm_size | ( | class(fitpack_surface), intent(in) | this | ) |
Parallel communication interface.
| procedure fitpack_surfaces::fitpack_surface::cross_section | ( | class(fitpack_surface), intent(in) | this, |
| real(fp_real), intent(in) | u, | ||
| logical, intent(in) | along_y, | ||
| integer(fp_flag), intent(out), optional | ierr ) |
Extract a 1D cross-section curve from the surface.
If along_y=.true., returns \( f(y) = s(u, y) \); otherwise \( g(x) = s(x, u) \). The result is a fitpack_curve with the appropriate knots and coefficients.
| procedure fitpack_surfaces::fitpack_surface::derivative_spline | ( | class(fitpack_surface), intent(in) | this, |
| integer(fp_size), intent(in) | nux, | ||
| integer(fp_size), intent(in) | nuy, | ||
| integer(fp_flag), intent(out), optional | ierr ) |
Compute the derivative spline coefficients.
Returns a new surface representing \( \partial^{n_x+n_y} s / \partial x^{n_x} \partial y^{n_y} \), with reduced degrees \( (k_x - n_x, k_y - n_y) \) and trimmed knots.
| procedure fitpack_surfaces::fitpack_surface::destroy | ( | class(fitpack_surface), intent(inout) | this | ) |
Clean memory.
| generic fitpack_surfaces::fitpack_surface::dfdx | ( | class(fitpack_surface), intent(inout) | this, |
| real(fp_real), intent(in) | x, | ||
| real(fp_real), intent(in) | y, | ||
| integer(fp_size), intent(in) | dx, | ||
| integer(fp_size), intent(in) | dy, | ||
| integer(fp_flag), intent(out), optional | ierr ) |
Evaluate a partial derivative at a single \( (x, y) \) point.

| generic fitpack_surfaces::fitpack_surface::dfdx | ( | class(fitpack_surface), intent(inout) | this, |
| real(fp_real), dimension(:), intent(in) | x, | ||
| real(fp_real), dimension(:), intent(in) | y, | ||
| integer(fp_size), intent(in) | dx, | ||
| integer(fp_size), intent(in) | dy, | ||
| integer(fp_flag), intent(out), optional | ierr ) |
Evaluate partial derivatives at scattered \( (x_i, y_i) \) points.
| generic fitpack_surfaces::fitpack_surface::dfdx_ongrid | ( | class(fitpack_surface), intent(inout) | this, |
| real(fp_real), dimension(:), intent(in) | x, | ||
| real(fp_real), dimension(:), intent(in) | y, | ||
| integer(fp_size), intent(in) | dx, | ||
| integer(fp_size), intent(in) | dy, | ||
| integer(fp_flag), intent(out), optional | ierr ) |
Evaluate derivatives at given coordinates.
Returns f(j,i) = \( \partial^{dx+dy} s / \partial x^{dx} \partial y^{dy} \) at \( (x_i, y_j) \).

| generic fitpack_surfaces::fitpack_surface::eval | ( | class(fitpack_surface), intent(inout) | this, |
| real(fp_real), intent(in) | x, | ||
| real(fp_real), intent(in) | y, | ||
| integer(fp_flag), intent(out), optional | ierr ) |
| generic fitpack_surfaces::fitpack_surface::eval | ( | class(fitpack_surface), intent(inout) | this, |
| real(fp_real), dimension(:), intent(in) | x, | ||
| real(fp_real), dimension(size(x)), intent(in) | y, | ||
| integer(fp_flag), intent(out), optional | ierr ) |
Evaluate the surface at a list of scattered \( (x_i, y_i) \) points.
| generic fitpack_surfaces::fitpack_surface::eval_ongrid | ( | class(fitpack_surface), intent(inout) | this, |
| real(fp_real), dimension(:), intent(in) | x, | ||
| real(fp_real), dimension(:), intent(in) | y, | ||
| integer(fp_flag), intent(out), optional | ierr ) |
Evaluate surface on a grid.
Returns f(j,i) = \( s(x_i, y_j) \).

| procedure fitpack_surfaces::fitpack_surface::fit | ( | class(fitpack_surface), intent(inout) | this, |
| real(fp_real), intent(in), optional | smoothing, | ||
| integer, intent(in), optional | order, | ||
| logical, intent(in), optional | keep_knots ) |
Generate/update fitting curve, with optional smoothing.
Uses the surfit core routine. The smoothing parameter controls the trade-off between closeness of fit and smoothness.
| [in,out] | this | The surface object. |
| [in] | smoothing | Optional smoothing factor. |
| [in] | order | Optional spline degree (applied to both directions). |
| [in] | keep_knots | If .true., continue from current knot set. |
| procedure fitpack_surfaces::fitpack_surface::integral | ( | class(fitpack_surface), intent(in) | this, |
| real(fp_real), dimension(2), intent(in) | lower, | ||
| real(fp_real), dimension(2), intent(in) | upper ) |
Double integration over a rectangular domain.
Computes \( \int_{x_a}^{x_b} \int_{y_a}^{y_b} s(x,y)\,dy\,dx \).
| [in] | this | The fitted surface. |
| [in] | lower | Lower bounds \( (x_a, y_a) \). |
| [in] | upper | Upper bounds \( (x_b, y_b) \). |
| procedure fitpack_surfaces::fitpack_surface::interpolate | ( | class(fitpack_surface), intent(inout) | this, |
| logical, intent(in), optional | reset_knots ) |
Fit an interpolating surface ( \( s = 0 \)) through the data points.
| procedure fitpack_surfaces::fitpack_surface::least_squares | ( | class(fitpack_surface), intent(inout) | this, |
| real(fp_real), intent(in), optional | smoothing, | ||
| logical, intent(in), optional | reset_knots ) |
Fit a least-squares surface with fixed knots.
| procedure fitpack_surfaces::fitpack_surface::new_fit | ( | class(fitpack_surface), intent(inout) | this, |
| real(fp_real), dimension(:), intent(in) | x, | ||
| real(fp_real), dimension(size(x)), intent(in) | y, | ||
| real(fp_real), dimension(size(x)), intent(in) | z, | ||
| real(fp_real), dimension(size(x)), intent(in), optional | w, | ||
| real(fp_real), intent(in), optional | smoothing, | ||
| integer, intent(in), optional | order ) |
Generate new fit.
| procedure fitpack_surfaces::fitpack_surface::new_points | ( | class(fitpack_surface), intent(inout) | this, |
| real(fp_real), dimension(:), intent(in) | x, | ||
| real(fp_real), dimension(size(x)), intent(in) | y, | ||
| real(fp_real), dimension(size(x)), intent(in) | z, | ||
| real(fp_real), dimension(size(x)), intent(in), optional | w ) |
Set new points.
| [in,out] | this | The surface object (destroyed and reinitialized). |
| [in] | x | X coordinates of scattered data points. |
| [in] | y | Y coordinates, same size as x. |
| [in] | z | Function values, same size as x. |
| [in] | w | Optional positive weights, same size as x. |
| type(fitpack_surface) function fitpack_surfaces::fitpack_surface::surf_new_from_points | ( | real(fp_real), dimension(:), intent(in) | x, |
| real(fp_real), dimension(size(x)), intent(in) | y, | ||
| real(fp_real), dimension(size(x)), intent(in) | z, | ||
| real(fp_real), dimension(size(x)), intent(in), optional | w, | ||
| integer(fp_flag), intent(out), optional | ierr ) |
Construct a surface from scattered data points and perform a default fit.
| [in] | x | X coordinates. |
| [in] | y | Y coordinates, same size as x. |
| [in] | z | Function values, same size as x. |
| [in] | w | Optional weights. |
| [out] | ierr | Optional error flag. |
|
private |
Evaluate derivatives at given coordinates.
Returns f(j,i) = \( \partial^{dx+dy} s / \partial x^{dx} \partial y^{dy} \) at \( (x_i, y_j) \).
|
private |
Evaluate partial derivatives at scattered \( (x_i, y_i) \) points.
|
private |
Evaluate a partial derivative at a single \( (x, y) \) point.
|
private |
|
private |
Evaluate the surface at a list of scattered \( (x_i, y_i) \) points.
|
private |
Evaluate surface at given coordinates.
| integer fitpack_surfaces::fitpack_surface::bc = OUTSIDE_NEAREST_BND |
| integer, dimension(2) fitpack_surfaces::fitpack_surface::knots = 0 |
| real(fp_real), dimension(2) fitpack_surfaces::fitpack_surface::left |
Interval boundaries.
| integer fitpack_surfaces::fitpack_surface::lwrk2 = 0 |
| integer fitpack_surfaces::fitpack_surface::m = 0 |
The input data points.
| integer, dimension(2) fitpack_surfaces::fitpack_surface::nest = 0 |
| integer fitpack_surfaces::fitpack_surface::nmax = 0 |
| integer, dimension(2) fitpack_surfaces::fitpack_surface::order = 3 |
Spline degree.
| real(fp_real), dimension(2) fitpack_surfaces::fitpack_surface::right |
| real(fp_real), dimension(:,:), allocatable fitpack_surfaces::fitpack_surface::t |
| real(fp_real), dimension(:), allocatable fitpack_surfaces::fitpack_surface::w |
| real(fp_real), dimension(:), allocatable fitpack_surfaces::fitpack_surface::wrk2 |
| real(fp_real), dimension(:), allocatable fitpack_surfaces::fitpack_surface::x |
| real(fp_real), dimension(:), allocatable fitpack_surfaces::fitpack_surface::y |
| real(fp_real), dimension(:), allocatable fitpack_surfaces::fitpack_surface::z |