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

OOP wrapper for constrained-convexity curve fitting. More...

Data Types

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

Functions/Subroutines

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.
 
elemental subroutine convex_destroy (this)
 Destroy the convex curve object and release all allocated memory.
 
subroutine convex_new_points (this, x, y, w)
 Load new data points and allocate workspace for convex fitting.
 
integer(fp_flag) function set_convexity (this, v)
 Set pointwise convexity constraints.
 
elemental integer(fp_flag) function remap_concon_error (ier)
 
integer(fp_flag) function convex_fit_automatic_knots (this, smoothing, order, keep_knots)
 Fit a smoothing spline with convexity constraints and automatic knot placement.
 
integer(fp_flag) function convex_fit_least_squares (this, smoothing, reset_knots)
 Fit a least-squares spline with convexity constraints on the current knots.
 
pure real(fp_real) function nearest_constraint (t_knot, x, v, m)
 
elemental integer(fp_size) function convex_comm_size (this)
 Return the communication buffer size for the convex curve.
 
pure subroutine convex_comm_pack (this, buffer)
 Pack convex curve data into a communication buffer.
 
pure subroutine convex_comm_expand (this, buffer)
 Expand convex curve data from a communication buffer.
 

Detailed Description

OOP wrapper for constrained-convexity curve fitting.

Provides fitpack_convex_curve, an extension of fitpack_curve that enforces local convexity or concavity constraints during spline fitting. Always uses cubic splines ( \( k = 3 \)). The underlying core routines are concon (automatic knot placement) and cocosp (least-squares with user-supplied knots).

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

Function/Subroutine Documentation

◆ convex_comm_expand()

pure subroutine fitpack_convex_curves::convex_comm_expand ( class(fitpack_convex_curve), intent(inout) this,
real(fp_comm), dimension(:), intent(in) buffer )
private

Expand convex curve data from a communication buffer.

◆ convex_comm_pack()

pure subroutine fitpack_convex_curves::convex_comm_pack ( class(fitpack_convex_curve), intent(in) this,
real(fp_comm), dimension(:), intent(out) buffer )
private

Pack convex curve data into a communication buffer.

◆ convex_comm_size()

elemental integer(fp_size) function fitpack_convex_curves::convex_comm_size ( class(fitpack_convex_curve), intent(in) this)
private

Return the communication buffer size for the convex curve.

Here is the call graph for this function:

◆ convex_destroy()

elemental subroutine fitpack_convex_curves::convex_destroy ( class(fitpack_convex_curve), intent(inout) this)
private

Destroy the convex curve object and release all allocated memory.

◆ convex_fit_automatic_knots()

integer(fp_flag) function fitpack_convex_curves::convex_fit_automatic_knots ( 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 )
private

Fit a smoothing spline with convexity constraints and automatic knot placement.

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
Here is the call graph for this function:

◆ convex_fit_least_squares()

integer(fp_flag) function fitpack_convex_curves::convex_fit_least_squares ( class(fitpack_convex_curve), intent(inout) this,
real(fp_real), intent(in), optional smoothing,
logical, intent(in), optional reset_knots )
private

Fit a least-squares spline with convexity constraints on the current knots.

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
Here is the call graph for this function:

◆ convex_new_from_points()

type(fitpack_convex_curve) function fitpack_convex_curves::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 )
private

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

◆ convex_new_points()

subroutine fitpack_convex_curves::convex_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 )
private

Load new data points and allocate workspace for convex fitting.

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

◆ nearest_constraint()

pure real(fp_real) function fitpack_convex_curves::nearest_constraint ( real(fp_real), intent(in) t_knot,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) v,
integer(fp_size), intent(in) m )
private

◆ remap_concon_error()

elemental integer(fp_flag) function fitpack_convex_curves::remap_concon_error ( integer(fp_flag), intent(in) ier)
private

◆ set_convexity()

integer(fp_flag) function fitpack_convex_curves::set_convexity ( class(fitpack_convex_curve), intent(inout) this,
real(fp_real), dimension(:), intent(in) v )
private

Set pointwise convexity constraints.

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).