|
fitpack
Modern Fortran library for curve and surface fitting with splines
|
Cubic spline fitter with pointwise convexity/concavity constraints. More...


Public Member Functions | |
| procedure | destroy (this) |
| Clean memory. | |
| procedure | new_points (this, x, y, w) |
| Set new points. | |
| procedure | fit (this, smoothing, order, keep_knots) |
| Generate/update fitting curve with automatic knots (concon) | |
| procedure | least_squares (this, smoothing, reset_knots) |
| Least-squares fit with given knots (cocosp) | |
| procedure | set_convexity (this, v) |
| Set convexity constraint values. | |
| procedure | comm_size (this) |
| Parallel communication interface. | |
| procedure | comm_pack (this, buffer) |
| Pack convex curve data into a communication buffer. | |
| procedure | comm_expand (this, buffer) |
| Expand convex curve data from a communication buffer. | |
| type(fitpack_convex_curve) function | convex_new_from_points (x, y, v, w, smoothing, ierr) |
| Construct a convex curve from data points with convexity constraints and fit it. | |
Public Member Functions inherited from fitpack_curves::fitpack_curve | |
| procedure | destroy (this) |
| Clean memory. | |
| procedure | new_points (this, x, y, w) |
| Set new points. | |
| procedure | new_fit (this, x, y, w, smoothing, order) |
| Generate new fit. | |
| procedure | fit (this, smoothing, order, keep_knots) |
| Generate/update fitting curve, with optional smoothing. | |
| procedure | interpolate (this, order, reset_knots) |
| Fit an interpolating spline ( \( s = 0 \)) through the data points. | |
| procedure | least_squares (this, smoothing, reset_knots) |
| Fit a least-squares spline with fixed knots. | |
| generic | eval (this, x, ierr) |
| Evaluate curve at given coordinates. | |
| generic | eval (this, x) |
| Evaluate the spline at a single point (pure, returns NaN on error). | |
| generic | eval (this, x, ierr) |
| Evaluate the spline at multiple points (with error flag). | |
| generic | eval (this, x) |
| Evaluate the spline at multiple points (pure, returns NaN on error). | |
| procedure | integral (this, from, to) |
| Integrate. | |
| procedure | fourier_coefficients (this, alpha, a, b, ierr) |
| Fourier coefficients. | |
| procedure | zeros (this, ierr) |
| Find the zeros of a spline s(x), only if it is cubic. | |
| generic | dfdx (this, x, order, ierr) |
| Evaluate derivative at given coordinates. | |
| generic | dfdx (this, x, order, ierr) |
| Evaluate the k-th derivative at multiple points (with error flag). | |
| generic | dfdx_all (this, x, ierr) |
| Evaluate all derivatives \( s^{(j)}(x) \) for \( j = 0, \ldots, k \) (with error flag). | |
| generic | dfdx_all (this, x) |
| Evaluate all derivatives \( s^{(j)}(x) \) for \( j = 0, \ldots, k \) (pure, NaN on error). | |
| generic | insert_knot (this, x, ierr) |
| Insert knot(s) into the spline representation. | |
| generic | insert_knot (this, x, ierr) |
| Insert multiple knots into the B-spline representation. | |
| procedure | comm_size (this) |
| Parallel communication interface (size/pack/expand) | |
| procedure | comm_pack (this, buffer) |
| Pack curve data into a communication buffer for parallel transfer. | |
| procedure | comm_expand (this, buffer) |
| Expand curve data from a communication buffer. | |
| type(fitpack_curve) function | new_from_points (x, y, w, ierr) |
| Construct a fitpack_curve from 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 | |
| real(fp_real), dimension(:), allocatable | v |
| Convexity constraints at data points: 1=concave, -1=convex, 0=unconstrained. | |
| real(fp_real), dimension(:), allocatable | sx |
| Spline values at data points after fit. | |
| logical(fp_bool), dimension(:), allocatable | bind |
| Active constraint flags at knots. | |
| integer(fp_size) | maxtr = 100 |
| Tree storage estimate for QP solver. | |
| integer(fp_size) | maxbin = 10 |
| Max number of zero-curvature knots. | |
Public Attributes inherited from fitpack_curves::fitpack_curve | |
| integer(fp_size) | m = 0 |
| The data points. | |
| real(fp_real), dimension(:), allocatable | x |
| real(fp_real), dimension(:), allocatable | y |
| integer(fp_size) | order = 3 |
| Spline degree. | |
| real(fp_real) | xleft |
| Interval boundaries. | |
| real(fp_real) | xright |
| real(fp_real), dimension(:), allocatable | sp |
| real(fp_real), dimension(:), allocatable | w |
| integer(fp_size) | nest = 0 |
| real(fp_real), dimension(:,:), allocatable | wrk_fou |
| integer(fp_flag) | bc = OUTSIDE_NEAREST_BND |
| integer(fp_size) | 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 |
Cubic spline fitter with pointwise convexity/concavity constraints.
Extends fitpack_curve with per-data-point convexity flags: each point can be constrained to lie on a locally concave ( \( v_i = 1 \)), convex ( \( v_i = -1 \)), or unconstrained ( \( v_i = 0 \)) portion of the spline. The fitting routines solve a constrained quadratic programming problem to determine knot positions and coefficients that satisfy these shape constraints while minimizing the smoothing functional.
| procedure fitpack_convex_curves::fitpack_convex_curve::comm_expand | ( | class(fitpack_convex_curve), intent(inout) | this, |
| real(fp_comm), dimension(:), intent(in) | buffer ) |
Expand convex curve data from a communication buffer.

| procedure fitpack_convex_curves::fitpack_convex_curve::comm_pack | ( | class(fitpack_convex_curve), intent(in) | this, |
| real(fp_comm), dimension(:), intent(out) | buffer ) |
Pack convex curve data into a communication buffer.
| procedure fitpack_convex_curves::fitpack_convex_curve::comm_size | ( | class(fitpack_convex_curve), intent(in) | this | ) |
Parallel communication interface.
| type(fitpack_convex_curve) function fitpack_convex_curves::fitpack_convex_curve::convex_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) | v, | ||
| real(fp_real), dimension(size(x)), intent(in), optional | w, | ||
| real(fp_real), intent(in), optional | smoothing, | ||
| integer(fp_flag), intent(out), optional | ierr ) |
Construct a convex curve from data points with convexity constraints and fit it.
| [in] | x | Independent variable values. |
| [in] | y | Dependent variable values, same size as x. |
| [in] | v | Convexity constraints: 1=concave, -1=convex, 0=unconstrained. |
| [in] | w | Optional weights (positive), same size as x. |
| [in] | smoothing | Optional smoothing factor. |
| [out] | ierr | Optional error flag. |

| procedure fitpack_convex_curves::fitpack_convex_curve::destroy | ( | class(fitpack_convex_curve), intent(inout) | this | ) |
Clean memory.
| procedure fitpack_convex_curves::fitpack_convex_curve::fit | ( | class(fitpack_convex_curve), intent(inout) | this, |
| real(fp_real), intent(in), optional | smoothing, | ||
| integer(fp_size), intent(in), optional | order, | ||
| logical, intent(in), optional | keep_knots ) |
Generate/update fitting curve with automatic knots (concon)
Uses the concon core routine which solves a constrained quadratic programming problem to place knots while respecting local convexity/concavity constraints.
| [in,out] | this | The convex curve object. |
| [in] | smoothing | Optional smoothing factor. |
| [in] | order | Ignored (always cubic). |
| [in] | keep_knots | If .true., continue from current knot set. |
| procedure fitpack_convex_curves::fitpack_convex_curve::least_squares | ( | class(fitpack_convex_curve), intent(inout) | this, |
| real(fp_real), intent(in), optional | smoothing, | ||
| logical, intent(in), optional | reset_knots ) |
Least-squares fit with given knots (cocosp)
Uses the cocosp core routine. Constraint values at interior knots are derived from the nearest data-point convexity flags.
| [in,out] | this | The convex curve object. |
| [in] | smoothing | Optional smoothing for initial knot placement (if reset_knots). |
| [in] | reset_knots | If .true., recompute knots via concon first. |
| procedure fitpack_convex_curves::fitpack_convex_curve::set_convexity | ( | class(fitpack_convex_curve), intent(inout) | this, |
| real(fp_real), dimension(:), intent(in) | v ) |
Set convexity constraint values.
| [in,out] | this | The convex curve object. |
| [in] | v | Constraint values: 1=concave, -1=convex, 0=unconstrained. Must have size m. |
| logical(fp_bool), dimension(:), allocatable fitpack_convex_curves::fitpack_convex_curve::bind |
Active constraint flags at knots.
| integer(fp_size) fitpack_convex_curves::fitpack_convex_curve::maxbin = 10 |
Max number of zero-curvature knots.
| integer(fp_size) fitpack_convex_curves::fitpack_convex_curve::maxtr = 100 |
Tree storage estimate for QP solver.
| real(fp_real), dimension(:), allocatable fitpack_convex_curves::fitpack_convex_curve::sx |
Spline values at data points after fit.
| real(fp_real), dimension(:), allocatable fitpack_convex_curves::fitpack_convex_curve::v |
Convexity constraints at data points: 1=concave, -1=convex, 0=unconstrained.