fitpack
Modern Fortran library for curve and surface fitting with splines
Loading...
Searching...
No Matches
fitpack_convex_curves::fitpack_convex_curve Interface Reference

Cubic spline fitter with pointwise convexity/concavity constraints. More...

Inheritance diagram for fitpack_convex_curves::fitpack_convex_curve:
Collaboration diagram for fitpack_convex_curves::fitpack_convex_curve:

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_sizemaxtr = 100
 Tree storage estimate for QP solver.
 
integer(fp_sizemaxbin = 10
 Max number of zero-curvature knots.
 
- Public Attributes inherited from fitpack_curves::fitpack_curve
integer(fp_sizem = 0
 The data points.
 
real(fp_real), dimension(:), allocatable x
 
real(fp_real), dimension(:), allocatable y
 
integer(fp_sizeorder = 3
 Spline degree.
 
real(fp_realxleft
 Interval boundaries.
 
real(fp_realxright
 
real(fp_real), dimension(:), allocatable sp
 
real(fp_real), dimension(:), allocatable w
 
integer(fp_sizenest = 0
 
real(fp_real), dimension(:,:), allocatable wrk_fou
 
integer(fp_flagbc = OUTSIDE_NEAREST_BND
 
integer(fp_sizeknots = 0
 
real(fp_real), dimension(:), allocatable t
 
- Public Attributes inherited from fitpack_fitters::fitpack_fitter
integer(fp_flagiopt = IOPT_NEW_SMOOTHING
 Fitting state flag.
 
real(fp_realsmoothing = 1000.0_FP_REAL
 Smoothing parameter.
 
real(fp_realfp = zero
 Weighted sum of squared residuals.
 
real(fp_real), dimension(:), allocatable c
 B-spline coefficients.
 
integer(fp_sizelwrk = 0
 Real workspace and its size.
 
real(fp_real), dimension(:), allocatable wrk
 
integer(fp_sizeliwrk = 0
 Integer workspace and its size.
 
integer(fp_size), dimension(:), allocatable iwrk
 

Detailed Description

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.

See also
Dierckx, Ch. 8, §8.3–8.4 (pp. 173–196)

Member Function/Subroutine Documentation

◆ comm_expand()

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.

Here is the call graph for this function:

◆ comm_pack()

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.

◆ comm_size()

procedure fitpack_convex_curves::fitpack_convex_curve::comm_size ( class(fitpack_convex_curve), intent(in) this)

Parallel communication interface.

◆ convex_new_from_points()

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.

Parameters
[in]xIndependent variable values.
[in]yDependent variable values, same size as x.
[in]vConvexity constraints: 1=concave, -1=convex, 0=unconstrained.
[in]wOptional weights (positive), same size as x.
[in]smoothingOptional smoothing factor.
[out]ierrOptional error flag.
Returns
Fitted convex curve object.
See also
concon
Here is the call graph for this function:

◆ destroy()

procedure fitpack_convex_curves::fitpack_convex_curve::destroy ( class(fitpack_convex_curve), intent(inout) this)

Clean memory.

◆ fit()

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.

Parameters
[in,out]thisThe convex curve object.
[in]smoothingOptional smoothing factor.
[in]orderIgnored (always cubic).
[in]keep_knotsIf .true., continue from current knot set.
Returns
Error flag.
See also
concon

◆ least_squares()

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.

Parameters
[in,out]thisThe convex curve object.
[in]smoothingOptional smoothing for initial knot placement (if reset_knots).
[in]reset_knotsIf .true., recompute knots via concon first.
Returns
Error flag.
See also
cocosp

◆ new_points()

procedure fitpack_convex_curves::fitpack_convex_curve::new_points ( class(fitpack_convex_curve), 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), optional w )

Set new points.

Parameters
[in,out]thisThe convex curve object (destroyed and reinitialized).
[in]xIndependent variable values.
[in]yDependent variable values, same size as x.
[in]wOptional positive weights, same size as x.
See also
concon, cocosp

◆ set_convexity()

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.

Parameters
[in,out]thisThe convex curve object.
[in]vConstraint values: 1=concave, -1=convex, 0=unconstrained. Must have size m.
Returns
Error flag (FITPACK_INPUT_ERROR if size mismatch).

Member Data Documentation

◆ bind

logical(fp_bool), dimension(:), allocatable fitpack_convex_curves::fitpack_convex_curve::bind

Active constraint flags at knots.

◆ maxbin

integer(fp_size) fitpack_convex_curves::fitpack_convex_curve::maxbin = 10

Max number of zero-curvature knots.

◆ maxtr

integer(fp_size) fitpack_convex_curves::fitpack_convex_curve::maxtr = 100

Tree storage estimate for QP solver.

◆ sx

real(fp_real), dimension(:), allocatable fitpack_convex_curves::fitpack_convex_curve::sx

Spline values at data points after fit.

◆ v

real(fp_real), dimension(:), allocatable fitpack_convex_curves::fitpack_convex_curve::v

Convexity constraints at data points: 1=concave, -1=convex, 0=unconstrained.


The documentation for this interface was generated from the following file: