fitpack
Modern Fortran library for curve and surface fitting with splines
Loading...
Searching...
No Matches
fitpack_gridded_splines::fitpack_gridded_spline Type Reference

Tensor-product gridded smoothing-spline fitter for any domain dimension. More...

Inheritance diagram for fitpack_gridded_splines::fitpack_gridded_spline:
Collaboration diagram for fitpack_gridded_splines::fitpack_gridded_spline:

Public Member Functions

procedure destroy (this)
 Release all allocated storage and reset the fit state.
 
procedure new_points (this, xg, z, m, row_major, order)
 Load new gridded data. z is assumed-rank: a rank-d array (2 <= d <= MAX_IDIM) whose shape gives the per-axis point counts, or a flat rank-1 array with explicit m.
 
procedure new_fit (this, xg, z, m, row_major, order, smoothing)
 Load new gridded data and perform a fit in one call.
 
procedure fit (this, smoothing, order)
 Fit a smoothing spline with automatic knot placement (delegates to regrid).
 
procedure least_squares (this, smoothing, reset_knots)
 Least-squares fit on the current knots (optionally recomputing them first).
 
procedure interpolate (this)
 Interpolating fit (s = 0).
 
procedure eval_ongrid (this, xg, m, ierr)
 Evaluate the fitted spline on a rectangular grid (delegates to ndspev).
 
generic eval (this, x, ierr)
 Evaluate at scattered points x(i,d) (ndspeu). For gridded output use eval_ongrid.
 
generic eval (this, xp, ierr)
 Evaluate the fitted spline at scattered points (delegates to ndspeu).
 
procedure dfdx_ongrid (this, xg, m, nu, ierr)
 Partial derivatives of order nu(:) on a rectangular grid (parder)
 
generic dfdx (this, x, nu, ierr)
 Partial derivatives of order nu(:) at scattered points (pardeu)
 
generic dfdx (this, xp, nu, ierr)
 Evaluate partial derivatives of order nu(:) at scattered points (delegates to pardeu).
 
procedure integral (this, lower, upper)
 Integral over a box [lower(d),upper(d)] (dblint)
 
procedure cross_section (this, ax, u, ierr)
 Cross-section: fix one axis to obtain a (dims-1)-D spline (profil)
 
procedure derivative_spline (this, nu, ierr)
 Partial-derivative spline: reduced degrees, trimmed knots (pardtc)
 
procedure comm_size (this)
 Parallel communication.
 
procedure comm_pack (this, buffer)
 Pack the fitter into a communication buffer.
 
procedure comm_expand (this, buffer)
 Expand the fitter from a communication buffer.
 
- 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(fp_dimdims = 0
 Domain (tensor) dimension, 1 <= dims <= MAX_IDIM. Metadata below is active over 1:dims.
 
integer(fp_size), dimension(max_idimorder = 3
 Per-axis spline degree.
 
integer(fp_size), dimension(max_idimm = 0
 Per-axis point counts, estimated/actual knot counts.
 
integer(fp_size), dimension(max_idimnest = 0
 
integer(fp_size), dimension(max_idimknots = 0
 
real(fp_real), dimension(max_idimleft = zero
 Per-axis domain boundaries.
 
real(fp_real), dimension(max_idimright = zero
 
real(fp_real), dimension(:,:), allocatable t
 Bulk arrays (only these are allocatable). t(:,d)=knots on axis d; xg(:,d)=grid coords on axis d; z(:)=flat function values (row-major, axis 1 slowest). c/wrk/iwrk/fp are inherited.
 
real(fp_real), dimension(:,:), allocatable xg
 
real(fp_real), dimension(:), allocatable z
 
- 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
 

Private Member Functions

procedure, private grid_eval_one (this, x, ierr)
 Evaluate at scattered points x(i,d) (ndspeu). For gridded output use eval_ongrid.
 
procedure, private grid_eval_many (this, xp, ierr)
 Evaluate the fitted spline at scattered points (delegates to ndspeu).
 
procedure, private grid_derivatives_one (this, x, nu, ierr)
 Partial derivatives of order nu(:) at scattered points (pardeu)
 
procedure, private grid_derivatives_many (this, xp, nu, ierr)
 Evaluate partial derivatives of order nu(:) at scattered points (delegates to pardeu).
 

Detailed Description

Tensor-product gridded smoothing-spline fitter for any domain dimension.

Member Function/Subroutine Documentation

◆ comm_expand()

procedure fitpack_gridded_splines::fitpack_gridded_spline::comm_expand ( class(fitpack_gridded_spline), intent(inout) this,
real(fp_comm), dimension(:), intent(in) buffer )

Expand the fitter from a communication buffer.

◆ comm_pack()

procedure fitpack_gridded_splines::fitpack_gridded_spline::comm_pack ( class(fitpack_gridded_spline), intent(in) this,
real(fp_comm), dimension(:), intent(out) buffer )

Pack the fitter into a communication buffer.

◆ comm_size()

procedure fitpack_gridded_splines::fitpack_gridded_spline::comm_size ( class(fitpack_gridded_spline), intent(in) this)

Parallel communication.

◆ cross_section()

procedure fitpack_gridded_splines::fitpack_gridded_spline::cross_section ( class(fitpack_gridded_spline), intent(in) this,
integer(fp_dim), intent(in) ax,
real(fp_real), intent(in) u,
integer(fp_flag), intent(out), optional ierr )

Cross-section: fix one axis to obtain a (dims-1)-D spline (profil)

The result is a fully-formed, evaluable fitpack_gridded_spline over the surviving axes (in their original relative order). Like the 2-D cross_section it carries only the spline (knots/degrees/ coefficients/bounds), not a data grid, so it is eval-only.

Parameters
[in]axAxis to fix, 1 <= ax <= dims (requires dims >= 2).
[in]uValue at which axis ax is fixed.
[out]ierrOptional error flag.

◆ derivative_spline()

procedure fitpack_gridded_splines::fitpack_gridded_spline::derivative_spline ( class(fitpack_gridded_spline), intent(in) this,
integer(fp_size), dimension(:), intent(in) nu,
integer(fp_flag), intent(out), optional ierr )

Partial-derivative spline: reduced degrees, trimmed knots (pardtc)

◆ destroy()

procedure fitpack_gridded_splines::fitpack_gridded_spline::destroy ( class(fitpack_gridded_spline), intent(inout) this)

Release all allocated storage and reset the fit state.

◆ dfdx() [1/2]

generic fitpack_gridded_splines::fitpack_gridded_spline::dfdx ( class(fitpack_gridded_spline), intent(inout) this,
real(fp_real), dimension(:), intent(in) x,
integer(fp_size), dimension(:), intent(in) nu,
integer(fp_flag), intent(out), optional ierr )

Partial derivatives of order nu(:) at scattered points (pardeu)

Here is the call graph for this function:

◆ dfdx() [2/2]

generic fitpack_gridded_splines::fitpack_gridded_spline::dfdx ( class(fitpack_gridded_spline), intent(inout) this,
real(fp_real), dimension(:,:), intent(in), contiguous xp,
integer(fp_size), dimension(:), intent(in) nu,
integer(fp_flag), intent(out), optional ierr )

Evaluate partial derivatives of order nu(:) at scattered points (delegates to pardeu).

Parameters
[in]xpPoint coordinates, xp(d,i) = axis-d coordinate of point i (shape (dims,m), point i = contiguous column xp(:,i)).

◆ dfdx_ongrid()

procedure fitpack_gridded_splines::fitpack_gridded_spline::dfdx_ongrid ( class(fitpack_gridded_spline), intent(inout) this,
real(fp_real), dimension(:,:), intent(in) xg,
integer(fp_size), dimension(:), intent(in) m,
integer(fp_size), dimension(:), intent(in) nu,
integer(fp_flag), intent(out), optional ierr )

Partial derivatives of order nu(:) on a rectangular grid (parder)

Parameters
[in]xgPer-axis evaluation grids, xg(1:m(d),d) strictly increasing.
[in]mPer-axis grid sizes.
[in]nuPer-axis derivative orders, 0 <= nu(d) < order(d).
[out]ierrOptional error flag.
Returns
f Flat row-major derivative values, length product(m).

◆ eval() [1/2]

generic fitpack_gridded_splines::fitpack_gridded_spline::eval ( class(fitpack_gridded_spline), intent(in) this,
real(fp_real), dimension(:), intent(in) x,
integer(fp_flag), intent(out), optional ierr )

Evaluate at scattered points x(i,d) (ndspeu). For gridded output use eval_ongrid.

Here is the call graph for this function:

◆ eval() [2/2]

generic fitpack_gridded_splines::fitpack_gridded_spline::eval ( class(fitpack_gridded_spline), intent(in) this,
real(fp_real), dimension(:,:), intent(in), contiguous xp,
integer(fp_flag), intent(out), optional ierr )

Evaluate the fitted spline at scattered points (delegates to ndspeu).

Parameters
[in]xpPoint coordinates, xp(d,i) = axis-d coordinate of point i (shape (dims,m), point i = contiguous column xp(:,i); matches curev/parcur layout).
[out]ierrOptional error flag.
Returns
f Spline values at the m points.

◆ eval_ongrid()

procedure fitpack_gridded_splines::fitpack_gridded_spline::eval_ongrid ( class(fitpack_gridded_spline), intent(inout) this,
real(fp_real), dimension(:,:), intent(in) xg,
integer(fp_size), dimension(:), intent(in) m,
integer(fp_flag), intent(out), optional ierr )

Evaluate the fitted spline on a rectangular grid (delegates to ndspev).

Parameters
[in]xgEvaluation coordinates, xg(1:m(d),d) strictly increasing on axis d.
[in]mPer-axis evaluation-grid sizes.
[out]ierrOptional error flag.
Returns
zeval Flat, row-major (axis 1 slowest) evaluated values, length product(m).

◆ fit()

procedure fitpack_gridded_splines::fitpack_gridded_spline::fit ( class(fitpack_gridded_spline), intent(inout) this,
real(fp_real), intent(in), optional smoothing,
integer(fp_size), intent(in), optional order )

Fit a smoothing spline with automatic knot placement (delegates to regrid).

◆ grid_derivatives_many()

procedure, private fitpack_gridded_splines::fitpack_gridded_spline::grid_derivatives_many ( class(fitpack_gridded_spline), intent(inout) this,
real(fp_real), dimension(:,:), intent(in), contiguous xp,
integer(fp_size), dimension(:), intent(in) nu,
integer(fp_flag), intent(out), optional ierr )
private

Evaluate partial derivatives of order nu(:) at scattered points (delegates to pardeu).

Parameters
[in]xpPoint coordinates, xp(d,i) = axis-d coordinate of point i (shape (dims,m), point i = contiguous column xp(:,i)).

◆ grid_derivatives_one()

procedure, private fitpack_gridded_splines::fitpack_gridded_spline::grid_derivatives_one ( class(fitpack_gridded_spline), intent(inout) this,
real(fp_real), dimension(:), intent(in) x,
integer(fp_size), dimension(:), intent(in) nu,
integer(fp_flag), intent(out), optional ierr )
private

Partial derivatives of order nu(:) at scattered points (pardeu)

◆ grid_eval_many()

procedure, private fitpack_gridded_splines::fitpack_gridded_spline::grid_eval_many ( class(fitpack_gridded_spline), intent(in) this,
real(fp_real), dimension(:,:), intent(in), contiguous xp,
integer(fp_flag), intent(out), optional ierr )
private

Evaluate the fitted spline at scattered points (delegates to ndspeu).

Parameters
[in]xpPoint coordinates, xp(d,i) = axis-d coordinate of point i (shape (dims,m), point i = contiguous column xp(:,i); matches curev/parcur layout).
[out]ierrOptional error flag.
Returns
f Spline values at the m points.

◆ grid_eval_one()

procedure, private fitpack_gridded_splines::fitpack_gridded_spline::grid_eval_one ( class(fitpack_gridded_spline), intent(in) this,
real(fp_real), dimension(:), intent(in) x,
integer(fp_flag), intent(out), optional ierr )
private

Evaluate at scattered points x(i,d) (ndspeu). For gridded output use eval_ongrid.

◆ integral()

procedure fitpack_gridded_splines::fitpack_gridded_spline::integral ( class(fitpack_gridded_spline), intent(in) this,
real(fp_real), dimension(:), intent(in) lower,
real(fp_real), dimension(:), intent(in) upper )

Integral over a box [lower(d),upper(d)] (dblint)

◆ interpolate()

procedure fitpack_gridded_splines::fitpack_gridded_spline::interpolate ( class(fitpack_gridded_spline), intent(inout) this)

Interpolating fit (s = 0).

◆ least_squares()

procedure fitpack_gridded_splines::fitpack_gridded_spline::least_squares ( class(fitpack_gridded_spline), intent(inout) this,
real(fp_real), intent(in), optional smoothing,
logical, intent(in), optional reset_knots )

Least-squares fit on the current knots (optionally recomputing them first).

◆ new_fit()

procedure fitpack_gridded_splines::fitpack_gridded_spline::new_fit ( class(fitpack_gridded_spline), intent(inout) this,
real(fp_real), dimension(:,:), intent(in) xg,
real(fp_real), dimension(..), intent(in) z,
integer(fp_size), dimension(:), intent(in), optional m,
logical(fp_bool), intent(in), optional row_major,
integer(fp_size), intent(in), optional order,
real(fp_real), intent(in), optional smoothing )

Load new gridded data and perform a fit in one call.

◆ new_points()

procedure fitpack_gridded_splines::fitpack_gridded_spline::new_points ( class(fitpack_gridded_spline), intent(inout) this,
real(fp_real), dimension(:,:), intent(in) xg,
real(fp_real), dimension(..), intent(in) z,
integer(fp_size), dimension(:), intent(in), optional m,
logical(fp_bool), intent(in), optional row_major,
integer(fp_size), intent(in), optional order )

Load new gridded data. z is assumed-rank: a rank-d array (2 <= d <= MAX_IDIM) whose shape gives the per-axis point counts, or a flat rank-1 array with explicit m.

Parameters
[in]xgGrid coordinates, xg(1:m(d),d) strictly increasing on axis d.
[in]zFunction values (see the module header for the layout conventions).
[in]mPer-axis point counts; REQUIRED when z is rank-1, ignored otherwise.
[in]row_majorLayout of a rank-d z (default .true.); see the module header.
[in]orderOptional per-axis spline degree (scalar, applied to all axes).

Member Data Documentation

◆ dims

integer(fp_dim) fitpack_gridded_splines::fitpack_gridded_spline::dims = 0

Domain (tensor) dimension, 1 <= dims <= MAX_IDIM. Metadata below is active over 1:dims.

◆ knots

integer(fp_size), dimension(max_idim) fitpack_gridded_splines::fitpack_gridded_spline::knots = 0

◆ left

real(fp_real), dimension(max_idim) fitpack_gridded_splines::fitpack_gridded_spline::left = zero

Per-axis domain boundaries.

◆ m

integer(fp_size), dimension(max_idim) fitpack_gridded_splines::fitpack_gridded_spline::m = 0

Per-axis point counts, estimated/actual knot counts.

◆ nest

integer(fp_size), dimension(max_idim) fitpack_gridded_splines::fitpack_gridded_spline::nest = 0

◆ order

integer(fp_size), dimension(max_idim) fitpack_gridded_splines::fitpack_gridded_spline::order = 3

Per-axis spline degree.

◆ right

real(fp_real), dimension(max_idim) fitpack_gridded_splines::fitpack_gridded_spline::right = zero

◆ t

real(fp_real), dimension(:,:), allocatable fitpack_gridded_splines::fitpack_gridded_spline::t

Bulk arrays (only these are allocatable). t(:,d)=knots on axis d; xg(:,d)=grid coords on axis d; z(:)=flat function values (row-major, axis 1 slowest). c/wrk/iwrk/fp are inherited.

◆ xg

real(fp_real), dimension(:,:), allocatable fitpack_gridded_splines::fitpack_gridded_spline::xg

◆ z

real(fp_real), dimension(:), allocatable fitpack_gridded_splines::fitpack_gridded_spline::z

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