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

Data Types

interface  fitpack_polar_boundary
 
interface  fitpack_swap
 
interface  fp_comm_expand
 Expand communication buffer into allocatable arrays. More...
 
interface  fp_comm_pack
 Pack allocatable arrays into communication buffer. More...
 
interface  fp_comm_size
 Communication size for allocatable 1D arrays. More...
 

Functions/Subroutines

subroutine, public fitpack_error_handling (ierr, ierr_out, whereat)
 Dispatch an error code: return it to caller or halt with a message.
 
pure character(len=:) function, allocatable, public fitpack_message (ierr)
 Convert an integer error flag to a human-readable message string.
 
subroutine, public get_smoothing (old_smoothing, user_smoothing, nit, smooth_now)
 Choose the smoothing parameter(s) for an iterative fit.
 
pure character(len=:) function, allocatable, public iopt_message (iopt)
 Convert an iopt computation-mode flag to a human-readable string.
 
elemental logical(fp_bool) function, public fitpack_success (ierr)
 Test whether a FITPACK error flag indicates success.
 
pure subroutine, public bispeu (tx, nx, ty, ny, c, kx, ky, x, y, z, m, wrk, lwrk, ier)
 Evaluate a bivariate spline at scattered points \( (x_i, y_i) \).
 
pure subroutine, public bispev (tx, nx, ty, ny, c, kx, ky, x, mx, y, my, z, wrk, lwrk, iwrk, kwrk, ier)
 Evaluate a bivariate spline on a rectangular grid.
 
pure subroutine, public clocur (iopt, ipar, idim, m, u, mx, x, w, k, s, nest, n, t, nc, c, fp, wrk, lwrk, iwrk, ier)
 Determine a smooth closed parametric spline curve approximation.
 
pure subroutine, public cocosp (m, x, y, w, n, t, e, maxtr, maxbin, c, sq, sx, bind, wrk, lwrk, iwrk, kwrk, ier)
 Fit a cubic spline with convexity/concavity constraints and user-specified knots.
 
pure subroutine, public concon (iopt, m, x, y, w, v, s, nest, maxtr, maxbin, n, t, c, sq, sx, bind, wrk, lwrk, iwrk, kwrk, ier)
 Fit a cubic spline with convexity/concavity constraints and automatic knot placement.
 
pure subroutine, public concur (iopt, idim, m, u, mx, x, xx, w, ib, db, nb, ie, de, ne, k, s, nest, n, t, nc, c, np, cp, fp, wrk, lwrk, iwrk, ier)
 Determine a smooth parametric spline curve with derivative constraints at endpoints.
 
pure subroutine, public cualde (idim, t, n, c, nc, k1, u, d, nd, ier)
 Evaluate all derivatives of a parametric spline curve at a single point.
 
pure subroutine, public curev (idim, t, n, c, nc, k, u, m, x, mx, ier)
 Evaluate a parametric spline curve at a set of parameter values.
 
pure subroutine, public curfit (iopt, m, x, y, w, xb, xe, k, s, nest, n, t, c, fp, wrk, lwrk, iwrk, ier)
 Determine a smooth spline approximation of degree \( k \) to a set of data points.
 
real(fp_real) function, public dblint (tx, nx, ty, ny, c, kx, ky, xb, xe, yb, ye, wrk)
 Compute the double integral of a bivariate spline over a rectangle.
 
pure real(fp_real) function, public evapol (tu, nu, tv, nv, c, rad, x, y)
 Evaluate a polar spline \( f(x,y) = s(u,v) \) at a Cartesian point.
 
pure subroutine, public fourco (t, n, c, alfa, m, ress, resc, wrk1, wrk2, ier)
 Compute Fourier coefficients of a cubic spline.
 
pure subroutine fpader (t, n, c, k1, x, l, d)
 Evaluate all derivatives of a spline at a single point.
 
pure subroutine fpadno (maxtr, up, left, right, info, count, merk, jbind, n1, ier)
 Add a branch to the constraint-set binary tree.
 
pure subroutine fpadpo (idim, t, n, c, nc, k, cp, np, cc, t1, t2)
 Add a polynomial curve to a spline curve in B-spline representation.
 
pure real(fp_real) function, dimension(n) fpback (a, z, n, k, nest)
 Solve an upper triangular banded system by back-substitution.
 
pure real(fp_real) function, dimension(n) fpbacp (a, b, z, n, k, k1, nest)
 Solve a bordered upper triangular system by back-substitution.
 
pure subroutine fpbfou (t, n, par, ress, resc)
 Compute Fourier coefficients of cubic B-splines.
 
pure subroutine fpbisp (tx, nx, ty, ny, c, kx, ky, x, mx, y, my, z, wx, wy, lx, ly)
 Evaluate a tensor product spline on a grid.
 
pure real(fp_real) function, dimension(max_order+1) fpbspl (t, n, k, x, l)
 Evaluate the non-zero B-splines at a given point.
 
pure integer(fp_size) function fp_knot_interval (t, x, l_start, l_max)
 Find knot interval index l such that t(l) <= x < t(l+1). Uses hybrid search: linear for small ranges, binary for large. This replaces the repeated pattern: do while (x >= t(l+1) .and. l /= l_max) l = l + 1 end do.
 
pure integer(fp_flag) function fpchec (x, m, t, n, k)
 Verify knot positions against data points (Schoenberg-Whitney check).
 
pure integer function fpched (x, m, t, n, k, ib, ie)
 Verify knot positions for a constrained spline (Schoenberg-Whitney check).
 
pure integer(fp_flag) function fpchep (x, m, t, n, k)
 Verify knot positions for a periodic spline (Schoenberg-Whitney check).
 
pure subroutine fpclos (iopt, idim, m, u, mx, x, w, k, s, nest, tol, maxit, k1, k2, n, t, nc, c, fp, fpint, z, a1, a2, b, g1, g2, q, nrdata, ier)
 Core algorithm for closed (periodic) parametric curve fitting.
 
pure subroutine fpclos_reset_interp (idim, k, m, mx, n, nc, nest, kk, kk1, u, x, t, c, fp, per, fp0, s, fpint, nrdata, done)
 Set up the initial knot configuration for closed-curve interpolation.
 
pure subroutine fpcoco (iopt, m, x, y, w, v, s, nest, maxtr, maxbin, n, t, c, sq, sx, bind, e, wrk, lwrk, iwrk, kwrk, ier)
 Fit a convexity-constrained cubic smoothing spline.
 
pure subroutine fpcons (iopt, idim, m, u, mx, x, w, ib, ie, k, s, nest, tol, maxit, k1, k2, n, t, nc, c, fp, fpint, z, a, b, g, q, nrdata, ier)
 Core algorithm for constrained parametric curve fitting.
 
pure subroutine fpcosp (m, x, y, w, n, t, e, maxtr, maxbin, c, sq, sx, bind, nm, mb, a, b, const, z, zz, u, q, info, up, left, right, jbind, ibind, ier)
 Core algorithm for convexity-constrained cubic spline fitting.
 
pure elemental subroutine fpcsin (a, b, par, sia, coa, sib, cob, ress, resc)
 Compute weighted Fourier integrals of a cubic polynomial.
 
pure subroutine fpcurf (iopt, x, y, w, m, xb, xe, k, s, nest, tol, maxit, k1, k2, n, t, c, fp, fpint, z, a, b, g, q, nrdata, ier)
 Core algorithm for univariate spline curve fitting.
 
pure subroutine fpcuro (a, b, c, d, x, n)
 Find the real zeros of a cubic polynomial.
 
pure subroutine fpcyt1 (a, n, nn)
 LU-decompose a cyclic tridiagonal matrix.
 
pure subroutine fpcyt2 (a, n, b, c, nn)
 Solve a cyclic tridiagonal system using LU factors from fpcyt1.
 
pure subroutine fpdeno (maxtr, up, left, right, nbind, merk)
 Prune short branches from the constraint-set binary tree.
 
pure subroutine fpdisc (t, n, k2, b, nest)
 Compute the discontinuity jumps of the B-spline derivatives.
 
pure subroutine fpfrno (maxtr, up, left, right, info, point, merk, n1, count, ier)
 Collect free nodes from the constraint-set binary tree.
 
elemental subroutine fpgivs (piv, ww, cos, sin)
 Compute parameters of a Givens plane rotation.
 
pure subroutine fp_rotate_row (h, band, a, yi, z, j_start)
 Rotate an observation row into the upper triangular band matrix.
 
pure subroutine fp_rotate_row_vec (h, band, a, nest, xi, z, j_start, n, idim)
 Rotate an observation row into a band matrix with vector RHS.
 
pure subroutine fp_rotate_shifted (h, band, a, nest, yi, z, j_start, j_end)
 Rotate a smoothing-matrix row into a band matrix using shifted pivots.
 
pure subroutine fp_rotate_shifted_vec (h, band, a, nest, xi, z, j_start, j_end, n, idim)
 Rotate a smoothing-matrix row into a band matrix with vector RHS.
 
pure subroutine fp_rotate_row_2mat_vec (h1, band1, h2, band2, a1, a2, nest, xi, z, j1_start, j1_end, n, idim)
 Rotate a split observation row into the block-triangular periodic system with vector RHS.
 
pure subroutine fp_rotate_row_2mat (h1, band1, h2, band2, a1, a2, nest, yi, z, j1_start, j1_end)
 Rotate a split observation row into the block-triangular periodic system with scalar RHS.
 
pure subroutine fp_rotate_row_block (h, band, a, na, right, q, nrhs, irot_start)
 Rotate a row into a band matrix with contiguous-block RHS.
 
pure subroutine fp_rotate_row_stride (h, band, a, na, right, c, ldc, nrhs, irot_start)
 Rotate a row into a band matrix with stride (row-access) RHS.
 
pure subroutine fp_rotate_2mat_stride (h1, band1, h2, band2, a1, a2, na, right, c, ldc, nrhs, j1_start, j1_end)
 Rotate a split row into the block-triangular periodic system with stride RHS.
 
pure subroutine fpgrdi (ifsu, ifsv, ifbu, ifbv, lback, u, mu, v, mv, z, mz, dz, iop0, iop1, tu, nu, tv, nv, p, c, nc, sq, fp, fpu, fpv, mm, mvnu, spu, spv, right, q, au, av1, av2, bu, bv, aa, bb, cc, cosi, nru, nrv)
 Compute spline coefficients on a polar/spherical grid via Kronecker product.
 
pure subroutine fpgrpa (ifsu, ifsv, ifbu, ifbv, idim, ipar, u, mu, v, mv, z, mz, tu, nu, tv, nv, p, c, nc, fp, fpu, fpv, mm, mvnu, spu, spv, right, q, au, au1, av, av1, bu, bv, nru, nrv)
 Compute parametric surface spline coefficients on a grid.
 
pure subroutine fpgrre (ifsx, ifsy, ifbx, ifby, x, mx, y, my, z, mz, kx, ky, tx, nx, ty, ny, p, c, nc, fp, fpx, fpy, mm, mynx, kx1, kx2, ky1, ky2, spx, spy, right, q, ax, ay, bx, by, nrx, nry)
 Compute grid-based spline coefficients via Kronecker product decomposition.
 
pure subroutine fpgrsp (ifsu, ifsv, ifbu, ifbv, lback, u, mu, v, mv, r, mr, dr, iop0, iop1, tu, nu, tv, nv, p, c, nc, sq, fp, fpu, fpv, mm, mvnu, spu, spv, right, q, au, av1, av2, bu, bv, a0, a1, b0, b1, c0, c1, cosi, nru, nrv)
 Compute spherical grid spline coefficients via Kronecker product.
 
pure subroutine fpinst (iopt, t, n, c, k, x, l, tt, nn, cc, nest)
 Insert a single knot into a B-spline representation.
 
pure subroutine fpintb (t, n, bint, nk1, x, y)
 Compute definite integrals of the normalized B-splines.
 
pure subroutine fpknot (x, m, t, n, fpint, nrdata, nrint, nest, istart)
 Select and insert a new knot at the location of maximum residual.
 
pure subroutine fpopdi (ifsu, ifsv, ifbu, ifbv, u, mu, v, mv, z, mz, z0, dz, iopt, ider, tu, nu, tv, nv, nuest, nvest, p, step, c, nc, fp, fpu, fpv, nru, nrv, wrk, lwrk)
 Compute smoothing spline on a polar grid with origin constraints.
 
pure subroutine fpopsp (ifsu, ifsv, ifbu, ifbv, u, mu, v, mv, r, mr, r0, r1, dr, iopt, ider, tu, nu, tv, nv, nuest, nvest, p, step, c, nc, fp, fpu, fpv, nru, nrv, wrk, lwrk)
 Compute smoothing spline on a spherical grid with pole constraints.
 
pure subroutine fporde (x, y, m, kx, ky, tx, nx, ty, ny, nummer, index, nreg)
 Sort scattered data points into rectangular panels.
 
pure subroutine fppara (iopt, idim, m, u, mx, x, w, ub, ue, k, s, nest, tol, maxit, k1, k2, n, t, nc, c, fp, fpint, z, a, b, g, q, nrdata, ier)
 Core algorithm for open parametric curve fitting.
 
pure subroutine fppasu (iopt, ipar, idim, u, mu, v, mv, z, mz, s, nuest, nvest, tol, maxit, nc, nu, tu, nv, tv, c, fp, fp0, fpold, reducu, reducv, fpintu, fpintv, lastdi, nplusu, nplusv, nru, nrv, nrdatu, nrdatv, wrk, lwrk, ier)
 Core algorithm for parametric surface fitting on a grid.
 
pure subroutine fpperi (iopt, x, y, w, m, k, s, nest, tol, maxit, k1, k2, n, t, c, fp, fpint, z, a1, a2, b, g1, g2, q, nrdata, ier)
 Core algorithm for univariate periodic spline fitting.
 
pure subroutine fpperi_reset_interp (k, m, n, nest, kk, kk1, x, y, t, c, fp, per, fp0, s, fpint, nrdata, done)
 Set up the initial knot configuration for periodic spline interpolation.
 
pure subroutine fppocu (idim, k, a, b, ib, db, nb, ie, de, ne, cp, np)
 Construct a polynomial curve satisfying endpoint derivative constraints.
 
pure subroutine fppogr (iopt, ider, u, mu, v, mv, z, mz, z0, r, s, nuest, nvest, tol, maxit, nc, nu, tu, nv, tv, c, fp, fp0, fpold, reducu, reducv, fpintu, fpintv, dz, step, lastdi, nplusu, nplusv, lasttu, nru, nrv, nrdatu, nrdatv, wrk, lwrk, ier)
 Driver for polar grid smoothing spline with knot selection.
 
pure subroutine fppola (iopt1, iopt2, iopt3, m, u, v, z, w, rad, s, nuest, nvest, eta, tol, maxit, ib1, ib3, nc, ncc, intest, nrest, nu, tu, nv, tv, c, fp, sup, fpint, coord, f, ff, row, cs, cosi, a, q, bu, bv, spu, spv, h, index, nummer, wrk, lwrk, ier)
 Core algorithm for spline fitting on a polar domain.
 
elemental subroutine root_finding_iterate (p1, f1, p2, f2, p3, f3, p, fpms, acc, check1, check3, success)
 Update the smoothing parameter \( p \) during iterative knot selection.
 
pure subroutine fprank (a, f, n, m, na, tol, c, sq, rank, aa, ff, h)
 Compute the minimum-norm least-squares solution under rank deficiency.
 
elemental subroutine fprati (p1, f1, p2, f2, p3, f3, p)
 Rational interpolation for the smoothing parameter search.
 
pure subroutine fpregr (iopt, x, mx, y, my, z, mz, xb, xe, yb, ye, kx, ky, s, nxest, nyest, tol, maxit, nc, nx, tx, ny, ty, c, fp, fp0, fpold, reducx, reducy, fpintx, fpinty, lastdi, nplusx, nplusy, nrx, nry, nrdatx, nrdaty, wrk, lwrk, ier)
 Driver for rectangular grid smoothing surface with knot selection.
 
elemental integer function new_knot_dimension (n1, n1add, n1max, n2, n2add, n2max, last)
 Choose which dimension receives the next knot during bivariate fitting.
 
elemental subroutine fprota (cos, sin, a, b)
 Apply a Givens plane rotation to two scalars.
 
pure subroutine fprppo (nu, nv, if1, if2, cosi, ratio, c, f, ncoff)
 Convert constrained polar spline coefficients to standard form.
 
pure subroutine fprpsp (nt, np, co, si, c, f, ncoff)
 Convert constrained spherical spline coefficients to standard form.
 
pure subroutine fpseno (maxtr, up, left, right, info, merk, ibind, nbind)
 Fetch and advance to the next branch in the constraint-set tree.
 
pure subroutine fpspgr (iopt, ider, u, mu, v, mv, r, mr, r0, r1, s, nuest, nvest, tol, maxit, nc, nu, tu, nv, tv, c, fp, fp0, fpold, reducu, reducv, fpintu, fpintv, dr, step, lastdi, nplusu, nplusv, lastu0, lastu1, nru, nrv, nrdatu, nrdatv, wrk, lwrk, ier)
 Driver for spherical grid smoothing spline with knot selection.
 
pure subroutine fpsphe (iopt, m, teta, phi, r, w, s, ntest, npest, eta, tol, maxit, ib1, ib3, nc, ncc, intest, nrest, nt, tt, np, tp, c, fp, sup, fpint, coord, f, ff, row, coco, cosi, a, q, bt, bp, spt, spp, h, index, nummer, wrk, lwrk, ier)
 Core algorithm for spline fitting on the sphere.
 
pure subroutine fpsuev (idim, tu, nu, tv, nv, c, u, mu, v, mv, f, wu, wv, lu, lv)
 Evaluate a parametric bicubic tensor-product spline surface.
 
pure subroutine fpsurf (iopt, m, x, y, z, w, xb, xe, yb, ye, kxx, kyy, s, nxest, nyest, eta, tol, maxit, nmax, km1, km2, ib1, ib3, nc, intest, nrest, nx0, tx, ny0, ty, c, fp, fp0, fpint, coord, f, ff, a, q, bx, by, spx, spy, h, index, nummer, wrk, lwrk, ier)
 Core algorithm for bivariate tensor-product spline surface fitting.
 
pure subroutine fpsysy (a, n, g)
 Solve a small symmetric linear system by Cholesky factorization.
 
pure subroutine fptrnp (m, mm, idim, n, nr, sp, p, b, z, a, q, right)
 Triangularize the tensor-product system for non-periodic grids.
 
pure subroutine fptrpe (m, mm, idim, n, nr, sp, p, b, z, a, aa, q, right)
 Triangularize the tensor-product system for periodic grids.
 
pure subroutine, public insert (iopt, t, n, c, k, x, tt, nn, cc, nest, ier)
 Insert a single knot into a spline, returning a new B-spline representation.
 
pure subroutine, public insert_inplace (iopt, t, n, c, k, x, nest, ier)
 Insert a single knot into a spline in place (avoiding aliasing issues).
 
pure subroutine, public parcur (iopt, ipar, idim, m, u, mx, x, w, ub, ue, k, s, nest, n, t, nc, c, fp, wrk, lwrk, iwrk, ier)
 Determine a smooth parametric spline curve approximation.
 
pure subroutine, public parder (tx, nx, ty, ny, c, kx, ky, nux, nuy, x, mx, y, my, z, wrk, lwrk, iwrk, kwrk, ier)
 Evaluate a partial derivative of a bivariate spline on a rectangular grid.
 
pure subroutine, public pardeu (tx, nx, ty, ny, c, kx, ky, nux, nuy, x, y, z, m, wrk, lwrk, iwrk, kwrk, ier)
 Evaluate a partial derivative of a bivariate spline at scattered points.
 
pure subroutine, public pardtc (tx, nx, ty, ny, c, kx, ky, nux, nuy, newc, ier)
 Transform B-spline coefficients to obtain the partial derivative spline.
 
pure subroutine, public parsur (iopt, ipar, idim, mu, u, mv, v, f, s, nuest, nvest, nu, tu, nv, tv, c, fp, wrk, lwrk, iwrk, kwrk, ier)
 Fit a smooth parametric surface to gridded data.
 
pure subroutine, public percur (iopt, m, x, y, w, k, s, nest, n, t, c, fp, wrk, lwrk, iwrk, ier)
 Determine a smooth periodic spline approximation to data.
 
subroutine, public pogrid (iopt, ider, mu, u, mv, v, z, z0, r, s, nuest, nvest, nu, tu, nv, tv, c, fp, wrk, lwrk, iwrk, kwrk, ier)
 Fit a smooth bivariate spline to gridded data on a polar (disc) domain.
 
pure subroutine, public polar (iopt, m, x, y, z, w, rad, s, nuest, nvest, eps, nu, tu, nv, tv, u, v, c, fp, wrk1, lwrk1, wrk2, lwrk2, iwrk, kwrk, ier)
 Fit a smooth bivariate spline to scattered data on a polar domain.
 
pure subroutine, public profil (iopt, tx, nx, ty, ny, c, kx, ky, u, nu, cu, ier)
 Extract a cross-section (profile) of a bivariate spline.
 
pure subroutine, public regrid (iopt, mx, x, my, y, z, xb, xe, yb, ye, kx, ky, s, nxest, nyest, nx, tx, ny, ty, c, fp, wrk, lwrk, iwrk, kwrk, ier)
 Fit a smoothing bivariate spline to data on a rectangular grid.
 
pure subroutine, public spalde (t, n, c, k1, x, d, ier)
 Evaluate all derivatives of a spline at a single point.
 
pure subroutine, public spgrid (iopt, ider, mu, u, mv, v, r, r0, r1, s, nuest, nvest, nu, tu, nv, tv, c, fp, wrk, lwrk, iwrk, kwrk, ier)
 Fit a smooth bivariate spline to gridded data on a sphere (latitude-longitude grid).
 
pure subroutine, public sphere (iopt, m, teta, phi, r, w, s, ntest, npest, eps, nt, tt, np, tp, c, fp, wrk1, lwrk1, wrk2, lwrk2, iwrk, kwrk, ier)
 Fit a smooth bicubic spherical spline to scattered data on a sphere.
 
pure subroutine, public splder (t, n, c, k, nu, x, y, m, e, wrk, ier)
 Evaluate the \( \nu \)-th derivative of a spline \( s(x) \) at a set of points.
 
pure subroutine, public splev (t, n, c, k, x, y, m, e, ier)
 Evaluate a spline \( s(x) \) of degree \( k \) at a set of points.
 
real(fp_real) function, public splint (t, n, c, k, a, b, wrk)
 Compute the definite integral of a spline \( s(x) \) over \( [a, b] \).
 
pure subroutine, public sproot (t, n, c, zeros, mest, m, ier)
 Find the zeros of a cubic spline \( s(x) \) given in B-spline representation.
 
pure subroutine, public surev (idim, tu, nu, tv, nv, c, u, mu, v, mv, f, mf, wrk, lwrk, iwrk, kwrk, ier)
 Evaluate a parametric bicubic spline surface on a grid.
 
pure subroutine, public surfit (iopt, m, x, y, z, w, xb, xe, yb, ye, kx, ky, s, nxest, nyest, nmax, eps, nx, tx, ny, ty, c, fp, wrk1, lwrk1, wrk2, lwrk2, iwrk, kwrk, ier)
 Fit a smoothing bivariate spline to scattered data.
 
pure integer(fp_size) function, dimension(size(list)), public fitpack_argsort (list)
 Return the permutation indices that would sort an array.
 
pure recursive subroutine fitpack_quicksort (list, ilist, down)
 In-place quicksort with optional index tracking.
 
elemental subroutine swap_data (a, b)
 Swap two real values in place.
 
elemental subroutine swap_size (a, b)
 Swap two integer values in place.
 
elemental logical(fp_bool) function is_before (a, b)
 Test \( a < b \) (strict less-than).
 
elemental logical(fp_bool) function is_after (a, b)
 Test \( a > b \) (strict greater-than).
 
elemental logical(fp_bool) function is_ge (a, b)
 Test \( a \ge b \).
 
elemental logical(fp_bool) function is_le (a, b)
 Test \( a \le b \).
 
elemental logical(fp_bool) function, public equal (a, b)
 Test whether two reals are equal within machine precision.
 
elemental logical(fp_bool) function not_equal (a, b)
 Test whether two reals differ beyond machine precision.
 
elemental integer(fp_size) function, public fp_rcomms_per_bits (nbits)
 Number of FP_COMM elements required to store nbits of data.
 
pure integer(fp_size) function fp_real_comm_size_1d (array)
 Calculate storage size for 1D real(FP_REAL) allocatable array Header: 1 FP_COMM storing bounds as 2 int32 (or NOT_ALLOC marker) Data: raw transfer of array contents.
 
pure integer(fp_size) function fp_real_comm_size_2d (array)
 Calculate storage size for 2D real(FP_REAL) allocatable array.
 
pure integer(fp_size) function fp_real_comm_size_3d (array)
 Calculate storage size for 3D real(FP_REAL) allocatable array.
 
pure integer(fp_size) function fp_size_comm_size_1d (array)
 Calculate storage size for 1D integer(FP_SIZE) allocatable array.
 
pure subroutine fp_real_comm_pack_1d (array, buffer)
 Pack 1D real(FP_REAL) allocatable array into communication buffer.
 
pure subroutine fp_real_comm_pack_2d (array, buffer)
 Pack 2D real(FP_REAL) allocatable array into communication buffer.
 
pure subroutine fp_real_comm_pack_3d (array, buffer)
 Pack 3D real(FP_REAL) allocatable array into communication buffer.
 
pure subroutine fp_size_comm_pack_1d (array, buffer)
 Pack 1D integer(FP_SIZE) allocatable array into communication buffer.
 
pure subroutine fp_real_comm_expand_1d (array, buffer)
 Expand communication buffer into 1D real(FP_REAL) allocatable array.
 
pure subroutine fp_real_comm_expand_2d (array, buffer)
 Expand communication buffer into 2D real(FP_REAL) allocatable array.
 
pure subroutine fp_real_comm_expand_3d (array, buffer)
 Expand communication buffer into 3D real(FP_REAL) allocatable array.
 
pure subroutine fp_size_comm_expand_1d (array, buffer)
 Expand communication buffer into 1D integer(FP_SIZE) allocatable array.
 
pure integer(fp_size) function fp_bool_comm_size_1d (array)
 Calculate storage size for 1D logical(FP_BOOL) allocatable array.
 
pure subroutine fp_bool_comm_pack_1d (array, buffer)
 Pack 1D logical(FP_BOOL) allocatable array into communication buffer.
 
pure subroutine fp_bool_comm_expand_1d (array, buffer)
 Expand communication buffer into 1D logical(FP_BOOL) allocatable array.
 

Variables

integer, parameter, public fp_real = c_double
 
integer, parameter, public fp_size = c_int32_t
 
integer, parameter, public fp_flag = c_int32_t
 
integer, parameter, public fp_bool = c_bool
 
integer, parameter, public fp_comm = c_double
 
integer(fp_size), parameter fp_not_alloc = -99999999_FP_SIZE
 Marker for unallocated arrays in communication buffers.
 
integer(fp_flag), parameter, public outside_extrapolate = 0
 
integer(fp_flag), parameter, public outside_zero = 1
 
integer(fp_flag), parameter, public outside_not_allowed = 2
 
integer(fp_flag), parameter, public outside_nearest_bnd = 3
 
integer(fp_flag), parameter, public iopt_new_leastsquares = -1
 
integer(fp_flag), parameter, public iopt_new_smoothing = 0
 
integer(fp_flag), parameter, public iopt_old_fit = 1
 
integer(fp_size), parameter, public max_idim = 10
 
integer(fp_flag), parameter, public knot_dim_none = 0
 
integer(fp_flag), parameter, public knot_dim_2 = 1
 
integer(fp_flag), parameter, public knot_dim_1 = -1
 
integer(fp_size), parameter, public max_order = 19
 
integer(fp_size), parameter, public degree_3 = 3
 
integer(fp_size), parameter, public degree_4 = 4
 
integer(fp_size), parameter, public degree_5 = 5
 
integer(fp_flag), parameter, public fitpack_ok = 0
 
integer(fp_flag), parameter, public fitpack_interpolating_ok = -1
 
integer(fp_flag), parameter, public fitpack_leastsquares_ok = -2
 
integer(fp_flag), parameter, public fitpack_insufficient_storage = 1
 
integer(fp_flag), parameter, public fitpack_s_too_small = 2
 
integer(fp_flag), parameter, public fitpack_maxit = 3
 
integer(fp_flag), parameter, public fitpack_too_many_knots = 4
 
integer(fp_flag), parameter, public fitpack_overlapping_knots = 5
 
integer(fp_flag), parameter, public fitpack_invalid_range = 6
 
integer(fp_flag), parameter, public fitpack_input_error = 10
 
integer(fp_flag), parameter, public fitpack_test_error = 11
 
integer(fp_flag), parameter, public fitpack_invalid_constraint = 12
 
integer(fp_flag), parameter, public fitpack_insufficient_knots = 13
 
integer(fp_flag), parameter, public concon_maxbin = 14
 
integer(fp_flag), parameter, public concon_maxtr = 15
 
integer(fp_flag), parameter, public concon_qp_fail = 16
 
logical(fp_bool), parameter, public fp_true = .true._FP_BOOL
 
logical(fp_bool), parameter, public fp_false = .false._FP_BOOL
 
integer(fp_size), parameter izero = 0_FP_SIZE
 
integer(fp_size), parameter ione = 1_FP_SIZE
 
integer(fp_size), parameter itwo = 2_FP_SIZE
 
integer(fp_size), parameter ithree = 3_FP_SIZE
 
integer(fp_size), parameter ifour = 4_FP_SIZE
 
integer(fp_size), parameter ifive = 5_FP_SIZE
 
real(fp_real), parameter, public one = 1.0_FP_REAL
 
real(fp_real), parameter, public zero = 0.0_FP_REAL
 
real(fp_real), parameter, public half = 0.5_FP_REAL
 
real(fp_real), parameter, public onep5 = 1.5_FP_REAL
 
real(fp_real), parameter, public third = one/3.0_FP_REAL
 
real(fp_real), parameter, public fourth = 0.25_FP_REAL
 
real(fp_real), parameter, public two = 2.0_FP_REAL
 
real(fp_real), parameter, public three = 3.0_FP_REAL
 
real(fp_real), parameter, public four = 4.0_FP_REAL
 
real(fp_real), parameter, public five = 5.0_FP_REAL
 
real(fp_real), parameter, public six = 6.0_FP_REAL
 
real(fp_real), parameter, public ten = 10.0_FP_REAL
 
real(fp_real), parameter, public pi = atan2(zero, -one)
 
real(fp_real), parameter, public pi2 = 2*pi
 
real(fp_real), parameter, public pi4 = 4*pi
 
real(fp_real), parameter, public pio2 = half*pi
 
real(fp_real), parameter, public pio4 = fourth*pi
 
real(fp_real), parameter, public pio8 = 0.125_FP_REAL*pi
 
real(fp_real), parameter, public deg2rad = pi/180.0_FP_REAL
 
real(fp_real), parameter, public smallnum03 = 1.0e-03_FP_REAL
 
real(fp_real), parameter, public smallnum06 = 1.0e-06_FP_REAL
 
real(fp_real), parameter, public smallnum08 = 1.0e-08_FP_REAL
 
real(fp_real), parameter, public smallnum10 = 1.0e-10_FP_REAL
 

Function/Subroutine Documentation

◆ bispeu()

pure subroutine, public fitpack_core::bispeu ( real(fp_real), dimension(nx), intent(in) tx,
integer(fp_size), intent(in) nx,
real(fp_real), dimension(ny), intent(in) ty,
integer(fp_size), intent(in) ny,
real(fp_real), dimension((nx-kx-1)*(ny-ky-1)), intent(in) c,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(m), intent(out) z,
integer(fp_size), intent(in) m,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_flag), intent(out) ier )

Evaluate a bivariate spline at scattered points \( (x_i, y_i) \).

Given a bivariate spline \( s(x,y) \) of degrees \( k_x \) and \( k_y \) in tensor-product B-spline representation, evaluates \( s(x_i, y_i) \) for \( i = 1,\ldots,m \) at arbitrary (scattered) points.

Parameters
[in]txKnot positions in \( x \)-direction (length \( n_x \)).
[in]nxTotal number of knots in \( x \).
[in]tyKnot positions in \( y \)-direction (length \( n_y \)).
[in]nyTotal number of knots in \( y \).
[in]cB-spline coefficients, length \( (n_x{-}k_x{-}1)(n_y{-}k_y{-}1) \).
[in]kxDegree in \( x \).
[in]kyDegree in \( y \).
[in]x\( x \)-coordinates of evaluation points (length \( m \)).
[in]y\( y \)-coordinates of evaluation points (length \( m \)).
[out]zSpline values \( s(x_i, y_i) \) (length \( m \)).
[in]mNumber of evaluation points, \( m \ge 1 \).
[in,out]wrkReal workspace, length \( \ge k_x + k_y + 2 \).
[in]lwrkDeclared dimension of wrk.
[out]ierError flag: 0 = normal return; 10 = invalid input.
See also
bispev — grid evaluation variant; fpbisp — tensor-product evaluation kernel
Here is the call graph for this function:

◆ bispev()

pure subroutine, public fitpack_core::bispev ( real(fp_real), dimension(nx), intent(in) tx,
integer(fp_size), intent(in) nx,
real(fp_real), dimension(ny), intent(in) ty,
integer(fp_size), intent(in) ny,
real(fp_real), dimension((nx-kx-1)*(ny-ky-1)), intent(in) c,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
real(fp_real), dimension(mx), intent(in) x,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(my), intent(in) y,
integer(fp_size), intent(in) my,
real(fp_real), dimension(mx*my), intent(out) z,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Evaluate a bivariate spline on a rectangular grid.

Given a bivariate spline \( s(x,y) \) of degrees \( k_x \) and \( k_y \) in tensor-product B-spline representation, evaluates \( s(x_i, y_j) \) on the grid \( i = 1,\ldots,m_x;\ j = 1,\ldots,m_y \).

Here is the call graph for this function:

◆ clocur()

pure subroutine, public fitpack_core::clocur ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) ipar,
integer(fp_size), intent(in) idim,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(inout) u,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(mx), intent(in) x,
real(fp_real), dimension(m), intent(in) w,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nest,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
integer(fp_size), intent(in) nc,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(nest), intent(inout) iwrk,
integer(fp_flag), intent(inout) ier )

Determine a smooth closed parametric spline curve approximation.

Given \( m \) data points \( \mathbf{x}_i \in \mathbb{R}^{\text{idim}} \) with \( \mathbf{x}_1 = \mathbf{x}_m \) (closure condition) and weights \( w_i > 0 \), computes an idim-dimensional periodic spline curve \( \mathbf{s}(u) = (s_1(u),\ldots,s_{\text{idim}}(u)) \) of degree \( k \).

Parameter values \( u_i \) can be supplied by the user (ipar=1) or computed automatically from cumulative chord lengths (ipar=0).

Parameters
[in]ioptComputation mode: -1 (LSQ), 0 (new smoothing), 1 (continue).
[in]iparParameter mode: 0 = automatic (chord-length), 1 = user-supplied.
[in]idimDimension of the curve, \( 1 \le \text{idim} \le 10 \).
[in]mNumber of data points, \( m > 1 \).
[in,out]uParameter values (length \( m \)). Output when ipar=0.
[in]mxDeclared dimension of x, \( \text{mx} \ge \text{idim} \times m \).
[in]xData coordinates: x(idim*(i-1)+j) is the \( j \)-th coordinate of point \( i \). First and last points must coincide.
[in]wWeights (length \( m \)). \( w_m \) not used.
[in]kSpline degree, \( 1 \le k \le 5 \). Cubic recommended.
[in]sSmoothing factor \( S \ge 0 \).
[in]nestOver-estimate of total knots. nest=m+2*k always suffices.
[in,out]nTotal number of knots.
[in,out]tKnot positions (length nest).
[in]ncDeclared dimension of c, \( \text{nc} \ge \text{nest} \times \text{idim} \).
[in,out]cB-spline coefficients (length nc).
[in,out]fpWeighted sum of squared residuals.
[in,out]wrkReal workspace, length \( \ge m(k+1) + \text{nest}(7+\text{idim}+5k) \).
[in]lwrkDeclared dimension of wrk.
[in,out]iwrkInteger workspace (length nest).
[in,out]ierError flag (same codes as curfit).
See also
Dierckx, Ch. 6, §6.1–6.2; fpclos — core closed-curve fitting algorithm
Here is the call graph for this function:

◆ cocosp()

pure subroutine, public fitpack_core::cocosp ( integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(m), intent(in) w,
integer(fp_size), intent(in) n,
real(fp_real), dimension(n), intent(in) t,
real(fp_real), dimension(n), intent(inout) e,
integer(fp_size), intent(in) maxtr,
integer(fp_size), intent(in) maxbin,
real(fp_real), dimension(n), intent(out) c,
real(fp_real), intent(out) sq,
real(fp_real), dimension(m), intent(out) sx,
logical(fp_bool), dimension(n), intent(out) bind,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Fit a cubic spline with convexity/concavity constraints and user-specified knots.

Given data points \( (x_i, y_i) \) with weights \( w_i > 0 \) and a fixed set of knots \( t_j \), computes the weighted least-squares cubic spline \( s(x) \) subject to local convexity/concavity constraints specified by the array e:

  • \( e_j = +1 \): \( s''(t_{j+3}) \ge 0 \) (locally concave)
  • \( e_j = -1 \): \( s''(t_{j+3}) \le 0 \) (locally convex)
  • \( e_j = 0 \): no constraint at \( t_{j+3} \)

The constrained fitting uses a quadratic programming approach with a binary tree structure for managing active constraints.

Parameters
[in]mNumber of data points, \( m > 3 \).
[in]xAbscissae (strictly ascending).
[in]yOrdinates.
[in]wWeights, \( w_i > 0 \).
[in]nTotal number of knots, \( 8 \le n \le m + 4 \).
[in]tKnot positions (length \( n \)), user-specified.
[in,out]eConvexity indicators (length \( n \)). Only e(1:n-6) used.
[in]maxtrOver-estimate of tree records. maxtr=100 usually sufficient.
[in]maxbinOver-estimate of inflection knots. maxbin=10 usually sufficient.
[out]cB-spline coefficients (length \( n \)).
[out]sqWeighted sum of squared residuals.
[out]sxSpline values at data points (length \( m \)).
[out]bindActive constraint flags (length \( n \)): .true. where \( s''=0 \).
[in,out]wrkReal workspace, length \( \ge 4m + 7n + \text{maxbin}(\text{maxbin}+n+1) \).
[in]lwrkDeclared dimension of wrk.
[in,out]iwrkInteger workspace, length \( \ge 4 \times \text{maxtr} + 2(\text{maxbin}+1) \).
[in]kwrkDeclared dimension of iwrk.
[out]ierError flag: 0 = success; 1 = maxbin exceeded; 2 = maxtr exceeded; 3 = QP solver failed; 10 = invalid input.
See also
Dierckx, Ch. 7, §7.1–7.2; fpcosp — core convexity-constrained algorithm
Here is the call graph for this function:

◆ concon()

pure subroutine, public fitpack_core::concon ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(m), intent(in) w,
real(fp_real), dimension(m), intent(inout) v,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nest,
integer(fp_size), intent(in) maxtr,
integer(fp_size), intent(in) maxbin,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
real(fp_real), dimension(nest), intent(inout) c,
real(fp_real), intent(out) sq,
real(fp_real), dimension(m), intent(inout) sx,
logical(fp_bool), dimension(nest), intent(inout) bind,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Fit a cubic spline with convexity/concavity constraints and automatic knot placement.

Given data points \( (x_i, y_i) \) with weights \( w_i > 0 \) and local convexity/concavity requirements \( v_i \in \{-1, 0, +1\} \) at the data points, determines a cubic spline \( s(x) \) satisfying the constraints with weighted residual sum \( \text{sq} \le S \).

Unlike cocosp (which takes fixed knots), concon automatically selects the number and position of knots, starting from a minimal set and adding knots progressively.

Parameters
[in]ioptComputation mode: 0 = start with minimal knots; 1 = continue.
[in]mNumber of data points, \( m > 3 \).
[in]xAbscissae (strictly ascending).
[in]yOrdinates.
[in]wWeights, \( w_i > 0 \).
[in,out]vConvexity indicators at data points: +1 (concave), -1 (convex), 0 (free).
[in]sSmoothing factor \( S \ge 0 \) (target upper bound for sq).
[in]nestOver-estimate of total knots, \( \ge 8 \). nest=m+4 always suffices.
[in]maxtrOver-estimate of tree records. maxtr=100 usually sufficient.
[in]maxbinOver-estimate of inflection knots. maxbin=10 usually sufficient.
[in,out]nTotal number of knots.
[in,out]tKnot positions (length nest).
[in,out]cB-spline coefficients (length nest).
[out]sqWeighted sum of squared residuals.
[in,out]sxSpline values at data points (length \( m \)).
[in,out]bindActive constraint flags (length nest).
[in,out]wrkReal workspace, length \( \ge 4m + 8\,\text{nest} + \text{maxbin}(\text{maxbin}+\text{nest}+1) \).
[in]lwrkDeclared dimension of wrk.
[in,out]iwrkInteger workspace, length \( \ge 4\,\text{maxtr} + 2(\text{maxbin}+1) \).
[in]kwrkDeclared dimension of iwrk.
[out]ierError flag:
  • 0: normal return ( \( \text{sq} \le S \) and constraints satisfied).
  • -3: nest too small.
  • -2: max knots \( m+4 \) reached.
  • -1: adding knots won't help.
  • 15: various errors (maxbin, maxtr, QP, nest, constraint conflicts).
  • 10: invalid input.
See also
Dierckx, Ch. 7, §7.2; fpcoco — convexity-constrained driver; fpcosp — core algorithm
Here is the call graph for this function:

◆ concur()

pure subroutine, public fitpack_core::concur ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) idim,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) u,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(mx), intent(in) x,
real(fp_real), dimension(mx), intent(inout) xx,
real(fp_real), dimension(m), intent(in) w,
integer(fp_size), intent(in) ib,
real(fp_real), dimension(nb), intent(in) db,
integer(fp_size), intent(in) nb,
integer(fp_size), intent(in) ie,
real(fp_real), dimension(ne), intent(in) de,
integer(fp_size), intent(in) ne,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nest,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
integer(fp_size), intent(in) nc,
real(fp_real), dimension(nc), intent(inout) c,
integer(fp_size), intent(in) np,
real(fp_real), dimension(np), intent(inout) cp,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(nest), intent(inout) iwrk,
integer(fp_flag), intent(out) ier )

Determine a smooth parametric spline curve with derivative constraints at endpoints.

Given \( m \) ordered points \( \mathbf{x}_i \in \mathbb{R}^{\text{idim}} \) with parameter values \( u_i \) and weights \( w_i > 0 \), computes a parametric spline curve \( \mathbf{s}(u) \) of degree \( k \) that satisfies derivative constraints at the endpoints:

\[ s_j^{(l)}(u_1) = d_b(\text{idim} \cdot l + j), \quad l = 0,\ldots,i_b{-}1 \]

\[ s_j^{(l)}(u_m) = d_e(\text{idim} \cdot l + j), \quad l = 0,\ldots,i_e{-}1 \]

Parameters
[in]ioptComputation mode: -1 (LSQ), 0 (new smoothing), 1 (continue).
[in]idimDimension of the curve, \( 1 \le \text{idim} \le 10 \).
[in]mNumber of data points.
[in]uParameter values (strictly ascending).
[in]mxDeclared dimension of x and xx.
[in]xData coordinates (length mx).
[in,out]xxWorkspace (length mx). Modified data for constrained fitting.
[in]wWeights (length \( m \)), strictly positive.
[in]ibNumber of derivative constraints at \( u_1 \), \( 0 \le i_b \le (k+1)/2 \).
[in]dbBegin-point derivatives (length nb).
[in]nbDimension of db, \( \ge \max(1, \text{idim} \times i_b) \).
[in]ieNumber of derivative constraints at \( u_m \), \( 0 \le i_e \le (k+1)/2 \).
[in]deEnd-point derivatives (length ne).
[in]neDimension of de, \( \ge \max(1, \text{idim} \times i_e) \).
[in]kSpline degree: 1, 3, or 5.
[in]sSmoothing factor \( S \ge 0 \).
[in]nestOver-estimate of total knots.
[in,out]nTotal number of knots.
[in,out]tKnot positions (length nest).
[in]ncDeclared dimension of c.
[in,out]cB-spline coefficients (length nc).
[in]npDeclared dimension of cp, \( \ge 2(k+1) \times \text{idim} \).
[in,out]cpConstraint polynomial coefficients (length np).
[in,out]fpWeighted sum of squared residuals.
[in,out]wrkReal workspace.
[in]lwrkDeclared dimension of wrk.
[in,out]iwrkInteger workspace (length nest).
[out]ierError flag (same codes as curfit).
See also
Dierckx, Ch. 8, §8.2; fpcons — core constrained fitting algorithm
Here is the call graph for this function:

◆ cualde()

pure subroutine, public fitpack_core::cualde ( integer(fp_size), intent(in) idim,
real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(nc), intent(in) c,
integer(fp_size), intent(in) nc,
integer(fp_size), intent(in) k1,
real(fp_real), intent(in) u,
real(fp_real), dimension(nd), intent(out) d,
integer(fp_size), intent(in) nd,
integer(fp_flag), intent(out) ier )

Evaluate all derivatives of a parametric spline curve at a single point.

Given an idim-dimensional spline curve \( \mathbf{s}(u) = (s_1(u),\ldots,s_{\text{idim}}(u)) \) of order \( k_1 = k + 1 \) with common knots, evaluates all derivatives up to order \( k \) at the point \( u \). Uses the stable recurrence scheme of de Boor for each coordinate component.

Parameters
[in]idimDimension of the curve.
[in]tKnot positions (length \( n \)), common to all components.
[in]nTotal number of knots.
[in]cB-spline coefficients (length nc), stored as \( n \) coefficients for each of the idim components consecutively.
[in]ncTotal number of coefficients ( \( \ge n \times \text{idim} \)).
[in]k1Order of the spline ( \( k_1 = k + 1 \)).
[in]uParameter value where derivatives are evaluated. Must satisfy \( t_{k_1} \le u \le t_{n-k_1+1} \).
[out]dDerivative values (length nd): d(idim*l+j) contains the \( j \)-th coordinate of the \( l \)-th derivative.
[in]ndDimension of d. Must satisfy \( \text{nd} \ge k_1 \times \text{idim} \).
[out]ierError flag: 0 = normal return; 10 = invalid input.
Note
At a knot, right derivatives are computed (left derivatives at the right boundary).
See also
spalde — scalar variant; fpader — derivative computation kernel
Here is the call graph for this function:

◆ curev()

pure subroutine, public fitpack_core::curev ( integer(fp_size), intent(in) idim,
real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(nc), intent(in) c,
integer(fp_size), intent(in) nc,
integer(fp_size), intent(in) k,
real(fp_real), dimension(m), intent(in) u,
integer(fp_size), intent(in) m,
real(fp_real), dimension(idim,m), intent(out) x,
integer(fp_size), intent(in) mx,
integer(fp_flag), intent(out) ier )

Evaluate a parametric spline curve at a set of parameter values.

Given an idim-dimensional spline curve \( \mathbf{s}(u) = (s_1(u),\ldots,s_{\text{idim}}(u)) \) of degree \( k \) in B-spline representation with common knots, evaluates \( \mathbf{s}(u_i) \) for \( i = 1,\ldots,m \).

Parameters
[in]idimDimension of the curve ( \( 1 \le \text{idim} \le 10 \)).
[in]tKnot positions (length \( n \)).
[in]nTotal number of knots.
[in]cB-spline coefficients (length nc), stored consecutively for each dimension.
[in]ncTotal number of coefficients.
[in]kDegree of the spline.
[in]uParameter values (length \( m \)), must be non-decreasing and within \( [t_{k+1}, t_{n-k}] \).
[in]mNumber of evaluation points, \( m \ge 1 \).
[out]xCurve values (length mx): x(idim*(i-1)+j) is the \( j \)-th coordinate at the \( i \)-th point.
[in]mxDimension of x. Must satisfy \( \text{mx} \ge m \times \text{idim} \).
[out]ierError flag: 0 = normal return; 10 = invalid input.
See also
Dierckx, Ch. 6, §6.3; fpbspl — B-spline basis evaluation
Here is the call graph for this function:

◆ curfit()

pure subroutine, public fitpack_core::curfit ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(m), intent(in) w,
real(fp_real), intent(in) xb,
real(fp_real), intent(in) xe,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nest,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
real(fp_real), dimension(nest), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(nest), intent(inout) iwrk,
integer(fp_flag), intent(out) ier )

Determine a smooth spline approximation of degree \( k \) to a set of data points.

Given data points \( (x_i, y_i) \) with positive weights \( w_i \), \( i=1,\ldots,m \), computes a spline \( s(x) \) of degree \( k \) on the interval \( [x_b, x_e] \).

  • If iopt=-1: computes the weighted least-squares spline for a given set of knots.
  • If iopt>=0: the number and position of knots is chosen automatically. Smoothness is achieved by minimizing discontinuity jumps of the \( k \)-th derivative at interior knots, subject to the constraint

    \[ F(p) = \sum_{i=1}^{m} \bigl(w_i\,(y_i - s(x_i))\bigr)^2 \le S \]

    where \( S \ge 0 \) is the smoothing factor.

The result is returned in B-spline representation with coefficients \( c_j,\ j=1,\ldots,n{-}k{-}1 \) and can be evaluated with splev.

Here is the call graph for this function:

◆ dblint()

real(fp_real) function, public fitpack_core::dblint ( real(fp_real), dimension(nx), intent(in) tx,
integer(fp_size), intent(in) nx,
real(fp_real), dimension(ny), intent(in) ty,
integer(fp_size), intent(in) ny,
real(fp_real), dimension((nx-kx-1)*(ny-ky-1)), intent(in) c,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
real(fp_real), intent(in) xb,
real(fp_real), intent(in) xe,
real(fp_real), intent(in) yb,
real(fp_real), intent(in) ye,
real(fp_real), dimension(nx+ny-kx-ky-2), intent(out) wrk )

Compute the double integral of a bivariate spline over a rectangle.

Calculates \( \int_{x_b}^{x_e} \int_{y_b}^{y_e} s(x,y)\,dx\,dy \) for a bivariate spline of degrees \( k_x \) and \( k_y \) in tensor-product B-spline representation. The spline is considered identically zero outside its support rectangle \( (t^x_{k_x+1}, t^x_{n_x-k_x}) \times (t^y_{k_y+1}, t^y_{n_y-k_y}) \).

Parameters
[in]txKnot positions in \( x \) (length \( n_x \)).
[in]nxTotal number of knots in \( x \).
[in]tyKnot positions in \( y \) (length \( n_y \)).
[in]nyTotal number of knots in \( y \).
[in]cB-spline coefficients, length \( (n_x{-}k_x{-}1)(n_y{-}k_y{-}1) \).
[in]kxDegree in \( x \).
[in]kyDegree in \( y \).
[in]xbLeft boundary of integration in \( x \).
[in]xeRight boundary of integration in \( x \).
[in]ybLower boundary of integration in \( y \).
[in]yeUpper boundary of integration in \( y \).
[out]wrkWorkspace (length \( \ge n_x + n_y - k_x - k_y - 2 \)). On exit, contains integrals of normalized B-splines in each direction.
Returns
The double integral \( \iint s(x,y)\,dx\,dy \).
See also
splint — univariate integral; fpintb — B-spline integration
Here is the call graph for this function:

◆ equal()

elemental logical(fp_bool) function, public fitpack_core::equal ( real(fp_real), intent(in) a,
real(fp_real), intent(in) b )

Test whether two reals are equal within machine precision.

Returns .true. if \( |a - b| < \text{spacing}(\min(|a|,|b|)) \).

Here is the call graph for this function:

◆ evapol()

pure real(fp_real) function, public fitpack_core::evapol ( real(fp_real), dimension(nu), intent(in) tu,
integer(fp_size), intent(in) nu,
real(fp_real), dimension(nv), intent(in) tv,
integer(fp_size), intent(in) nv,
real(fp_real), dimension((nu-4)*(nv-4)), intent(in) c,
procedure(fitpack_polar_boundary) rad,
real(fp_real), intent(in) x,
real(fp_real), intent(in) y )

Evaluate a polar spline \( f(x,y) = s(u,v) \) at a Cartesian point.

Given a bicubic spline \( s(u,v) \) ( \( 0 \le u \le 1 \), \( -\pi \le v \le \pi \)) fitted by polar, evaluates \( f(x,y) \) via the polar transformation:

\[ x = u \cdot r(v) \cos v, \qquad y = u \cdot r(v) \sin v \]

where \( r(v) \) is the boundary function defining the polar domain.

Parameters
[in]tuKnot positions in \( u \) (length \( n_u \)).
[in]nuTotal number of knots in \( u \).
[in]tvKnot positions in \( v \) (length \( n_v \)).
[in]nvTotal number of knots in \( v \).
[in]cB-spline coefficients, length \( (n_u{-}4)(n_v{-}4) \).
[in]radBoundary function \( r(v) \) defining the polar domain.
[in]xCartesian \( x \)-coordinate.
[in]yCartesian \( y \)-coordinate.
Returns
The value \( f(x,y) = s(u,v) \).
See also
Dierckx, Ch. 11, §11.1; polarpolar spline fitting
Here is the call graph for this function:

◆ fitpack_argsort()

pure integer(fp_size) function, dimension(size(list)), public fitpack_core::fitpack_argsort ( real(fp_real), dimension(:), intent(in) list)

Return the permutation indices that would sort an array.

Returns an index array ilist such that list(ilist) is in ascending order.

Parameters
[in]listArray of values to sort.
Returns
Index permutation (length size(list)).
Here is the call graph for this function:

◆ fitpack_error_handling()

subroutine, public fitpack_core::fitpack_error_handling ( integer(fp_flag), intent(in) ierr,
integer(fp_flag), intent(out), optional ierr_out,
character(*), intent(in) whereat )

Dispatch an error code: return it to caller or halt with a message.

If ierr_out is present, the error code is returned through it. Otherwise, if ierr indicates failure, the program halts with a diagnostic message.

Parameters
[in]ierrError flag from a FITPACK routine.
[out]ierr_outOptional output flag; if present, receives ierr instead of halting.
[in]whereAtLocation string for the diagnostic message.
Here is the call graph for this function:

◆ fitpack_message()

pure character(len=:) function, allocatable, public fitpack_core::fitpack_message ( integer(fp_flag), intent(in) ierr)

Convert an integer error flag to a human-readable message string.

Parameters
[in]ierrFITPACK error flag (e.g., FITPACK_OK, FITPACK_INPUT_ERROR).
Returns
Allocatable character string describing the error.

◆ fitpack_quicksort()

pure recursive subroutine fitpack_core::fitpack_quicksort ( real(fp_real), dimension(:), intent(inout) list,
integer(fp_size), dimension(size(list)), intent(inout), optional ilist,
logical(fp_bool), intent(in), optional down )
private

In-place quicksort with optional index tracking.

Sorts list in ascending order (or descending if down=.true.). If ilist is present, its elements are permuted in parallel to track the original positions.

Parameters
[in,out]listArray to sort.
[in,out]ilistOptional index array, permuted alongside list.
[in]downOptional flag for descending order.
Here is the call graph for this function:

◆ fitpack_success()

elemental logical(fp_bool) function, public fitpack_core::fitpack_success ( integer(fp_flag), intent(in) ierr)

Test whether a FITPACK error flag indicates success.

Returns .true. if ierr <= 0 (i.e., FITPACK_OK or any negative success variant).

Parameters
[in]ierrError flag from a FITPACK routine.
Returns
.true. on success, .false. on error.
Here is the call graph for this function:

◆ fourco()

pure subroutine, public fitpack_core::fourco ( real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(n), intent(in) c,
real(fp_real), dimension(m), intent(in) alfa,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(out) ress,
real(fp_real), dimension(m), intent(out) resc,
real(fp_real), dimension(n), intent(inout) wrk1,
real(fp_real), dimension(n), intent(inout) wrk2,
integer(fp_flag), intent(out) ier )

Compute Fourier coefficients of a cubic spline.

For a cubic spline \( s(x) \) and a set of parameters \( \alpha_i \), \( i = 1,\ldots,m \), computes the Fourier integrals:

\[ R_s(i) = \int s(x) \sin(\alpha_i x)\,dx, \qquad R_c(i) = \int s(x) \cos(\alpha_i x)\,dx \]

over the support of the spline.

Parameters
[in]tKnot positions (length \( n \)). Must have \( n \ge 10 \).
[in]nTotal number of knots.
[in]cB-spline coefficients (length \( n \)).
[in]alfaFourier parameters \( \alpha_i \) (length \( m \)).
[in]mNumber of integrals to compute.
[out]ressSine integrals \( R_s(i) \) (length \( m \)).
[out]rescCosine integrals \( R_c(i) \) (length \( m \)).
[in,out]wrk1Real workspace (length \( n \)).
[in,out]wrk2Real workspace (length \( n \)).
[out]ierError flag: 0 = normal return; 10 = invalid input.
See also
Dierckx, Ch. 3, §3.3; fpbfou — B-spline Fourier integrals; fpcsin — cos/sin integrals
Here is the call graph for this function:

◆ fp_bool_comm_expand_1d()

pure subroutine fitpack_core::fp_bool_comm_expand_1d ( logical(fp_bool), dimension(:), intent(out), allocatable array,
real(fp_comm), dimension(:), intent(in) buffer )
private

Expand communication buffer into 1D logical(FP_BOOL) allocatable array.

◆ fp_bool_comm_pack_1d()

pure subroutine fitpack_core::fp_bool_comm_pack_1d ( logical(fp_bool), dimension(:), intent(in), allocatable array,
real(fp_comm), dimension(:), intent(out) buffer )
private

Pack 1D logical(FP_BOOL) allocatable array into communication buffer.

◆ fp_bool_comm_size_1d()

pure integer(fp_size) function fitpack_core::fp_bool_comm_size_1d ( logical(fp_bool), dimension(:), intent(in), allocatable array)
private

Calculate storage size for 1D logical(FP_BOOL) allocatable array.

◆ fp_knot_interval()

pure integer(fp_size) function fitpack_core::fp_knot_interval ( real(fp_real), dimension(:), intent(in) t,
real(fp_real), intent(in) x,
integer(fp_size), intent(in) l_start,
integer(fp_size), intent(in) l_max )
private

Find knot interval index l such that t(l) <= x < t(l+1). Uses hybrid search: linear for small ranges, binary for large. This replaces the repeated pattern: do while (x >= t(l+1) .and. l /= l_max) l = l + 1 end do.

Find the knot interval containing a given value.

Returns the index \( l \) such that \( t_l \le x < t_{l+1} \), using linear search for small ranges (or warm starts) and binary search otherwise.

Parameters
[in]tKnot array (non-decreasing).
[in]xValue to locate.
[in]l_startLeft bound for the search.
[in]l_maxRight bound for the search.
Returns
Index of the interval containing x.

◆ fp_rcomms_per_bits()

elemental integer(fp_size) function, public fitpack_core::fp_rcomms_per_bits ( integer(fp_size), intent(in) nbits)

Number of FP_COMM elements required to store nbits of data.

Here is the call graph for this function:

◆ fp_real_comm_expand_1d()

pure subroutine fitpack_core::fp_real_comm_expand_1d ( real(fp_real), dimension(:), intent(out), allocatable array,
real(fp_comm), dimension(:), intent(in) buffer )
private

Expand communication buffer into 1D real(FP_REAL) allocatable array.

◆ fp_real_comm_expand_2d()

pure subroutine fitpack_core::fp_real_comm_expand_2d ( real(fp_real), dimension(:,:), intent(out), allocatable array,
real(fp_comm), dimension(:), intent(in) buffer )
private

Expand communication buffer into 2D real(FP_REAL) allocatable array.

◆ fp_real_comm_expand_3d()

pure subroutine fitpack_core::fp_real_comm_expand_3d ( real(fp_real), dimension(:,:,:), intent(out), allocatable array,
real(fp_comm), dimension(:), intent(in) buffer )
private

Expand communication buffer into 3D real(FP_REAL) allocatable array.

◆ fp_real_comm_pack_1d()

pure subroutine fitpack_core::fp_real_comm_pack_1d ( real(fp_real), dimension(:), intent(in), allocatable array,
real(fp_comm), dimension(:), intent(out) buffer )
private

Pack 1D real(FP_REAL) allocatable array into communication buffer.

◆ fp_real_comm_pack_2d()

pure subroutine fitpack_core::fp_real_comm_pack_2d ( real(fp_real), dimension(:,:), intent(in), allocatable array,
real(fp_comm), dimension(:), intent(out) buffer )
private

Pack 2D real(FP_REAL) allocatable array into communication buffer.

◆ fp_real_comm_pack_3d()

pure subroutine fitpack_core::fp_real_comm_pack_3d ( real(fp_real), dimension(:,:,:), intent(in), allocatable array,
real(fp_comm), dimension(:), intent(out) buffer )
private

Pack 3D real(FP_REAL) allocatable array into communication buffer.

◆ fp_real_comm_size_1d()

pure integer(fp_size) function fitpack_core::fp_real_comm_size_1d ( real(fp_real), dimension(:), intent(in), allocatable array)
private

Calculate storage size for 1D real(FP_REAL) allocatable array Header: 1 FP_COMM storing bounds as 2 int32 (or NOT_ALLOC marker) Data: raw transfer of array contents.

◆ fp_real_comm_size_2d()

pure integer(fp_size) function fitpack_core::fp_real_comm_size_2d ( real(fp_real), dimension(:,:), intent(in), allocatable array)
private

Calculate storage size for 2D real(FP_REAL) allocatable array.

◆ fp_real_comm_size_3d()

pure integer(fp_size) function fitpack_core::fp_real_comm_size_3d ( real(fp_real), dimension(:,:,:), intent(in), allocatable array)
private

Calculate storage size for 3D real(FP_REAL) allocatable array.

◆ fp_rotate_2mat_stride()

pure subroutine fitpack_core::fp_rotate_2mat_stride ( real(fp_real), dimension(band1), intent(inout) h1,
integer(fp_size), intent(in) band1,
real(fp_real), dimension(band2), intent(inout) h2,
integer(fp_size), intent(in) band2,
real(fp_real), dimension(na,*), intent(inout) a1,
real(fp_real), dimension(na,*), intent(inout) a2,
integer(fp_size), intent(in) na,
real(fp_real), dimension(nrhs), intent(inout) right,
real(fp_real), dimension(ldc,*), intent(inout) c,
integer(fp_size), intent(in) ldc,
integer(fp_size), intent(in) nrhs,
integer(fp_size), intent(in) j1_start,
integer(fp_size), intent(in) j1_end )
private

Rotate a split row into the block-triangular periodic system with stride RHS.

Combines the two-matrix periodic decomposition (Eq. 6.13) with the stride (row-access) RHS pattern needed for grid-based surface fitting. Rotates the split row \( [h_1 \mid h_2] \) into \( [R_{11}^* \mid R_{12}^* 0 \mid R_{22}^*] \)

Here is the call graph for this function:

◆ fp_rotate_row()

pure subroutine fitpack_core::fp_rotate_row ( real(fp_real), dimension(:), intent(inout) h,
integer(fp_size), intent(in) band,
real(fp_real), dimension(:,:), intent(inout) a,
real(fp_real), intent(inout) yi,
real(fp_real), dimension(:), intent(inout) z,
integer(fp_size), intent(in) j_start )
private

Rotate an observation row into the upper triangular band matrix.

Incorporates a new observation row \( h \) (containing the \( k+1 \) non-zero B-spline values) into the upper triangular band matrix \( R \) using a sequence of Givens plane rotations (Eq. 4.15). Each rotation eliminates one element of \( h \) while updating the corresponding diagonal and upper elements of \( R \), plus the scalar right-hand side:

\[ \begin{pmatrix} c & s \\ -s & c \end{pmatrix} \begin{pmatrix} r_{j,j} \\ h_i \end{pmatrix} = \begin{pmatrix} r'_{j,j} \\ 0 \end{pmatrix} \tag{4.15} \]

This is the standard-walk variant: \( h(i) \) pivots for \( i = 1, \ldots, \texttt{band} \), targeting rows \( j = \texttt{j\_start}+1, \ldots, \texttt{j\_start}+\texttt{band} \) of \( R \). Zero pivots are skipped.

Parameters
[in,out]hRow to rotate, length band. Modified in place.
[in]bandNumber of elements in the row (typically \( k+1 \))
[in,out]aUpper triangular band matrix \( R \). a(j,1) is the diagonal; a(j,2:) stores the upper bandwidth.
[in,out]yiScalar RHS contribution; updated by each rotation
[in,out]zRHS vector; positions j_start+1 : j_start+band updated
[in]j_startStarting row index minus one (loop begins at j_start+1)
See also
Dierckx, Ch. 4, §4.1.2 (pp. 55-58), Eq. 4.15
fp_rotate_row_vec — vector-RHS variant for parametric fitting
Here is the call graph for this function:

◆ fp_rotate_row_2mat()

pure subroutine fitpack_core::fp_rotate_row_2mat ( real(fp_real), dimension(band1), intent(inout) h1,
integer(fp_size), intent(in) band1,
real(fp_real), dimension(band2), intent(inout) h2,
integer(fp_size), intent(in) band2,
real(fp_real), dimension(nest,*), intent(inout) a1,
real(fp_real), dimension(nest,*), intent(inout) a2,
integer(fp_size), intent(in) nest,
real(fp_real), intent(inout) yi,
real(fp_real), dimension(*), intent(inout) z,
integer(fp_size), intent(in) j1_start,
integer(fp_size), intent(in) j1_end )
private

Rotate a split observation row into the block-triangular periodic system with scalar RHS.

Scalar-RHS variant of fp_rotate_row_2mat_vec. Identical two-phase algorithm for the periodic block-triangular system (Eq. 6.13) but with a scalar right-hand side \( y_i / z(j) \) instead of the vector \( \xi(d) / z(j, 1{:}d) \).

Parameters
[in,out]h1First block of the observation row, length band1. Shifted left during Phase 1.
[in]band1Length of h1
[in,out]h2Second block (wraparound columns), length band2
[in]band2Length of h2
[in,out]a1Band matrix \( R_{11}^* \), dimension (nest,*)
[in,out]a2Band matrix \( R_{12}^* / R_{22}^* \), dimension (nest,*)
[in]nestLeading dimension of a1 and a2
[in,out]yiScalar RHS contribution; updated by rotations
[in,out]zRHS vector; entries at rows j1_start : j1_end+band2 updated
[in]j1_startFirst row index for Phase 1
[in]j1_endLast row index for Phase 1
See also
Dierckx, Ch. 6, §6.1.1 (pp. 95-100), Eq. 6.10, 6.13
fp_rotate_row_2mat_vec — vector-RHS variant
Here is the call graph for this function:

◆ fp_rotate_row_2mat_vec()

pure subroutine fitpack_core::fp_rotate_row_2mat_vec ( real(fp_real), dimension(band1), intent(inout) h1,
integer(fp_size), intent(in) band1,
real(fp_real), dimension(band2), intent(inout) h2,
integer(fp_size), intent(in) band2,
real(fp_real), dimension(nest,*), intent(inout) a1,
real(fp_real), dimension(nest,*), intent(inout) a2,
integer(fp_size), intent(in) nest,
real(fp_real), dimension(idim), intent(inout) xi,
real(fp_real), dimension(n,idim), intent(inout) z,
integer(fp_size), intent(in) j1_start,
integer(fp_size), intent(in) j1_end,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) idim )
private

Rotate a split observation row into the block-triangular periodic system with vector RHS.

Two-matrix Givens rotation for periodic spline fitting. The periodic B-spline constraint wraps the last \( k \) columns of the observation matrix into the first \( k \), producing a block-triangular structure:

\[ \begin{pmatrix} R_{11}^* & R_{12}^* \\ 0 & R_{22}^* \end{pmatrix} \tag{6.13} \]

Each observation row is split as \( [h_1 \mid h_2] \) and rotated in two phases:

  • Phase 1: Rotate \( h_1 \) through \( R_{11}^* \) using shifted pivots (always \( h_1(1) \)), simultaneously applying cross-rotations to \( h_2 \) and \( R_{12}^* \).
  • Phase 2: Rotate remaining \( h_2 \) through \( R_{22}^* \) using standard walk (diagonal at \( R_{22}^*(j,j) \)).
Parameters
[in,out]h1First block of the observation row, length band1. Shifted left during Phase 1.
[in]band1Length of h1 (main bandwidth)
[in,out]h2Second block (wraparound columns), length band2
[in]band2Length of h2 (typically \( k \))
[in,out]a1Band matrix \( R_{11}^* \), dimension (nest,*)
[in,out]a2Band matrix \( R_{12}^* / R_{22}^* \), dimension (nest,*)
[in]nestLeading dimension of a1 and a2
[in,out]xiVector RHS contribution of length idim
[in,out]zRHS array (n, idim), one column per coordinate dimension
[in]j1_startFirst row index for Phase 1
[in]j1_endLast row index for Phase 1
[in]nLeading dimension of z
[in]idimNumber of coordinate dimensions
See also
Dierckx, Ch. 6, §6.1.1 (pp. 95-100), Eq. 6.10, 6.13, Fig. 6.1
fp_rotate_row_2mat — scalar-RHS variant
Here is the call graph for this function:

◆ fp_rotate_row_block()

pure subroutine fitpack_core::fp_rotate_row_block ( real(fp_real), dimension(band), intent(inout) h,
integer(fp_size), intent(in) band,
real(fp_real), dimension(na,*), intent(inout) a,
integer(fp_size), intent(in) na,
real(fp_real), dimension(nrhs), intent(inout) right,
real(fp_real), dimension(nrhs,*), intent(inout) q,
integer(fp_size), intent(in) nrhs,
integer(fp_size), intent(in) irot_start )
private

Rotate a row into a band matrix with contiguous-block RHS.

Standard-walk Givens rotation for grid-based surface fitting. Rotates row \( h \) into the upper triangular band matrix \( A \), applying the same rotations to a block right-hand side: the vector right(1:nrhs) and the column q(1:nrhs, irot) of a 2D RHS matrix.

This arises from the Kronecker product decomposition of the bivariate system (Eq. 10.4-10.8), where the one-dimensional triangularizations \( A_x \) and \( A_{uu} \) operate on contiguous blocks of the tensor-product RHS.

Parameters
[in,out]hRow to rotate, length band. Modified in place.
[in]bandBandwidth
[in,out]aUpper triangular band matrix, dimension (na,*)
[in]naLeading dimension of a
[in,out]rightBlock RHS vector of length nrhs; updated by rotations
[in,out]q2D RHS matrix (nrhs,*); column irot updated
[in]nrhsNumber of RHS entries per rotation
[in]irot_startStarting row index minus one
See also
Dierckx, Ch. 10, §10.2 (pp. 170-172), Eq. 10.4-10.8
fp_rotate_row_stride — stride (row-access) RHS variant
Here is the call graph for this function:

◆ fp_rotate_row_stride()

pure subroutine fitpack_core::fp_rotate_row_stride ( real(fp_real), dimension(band), intent(inout) h,
integer(fp_size), intent(in) band,
real(fp_real), dimension(na,*), intent(inout) a,
integer(fp_size), intent(in) na,
real(fp_real), dimension(nrhs), intent(inout) right,
real(fp_real), dimension(ldc,*), intent(inout) c,
integer(fp_size), intent(in) ldc,
integer(fp_size), intent(in) nrhs,
integer(fp_size), intent(in) irot_start )
private

Rotate a row into a band matrix with stride (row-access) RHS.

Standard-walk Givens rotation for grid-based surface fitting. Rotates row \( h \) into the upper triangular band matrix \( A \), applying the same rotations to the vector right(1:nrhs) and the row c(irot, 1:nrhs) of a 2D RHS matrix c(ldc,*).

Unlike fp_rotate_row_block (which accesses RHS by columns), this routine accesses RHS by rows — the stride pattern needed for the \( A_y \) and \( A_{vv} \) triangularizations and the tensor-product back-substitution (Eq. 10.8) in the Kronecker product decomposition.

Parameters
[in,out]hRow to rotate, length band. Modified in place.
[in]bandBandwidth
[in,out]aUpper triangular band matrix, dimension (na,*)
[in]naLeading dimension of a
[in,out]rightBlock RHS vector of length nrhs; updated by rotations
[in,out]c2D RHS matrix (ldc,*); row irot updated
[in]ldcLeading dimension of c
[in]nrhsNumber of RHS entries per rotation
[in]irot_startStarting row index minus one
See also
Dierckx, Ch. 10, §10.2 (pp. 170-172), Eq. 10.4-10.8
fp_rotate_row_block — contiguous-block (column-access) RHS variant
Here is the call graph for this function:

◆ fp_rotate_row_vec()

pure subroutine fitpack_core::fp_rotate_row_vec ( real(fp_real), dimension(band), intent(inout) h,
integer(fp_size), intent(in) band,
real(fp_real), dimension(nest,*), intent(inout) a,
integer(fp_size), intent(in) nest,
real(fp_real), dimension(idim), intent(inout) xi,
real(fp_real), dimension(n,idim), intent(inout) z,
integer(fp_size), intent(in) j_start,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) idim )
private

Rotate an observation row into a band matrix with vector RHS.

Vector-RHS variant of fp_rotate_row for parametric curve fitting. Rotates a new observation row \( h \) into the upper triangular band matrix \( R \) using Givens rotations (Eq. 4.15), simultaneously transforming \( d \) right-hand side vectors stored column-wise in \( z(n, d) \).

In parametric fitting, all \( d \) coordinate curves share the same knot vector and B-spline basis, so a single triangularization of \( R \) applies the same rotations to each RHS column.

Parameters
[in,out]hRow to rotate, length band. Modified in place.
[in]bandBandwidth (typically \( k+1 \))
[in,out]aUpper triangular band matrix \( R \), dimension (nest,*)
[in]nestLeading dimension of a
[in,out]xiVector RHS contribution of length idim; updated by rotations
[in,out]zRHS array (n, idim), one column per coordinate dimension
[in]j_startStarting row index minus one
[in]nLeading dimension of z (number of coefficients)
[in]idimNumber of coordinate dimensions
See also
Dierckx, Ch. 4, §4.1.2 (pp. 55-58), Eq. 4.15
fp_rotate_row — scalar-RHS variant
Here is the call graph for this function:

◆ fp_rotate_shifted()

pure subroutine fitpack_core::fp_rotate_shifted ( real(fp_real), dimension(band), intent(inout) h,
integer(fp_size), intent(in) band,
real(fp_real), dimension(nest,*), intent(inout) a,
integer(fp_size), intent(in) nest,
real(fp_real), intent(inout) yi,
real(fp_real), dimension(*), intent(inout) z,
integer(fp_size), intent(in) j_start,
integer(fp_size), intent(in) j_end )
private

Rotate a smoothing-matrix row into a band matrix using shifted pivots.

Shifted-pivot variant of the Givens rotation for incorporating rows of the smoothing matrix \( P \) into the triangularized observation matrix. Unlike fp_rotate_row (which walks \( h(i) \) for \( i = 1, \ldots, b \)), this routine always pivots on \( h(1) \) and shifts \( h \) left after each rotation step:

\[ h \leftarrow (h_2, h_3, \ldots, h_b, 0) \]

The effective bandwidth shrinks as \( j \to \texttt{j\_end} \). This pattern arises because the smoothing matrix \( P \) (Eq. 5.5) has bandwidth \( k+2 \) and its rows are offset relative to \( R \).

Parameters
[in,out]hRow to rotate, length band. Shifted left at each step.
[in]bandBandwidth (typically \( k+2 \))
[in,out]aUpper triangular band matrix \( R^* \), dimension (nest,*)
[in]nestLeading dimension of a
[in,out]yiScalar RHS contribution; updated by rotations
[in,out]zRHS vector; positions j_start : j_end updated
[in]j_startFirst row index in \( R^* \)
[in]j_endLast row index in \( R^* \)
See also
Dierckx, Ch. 5, §5.2.2 (pp. 76-79), Eq. 5.5, 5.14-5.16
fp_rotate_shifted_vec — vector-RHS variant for parametric fitting
Here is the call graph for this function:

◆ fp_rotate_shifted_vec()

pure subroutine fitpack_core::fp_rotate_shifted_vec ( real(fp_real), dimension(band), intent(inout) h,
integer(fp_size), intent(in) band,
real(fp_real), dimension(nest,*), intent(inout) a,
integer(fp_size), intent(in) nest,
real(fp_real), dimension(idim), intent(inout) xi,
real(fp_real), dimension(n,idim), intent(inout) z,
integer(fp_size), intent(in) j_start,
integer(fp_size), intent(in) j_end,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) idim )
private

Rotate a smoothing-matrix row into a band matrix with vector RHS.

Shifted-pivot, vector-RHS variant of the Givens rotation. Combines the shifted-pivot pattern of fp_rotate_shifted (always pivot on \( h(1) \), shift left) with the multi-dimensional RHS of fp_rotate_row_vec. Used by smoothing iterations in parametric fitting (fpcons, fppara) where the smoothing-matrix rows \( P \) (Eq. 5.5, bandwidth \( k+2 \)) are rotated into the already-triangularized observation matrix \( R \), with \( d \) coordinate curves sharing the same knot vector.

Parameters
[in,out]hRow to rotate, length band. Shifted left at each step.
[in]bandBandwidth (typically \( k+2 \))
[in,out]aUpper triangular band matrix \( R^* \), dimension (nest,*)
[in]nestLeading dimension of a
[in,out]xiVector RHS contribution of length idim
[in,out]zRHS array (n, idim), one column per coordinate dimension
[in]j_startFirst row index in \( R^* \)
[in]j_endLast row index in \( R^* \)
[in]nLeading dimension of z
[in]idimNumber of coordinate dimensions
See also
Dierckx, Ch. 5, §5.2.2 (pp. 76-79), Eq. 5.5, 5.14-5.16
fp_rotate_shifted — scalar-RHS variant
Here is the call graph for this function:

◆ fp_size_comm_expand_1d()

pure subroutine fitpack_core::fp_size_comm_expand_1d ( integer(fp_size), dimension(:), intent(out), allocatable array,
real(fp_comm), dimension(:), intent(in) buffer )
private

Expand communication buffer into 1D integer(FP_SIZE) allocatable array.

◆ fp_size_comm_pack_1d()

pure subroutine fitpack_core::fp_size_comm_pack_1d ( integer(fp_size), dimension(:), intent(in), allocatable array,
real(fp_comm), dimension(:), intent(out) buffer )
private

Pack 1D integer(FP_SIZE) allocatable array into communication buffer.

◆ fp_size_comm_size_1d()

pure integer(fp_size) function fitpack_core::fp_size_comm_size_1d ( integer(fp_size), dimension(:), intent(in), allocatable array)
private

Calculate storage size for 1D integer(FP_SIZE) allocatable array.

◆ fpader()

pure subroutine fitpack_core::fpader ( real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(n), intent(in) c,
integer(fp_size), intent(in) k1,
real(fp_real), intent(in) x,
integer(fp_size), intent(in) l,
real(fp_real), dimension(k1), intent(out) d )
private

Evaluate all derivatives of a spline at a single point.

Computes all \( k+1 \) derivatives of a spline of order \( k_1 = k+1 \) at a point \( x \) in the knot interval \( [\lambda_l, \lambda_{l+1}) \):

\[ d(j) = s^{(j-1)}(x), \quad j = 1, \ldots, k_1 \]

Uses the stable recurrence scheme of de Boor, which first forms divided differences of the B-spline coefficients, then evaluates each derivative level by the standard B-spline recursion.

Parameters
[in]tKnot vector \( \lambda_1, \ldots, \lambda_n \)
[in]nLength of the knot vector
[in]cB-spline coefficients, length \( n \)
[in]k1Spline order \( k+1 \) (= degree + 1)
[in]xEvaluation point, \( \lambda_l \leq x < \lambda_{l+1} \)
[in]lKnot interval index
[out]dArray of derivatives: d(j) = \( s^{(j-1)}(x) \), \( j = 1, \ldots, k_1 \)
See also
Dierckx, Ch. 1, §1.4 (pp. 11-14): de Boor recurrence for derivatives
de Boor, C. (1978). A Practical Guide to Splines. Springer.

◆ fpadno()

pure subroutine fitpack_core::fpadno ( integer(fp_size), intent(in) maxtr,
integer(fp_size), dimension(maxtr), intent(inout) up,
integer(fp_size), dimension(maxtr), intent(inout) left,
integer(fp_size), dimension(maxtr), intent(inout) right,
integer(fp_size), dimension(maxtr), intent(inout) info,
integer(fp_size), intent(inout) count,
integer(fp_size), intent(inout) merk,
integer(fp_size), dimension(n1), intent(in) jbind,
integer(fp_size), intent(in) n1,
integer(fp_flag), intent(out) ier )
private

Add a branch to the constraint-set binary tree.

Adds a new branch of length n1 to the triply linked binary tree used by the Theil-Van de Panne convexity procedure (§7.2). The branch represents a candidate active-constraint set; its nodes contain constraint indices from jbind(1:n1).

The tree maintains the ordering invariant \( \text{info}(k) < \text{info}(\text{right}(k)) \) and \( \text{info}(k) < \text{info}(\text{left}(k)) \), preventing duplicate constraint sets. If no free nodes are available, fpfrno is called to reclaim nodes; if that also fails, ier = 1.

Parameters
[in]maxtrSize of the tree arrays
[in,out]upParent pointers; up(i) = 0 marks a free node
[in,out]leftLeft-child pointers
[in,out]rightRight-child pointers
[in,out]infoConstraint index stored at each node
[in,out]countNext free node pointer
[in,out]merkTerminal node of the most recent branch
[in]jbindConstraint indices for the new branch, length n1
[in]n1Length of the new branch
[out]ierError flag: 0 = success, 1 = tree full
See also
Dierckx, Ch. 7, §7.2.4 (pp. 125-130)
fpdeno, fpfrno, fpseno — companion tree operations
Here is the call graph for this function:

◆ fpadpo()

pure subroutine fitpack_core::fpadpo ( integer(fp_size), intent(in) idim,
real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(nc), intent(out) c,
integer(fp_size), intent(in) nc,
integer(fp_size), intent(in) k,
real(fp_real), dimension(np), intent(in) cp,
integer(fp_size), intent(in) np,
real(fp_real), dimension(nc), intent(out) cc,
real(fp_real), dimension(n), intent(out) t1,
real(fp_real), dimension(n), intent(out) t2 )
private

Add a polynomial curve to a spline curve in B-spline representation.

Given a \( d \)-dimensional spline curve of degree \( k \) with knots \( t \) and coefficients \( c \), and a polynomial curve with B-spline coefficients \( c_p \) (on the knot vector \( [a, \ldots, a, b, \ldots, b] \)), computes the B-spline coefficients of their sum by inserting knots from \( t \) into the polynomial representation via fpinst, then adding coefficients.

Parameters
[in]idimNumber of curve dimensions \( d \)
[in]tKnot vector of the spline, length n
[in]nNumber of knots
[in,out]cB-spline coefficients; on exit, contains the sum
[in]ncLength of c
[in]kSpline degree
[in]cpPolynomial B-spline coefficients, length np
[in]npLength of cp
[in,out]ccWork array, length nest
[in,out]t1Work array, length nest
[in,out]t2Work array, length nest
See also
Dierckx, Ch. 7, §7.1 (pp. 115-120)
fpinst — single knot insertion; fppocu — polynomial construction
Here is the call graph for this function:

◆ fpback()

pure real(fp_real) function, dimension(n) fitpack_core::fpback ( real(fp_real), dimension(nest,k), intent(in) a,
real(fp_real), dimension(n), intent(in) z,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) k,
integer(fp_size), intent(in) nest )
private

Solve an upper triangular banded system by back-substitution.

Computes the B-spline coefficients \( c \) by solving the triangular system:

\[ R_1 \, c = z_1 \tag{4.14} \]

where \( R_1 \) is an \( n \times n \) upper triangular matrix with bandwidth \( k \), obtained from the QR factorization of the observation matrix \( E \).

Matrix structure

\( R_1 \) is stored as a(nest, k) where a(i,1) holds the diagonal element \( r_{i,i} \) and a(i,j) for \( j > 1 \) holds \( r_{i,i+j-1} \).

Parameters
[in]aUpper triangular band matrix \( R_1 \), stored as a(nest, k)
[in]zRight-hand side vector \( z_1 \) of length \( n \)
[in]nNumber of equations (= number of B-spline coefficients)
[in]kBandwidth of \( R_1 \) (= spline order \( k+1 \))
[in]nestLeading dimension of array a
Returns
Solution vector \( c \) of length \( n \)
See also
Dierckx, Ch. 4, §4.1.2 (pp. 55-58), Eq. 4.14

◆ fpbacp()

pure real(fp_real) function, dimension(n) fitpack_core::fpbacp ( real(fp_real), dimension(nest,k1), intent(in) a,
real(fp_real), dimension(nest,k), intent(in) b,
real(fp_real), dimension(n), intent(in) z,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) k,
integer(fp_size), intent(in) k1,
integer(fp_size), intent(in) nest )
private

Solve a bordered upper triangular system by back-substitution.

Computes the solution \( c \) of the system \( G \, c = z \) where \( G \) is an \( n \times n \) upper triangular matrix of the form:

\[ G = \begin{pmatrix} A & \cdot \\ 0 & B \end{pmatrix} \tag{6.6} \]

with \( A \) an \( (n-k) \times (n-k) \) upper triangular band matrix of bandwidth \( k_1 \), and \( B \) an \( n \times k \) dense matrix accounting for the periodic boundary conditions.

This arises in periodic spline fitting where the periodic B-splines \( \tilde{N}_{i,k+1} \) wrap around the domain, coupling the first and last \( k \) coefficients.

Parameters
[in]aUpper triangular band matrix \( A \), stored as a(nest, k1)
[in]bDense coupling matrix \( B \), stored as b(nest, k)
[in]zRight-hand side vector of length \( n \)
[in]nNumber of equations
[in]kNumber of periodic coupling columns
[in]k1Bandwidth of the triangular part \( A \)
[in]nestLeading dimension of arrays a and b
Returns
Solution vector \( c \) of length \( n \)
See also
Dierckx, Ch. 6, §6.1 (pp. 95-100), Eq. 6.6

◆ fpbfou()

pure subroutine fitpack_core::fpbfou ( real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), intent(in) par,
real(fp_real), dimension(n), intent(out) ress,
real(fp_real), dimension(n), intent(out) resc )
private

Compute Fourier coefficients of cubic B-splines.

Calculates the Fourier sine and cosine integrals of each cubic B-spline \( N_{j,4}(x) \) over the active knot interval:

\[ \text{ress}(j) = \int_{\lambda_4}^{\lambda_{n-3}} N_{j,4}(x) \sin(\omega x) \, dx \]

\[ \text{resc}(j) = \int_{\lambda_4}^{\lambda_{n-3}} N_{j,4}(x) \cos(\omega x) \, dx \]

for \( j = 1, \ldots, n-4 \). Uses fpcsin to evaluate the weighted integrals over each knot span.

Parameters
[in]tKnot vector, length n
[in]nNumber of knots
[in]parFrequency \( \omega \)
[out]ressSine integrals, length n-4
[out]rescCosine integrals, length n-4
See also
Dierckx, Ch. 3, §3.3 (Fourier coefficients)
fpcsin — weighted Fourier integrals of cubics
Here is the call graph for this function:

◆ fpbisp()

pure subroutine fitpack_core::fpbisp ( real(fp_real), dimension(nx), intent(in) tx,
integer(fp_size), intent(in) nx,
real(fp_real), dimension(ny), intent(in) ty,
integer(fp_size), intent(in) ny,
real(fp_real), dimension((nx-kx-1)*(ny-ky-1)), intent(in) c,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
real(fp_real), dimension(mx), intent(in) x,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(my), intent(in) y,
integer(fp_size), intent(in) my,
real(fp_real), dimension(mx*my), intent(out) z,
real(fp_real), dimension(mx,kx+1), intent(out) wx,
real(fp_real), dimension(my,ky+1), intent(out) wy,
integer(fp_size), dimension(mx), intent(out) lx,
integer(fp_size), dimension(my), intent(out) ly )
private

Evaluate a tensor product spline on a grid.

Computes the values of a bivariate spline \( s(x, y) \) of degrees \( k_x \) and \( k_y \) at the grid points \( (x_i, y_j) \), \( i = 1, \ldots, m_x \), \( j = 1, \ldots, m_y \).

The evaluation uses the two-step algorithm: first compute the B-spline basis values in each direction, then assemble:

\[ s(x, y) = \sum_{i} \left( \sum_{j} c_{i,j} \, M_{j, k_y+1}(y) \right) N_{i, k_x+1}(x) \tag{2.14-2.15} \]

The B-spline values and knot interval indices are stored in workspace arrays wx, wy, lx, ly for reuse.

Parameters
[in]txKnot vector in \( x \), length nx
[in]nxNumber of knots in \( x \)
[in]tyKnot vector in \( y \), length ny
[in]nyNumber of knots in \( y \)
[in]cB-spline coefficients \( c_{i,j} \), length \( (n_x - k_x - 1)(n_y - k_y - 1) \)
[in]kxSpline degree in \( x \)
[in]kySpline degree in \( y \)
[in]xEvaluation points in \( x \), length mx
[in]mxNumber of evaluation points in \( x \)
[in]yEvaluation points in \( y \), length my
[in]myNumber of evaluation points in \( y \)
[out]zSpline values at grid points, length mx * my, stored in row-major order: \( z((i-1) m_y + j) = s(x_i, y_j) \)
[out]wxB-spline basis values in \( x \), wx(mx, kx+1)
[out]wyB-spline basis values in \( y \), wy(my, ky+1)
[out]lxKnot interval indices in \( x \), length mx
[out]lyKnot interval indices in \( y \), length my
See also
Dierckx, Ch. 2, §2.1.2 (pp. 28-30), Eq. 2.14-2.17
Here is the call graph for this function:

◆ fpbspl()

pure real(fp_real) function, dimension(max_order+1) fitpack_core::fpbspl ( real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) x,
integer(fp_size), intent(in) l )
private

Evaluate the non-zero B-splines at a given point.

Computes the \( k+1 \) non-zero B-splines of degree \( k \) at the point \( x \) satisfying \( \lambda_l \leq x < \lambda_{l+1} \), using the stable recurrence relation of de Boor and Cox:

\[ N_{i,1}(x) = \begin{cases} 1 & \text{if } \lambda_i \leq x < \lambda_{i+1} \\ 0 & \text{otherwise} \end{cases} \]

\[ N_{i,l+1}(x) = \frac{x - \lambda_i}{\lambda_{i+l} - \lambda_i} N_{i,l}(x) + \frac{\lambda_{i+l+1} - x}{\lambda_{i+l+1} - \lambda_{i+1}} N_{i+1,l}(x) \tag{1.24} \]

The result array h contains \( N_{l-k,k+1}(x), \ldots, N_{l,k+1}(x) \) in positions h(1:k+1). When knots have multiplicity (coincident knots), zero weights are used in the recurrence (convention \( 0/0 = 0 \)).

Parameters
[in]tKnot vector \( \lambda_1, \ldots, \lambda_n \)
[in]nLength of the knot vector
[in]kSpline degree
[in]xEvaluation point, must satisfy \( \lambda_l \leq x < \lambda_{l+1} \)
[in]lKnot interval index, must satisfy \( k \leq l \leq n-k \)
Returns
Array of length MAX_ORDER+1; positions 1:k+1 contain the \( k+1 \) non-zero B-spline values.
Note
Requires \( k \leq l \leq n-k \); this is not checked.
See also
Dierckx, Ch. 1, §1.3 (pp. 8-11), Eq. 1.22-1.24, 1.30
Here is the call graph for this function:

◆ fpchec()

pure integer(fp_flag) function fitpack_core::fpchec ( real(fp_real), dimension(m), intent(in) x,
integer(fp_size), intent(in) m,
real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) k )
private

Verify knot positions against data points (Schoenberg-Whitney check).

Checks that the knots \( \lambda_j \), \( j = 1, \ldots, n \), of a spline of degree \( k \) satisfy all conditions required for a well-posed least-squares problem with data points \( x_i \), \( i = 1, \ldots, m \).

The conditions verified are:

  1. \( k+1 \leq n-k-1 \leq m \)
  2. \( \lambda_1 \leq \cdots \leq \lambda_{k+1} \) and \( \lambda_{n-k} \leq \cdots \leq \lambda_n \) (boundary knot monotonicity)
  3. \( \lambda_{k+2} < \lambda_{k+3} < \cdots < \lambda_{n-k} \) (interior knots strictly increasing)
  4. \( \lambda_{k+1} \leq x_1 \) and \( x_m \leq \lambda_{n-k} \)
  5. The Schoenberg-Whitney conditions: there exists a subset of data points \( y_j \) such that

    \[ \lambda_j < y_j < \lambda_{j+k+1}, \quad j = 1, \ldots, n-k-1 \tag{4.5} \]

    guaranteeing full rank of the observation matrix.
Parameters
[in]xData abscissae, strictly increasing: \( x_1 < \cdots < x_m \)
[in]mNumber of data points
[in]tKnot vector \( \lambda_1, \ldots, \lambda_n \)
[in]nNumber of knots
[in]kSpline degree
Returns
FITPACK_OK if all conditions hold, FITPACK_INPUT_ERROR otherwise.
See also
Dierckx, Ch. 4, §4.1.1 (pp. 53-55), Eq. 4.5, 4.17

◆ fpched()

pure integer function fitpack_core::fpched ( real(fp_real), dimension(m), intent(in) x,
integer(fp_size), intent(in) m,
real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) k,
integer(fp_size), intent(in) ib,
integer(fp_size), intent(in) ie )
private

Verify knot positions for a constrained spline (Schoenberg-Whitney check).

Checks that the knots \( \lambda_j \), \( j = 1, \ldots, n \), of a spline of degree \( k \) with \( i_b \) derivative constraints at \( x_1 \) and \( i_e \) constraints at \( x_m \), satisfy all conditions required for a well-posed least-squares problem:

  1. \( k+1 \leq n-k-1 \leq m + \max(0, i_b - 1) + \max(0, i_e - 1) \)
  2. Boundary knot monotonicity
  3. Interior knots strictly increasing
  4. \( \lambda_{k+1} \leq x_1 \) and \( x_m \leq \lambda_{n-k} \)
  5. Schoenberg-Whitney conditions (Eq. 4.5) for the subset of unconstrained equations
Parameters
[in]xData abscissae, strictly increasing
[in]mNumber of data points
[in]tKnot vector \( \lambda_1, \ldots, \lambda_n \)
[in]nNumber of knots
[in]kSpline degree
[in]ibNumber of derivative constraints at \( x_1 \)
[in]ieNumber of derivative constraints at \( x_m \)
Returns
FITPACK_OK if all conditions hold, FITPACK_INPUT_ERROR otherwise.
See also
Dierckx, Ch. 8, §8.2 (pp. 141-146): constrained curve fitting
Dierckx, Ch. 4, §4.1.1 (pp. 53-55), Eq. 4.5

◆ fpchep()

pure integer(fp_flag) function fitpack_core::fpchep ( real(fp_real), dimension(m), intent(in) x,
integer(fp_size), intent(in) m,
real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) k )
private

Verify knot positions for a periodic spline (Schoenberg-Whitney check).

Checks that the knots \( \lambda_j \), \( j = 1, \ldots, n \), of a periodic spline of degree \( k \) satisfy all conditions required for a well-posed least-squares problem with data points \( x_i \):

  1. \( k+1 \leq n-k-1 \leq m+k-1 \)
  2. Boundary knot monotonicity
  3. Interior knots strictly increasing
  4. \( \lambda_{k+1} \leq x_1 \) and \( x_m \leq \lambda_{n-k} \)
  5. Schoenberg-Whitney conditions for the periodic basis: a subset \( y_j \) satisfying \( \lambda_j < y_j < \lambda_{j+k+1} \) must exist, where values may wrap around with period \( T = \lambda_{n-k} - \lambda_{k+1} \)
Parameters
[in]xData abscissae, strictly increasing
[in]mNumber of data points
[in]tKnot vector \( \lambda_1, \ldots, \lambda_n \)
[in]nNumber of knots
[in]kSpline degree
Returns
FITPACK_OK if all conditions hold, FITPACK_INPUT_ERROR otherwise.
See also
Dierckx, Ch. 6, §6.1 (pp. 95-100): periodic spline fitting
Dierckx, Ch. 4, §4.1.1 (pp. 53-55), Eq. 4.5

◆ fpclos()

pure subroutine fitpack_core::fpclos ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) idim,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) u,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(mx), intent(in) x,
real(fp_real), dimension(m), intent(in) w,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nest,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(in) k1,
integer(fp_size), intent(in) k2,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
integer(fp_size), intent(in) nc,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(nest), intent(inout) fpint,
real(fp_real), dimension(nc), intent(inout) z,
real(fp_real), dimension(nest,k1), intent(inout) a1,
real(fp_real), dimension(nest,k), intent(inout) a2,
real(fp_real), dimension(nest,k2), intent(inout) b,
real(fp_real), dimension(nest,k2), intent(inout) g1,
real(fp_real), dimension(nest,k1), intent(inout) g2,
real(fp_real), dimension(m,k1), intent(inout) q,
integer(fp_size), dimension(nest), intent(inout) nrdata,
integer(fp_flag), intent(inout) ier )
private

Core algorithm for closed (periodic) parametric curve fitting.

Fits a \( d \)-dimensional closed parametric spline curve where \( s(u_1) = s(u_m) \) and all derivatives match at the closure point. The periodicity constraint wraps the last \( k \) B-spline columns into the first \( k \), creating the block-triangular structure (Eq. 6.13):

\[ \begin{pmatrix} R_{11}^* & R_{12}^* \\ 0 & R_{22}^* \end{pmatrix} \tag{6.13} \]

which is factored using two-matrix Givens rotations (fp_rotate_row_2mat_vec). The smoothing-parameter search follows the same rational interpolation scheme as fpcurf.

Parameters
[in]iopt0 = new fit, 1 = continue
[in]idimNumber of curve dimensions \( d \)
[in]mNumber of data points
[in]uParameter values, length m
[in]mxLength of x ( \( = m \cdot d \))
[in]xData coordinates, interleaved, length mx
[in]wData weights, length m
[in]kSpline degree
[in]sSmoothing factor \( S \geq 0 \)
[in]nestMax knots
[in]tolTolerance for smoothing condition
[in]maxitMaximum smoothing-parameter iterations
[in]k1\( k + 1 \)
[in]k2\( k + 2 \)
[in,out]nNumber of knots
[in,out]tKnot vector, length nest
[in]ncLength of coefficient array c
[in,out]cB-spline coefficients, length nc
[in,out]fpWeighted sum of squared residuals
[in,out]fpintResidual sums per knot interval
[in,out]zWork: transformed RHS
[in,out]a1Work: band matrix \( R_{11}^* \)
[in,out]a2Work: band matrix \( R_{12}^*/R_{22}^* \)
[in,out]bWork: smoothing matrix
[in,out]g1Work: band matrix copy
[in,out]g2Work: band matrix copy
[in,out]qWork: B-spline values
[in,out]nrdataInterior data-point counts
[in,out]ierError flag
See also
Dierckx, Ch. 6, §6.1-6.2 (pp. 95-112), Eq. 6.1-6.13
fp_rotate_row_2mat_vec — two-matrix Givens rotation
Here is the call graph for this function:

◆ fpclos_reset_interp()

pure subroutine fitpack_core::fpclos_reset_interp ( integer(fp_size), intent(in) idim,
integer(fp_size), intent(in) k,
integer(fp_size), intent(in) m,
integer(fp_size), intent(in) mx,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) nc,
integer(fp_size), intent(in) nest,
integer(fp_size), intent(inout) kk,
integer(fp_size), intent(inout) kk1,
real(fp_real), dimension(m), intent(in) u,
real(fp_real), dimension(mx), intent(in) x,
real(fp_real), dimension(nest), intent(inout) t,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), intent(in) per,
real(fp_real), intent(in) fp0,
real(fp_real), intent(in) s,
real(fp_real), dimension(nest), intent(inout) fpint,
integer(fp_size), dimension(nest), intent(inout) nrdata,
logical(fp_bool), intent(out) done )
private

Set up the initial knot configuration for closed-curve interpolation.

When \( s = 0 \) (interpolation) and \( k \) is odd, places interior knots at the data parameter values. For \( k = 1 \) (linear), directly sets the B-spline coefficients from the data and returns the exact interpolant. When \( k \) is even, knots are placed at midpoints of consecutive parameters.

Parameters
[in]idimNumber of dimensions
[in]kSpline degree
[in]mNumber of data points
[in]mxLength of data array x (= m * idim)
[in]nNumber of knots
[in]ncLength of coefficient array c
[in]nestMaximum knots allowed
[in,out]kkAdjusted degree for iteration
[in,out]kk1Adjusted order for iteration
[in]uParameter values, length m
[in]xData coordinates, length mx
[in,out]tKnot vector, length nest
[in,out]cB-spline coefficients, length nc
[in,out]fpWeighted sum of squared residuals
[in]perPeriod \( = u_m - u_1 \)
[in]fp0Upper bound for the smoothing factor
[in]sSmoothing factor
[in,out]fpintKnot interval contributions, length nest
[in,out]nrdataData point counts per interval, length nest
[out]done.true. if the interpolant was fully determined
See also
Dierckx, Ch. 6, §6.1-6.2 (pp. 95-112): closed periodic spline fitting

◆ fpcoco()

pure subroutine fitpack_core::fpcoco ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(m), intent(in) w,
real(fp_real), dimension(m), intent(in) v,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nest,
integer(fp_size), intent(in) maxtr,
integer(fp_size), intent(in) maxbin,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
real(fp_real), dimension(nest), intent(inout) c,
real(fp_real), intent(inout) sq,
real(fp_real), dimension(m), intent(inout) sx,
logical(fp_bool), dimension(nest), intent(inout) bind,
real(fp_real), dimension(nest), intent(inout) e,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )
private

Fit a convexity-constrained cubic smoothing spline.

Determines a cubic spline approximation \( s(x) \) that satisfies the convexity (or concavity) constraints specified by \( v(i) \):

  • \( v(i) = 1 \): \( s''(x_i) \geq 0 \) (local convexity)
  • \( v(i) = -1 \): \( s''(x_i) \leq 0 \) (local concavity)
  • \( v(i) = 0 \): no constraint at \( x_i \)

while minimizing the weighted sum of squared residuals subject to \( \sum (w_i (y_i - s(x_i)))^2 \leq S \). The algorithm uses the Theil-Van de Panne quadratic programming procedure with a binary tree (§7.2) to enumerate active-constraint sets.

Parameters
[in]ioptOption: -1 = least-squares, 0 = new smoothing, 1 = continue from previous
[in]mNumber of data points
[in]xData abscissae, length m (strictly increasing)
[in]yData ordinates, length m
[in]wData weights, length m (positive)
[in]vConvexity signs, length m
[in]sSmoothing factor \( S \geq 0 \)
[in]nestMax knots (workspace dimension)
[in]maxtrMax tree nodes
[in]maxbinMax active constraints
[in,out]nNumber of knots
[in,out]tKnot vector, length nest
[in,out]cB-spline coefficients, length nest
[in,out]sqWeighted sum of squared residuals
[in,out]sxSpline values at data points, length m
[in,out]bindActive constraint flags, length nest
[in,out]eDiscontinuity coefficients, length nest
[in,out]wrkWork array, length lwrk
[in]lwrkLength of wrk
[in,out]iwrkInteger work array, length kwrk
[in]kwrkLength of iwrk
[out]ierError flag
Note
Error flags in fpcoco/cocosp do not match the global error messages.
See also
Dierckx, Ch. 7, §7.2 (pp. 125-130)
fpcosp — core convexity-constrained fitting algorithm
Here is the call graph for this function:

◆ fpcons()

pure subroutine fitpack_core::fpcons ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) idim,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) u,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(mx), intent(in) x,
real(fp_real), dimension(m), intent(in) w,
integer(fp_size), intent(in) ib,
integer(fp_size), intent(in) ie,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nest,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(in) k1,
integer(fp_size), intent(in) k2,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
integer(fp_size), intent(in) nc,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(nest), intent(inout) fpint,
real(fp_real), dimension(nc), intent(inout) z,
real(fp_real), dimension(nest,k1), intent(inout) a,
real(fp_real), dimension(nest,k2), intent(inout) b,
real(fp_real), dimension(nest,k2), intent(inout) g,
real(fp_real), dimension(m,k1), intent(inout) q,
integer(fp_size), dimension(nest), intent(inout) nrdata,
integer(fp_flag), intent(inout) ier )
private

Core algorithm for constrained parametric curve fitting.

Fits a \( d \)-dimensional parametric spline curve \( s(u) = (s_1(u), \ldots, s_d(u)) \) subject to derivative constraints at the endpoints:

\[ s_j^{(l)}(u_1) = x_j^{(l)}, \quad l = 0, \ldots, i_b - 1 \]

\[ s_j^{(l)}(u_m) = x_j^{(l)}, \quad l = 0, \ldots, i_e - 1 \]

The algorithm first constructs a polynomial satisfying the constraints (via fppocu), then iteratively refines the knot set and solves the constrained least-squares system using Givens rotations.

Parameters
[in]iopt0 = new fit, 1 = continue
[in]idimNumber of curve dimensions \( d \)
[in]mNumber of data points
[in]uParameter values, length m
[in]mxLength of x ( \( = m \cdot d \))
[in]xData coordinates, interleaved, length mx
[in]wData weights, length m
[in]ibNumber of derivative constraints at start
[in]ieNumber of derivative constraints at end
[in]kSpline degree
[in]sSmoothing factor \( S \geq 0 \)
[in]nestMax knots
[in]tolTolerance for smoothing condition
[in]maxitMaximum smoothing-parameter iterations
[in]k1\( k + 1 \)
[in]k2\( k + 2 \)
[in,out]nNumber of knots
[in,out]tKnot vector, length nest
[in]ncLength of coefficient array c
[in,out]cB-spline coefficients, length nc
[in,out]fpWeighted sum of squared residuals
[in,out]fpintResidual sums per knot interval
[in,out]zWork: transformed RHS
[in,out]aWork: band matrix
[in,out]bWork: smoothing matrix
[in,out]gWork: band matrix copy
[in,out]qWork: B-spline values
[in,out]nrdataInterior data-point counts
[in,out]ierError flag
See also
Dierckx, Ch. 8, §8.2 (pp. 141-146)
fppocu — initial polynomial; fp_rotate_shifted_vec — smoothing rotation
Here is the call graph for this function:

◆ fpcosp()

pure subroutine fitpack_core::fpcosp ( integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(m), intent(in) w,
integer(fp_size), intent(in) n,
real(fp_real), dimension(n), intent(in) t,
real(fp_real), dimension(n), intent(in) e,
integer(fp_size), intent(in) maxtr,
integer(fp_size), intent(in) maxbin,
real(fp_real), dimension(n), intent(inout) c,
real(fp_real), intent(out) sq,
real(fp_real), dimension(m), intent(inout) sx,
logical(fp_bool), dimension(n), intent(inout) bind,
integer(fp_size), intent(in) nm,
integer(fp_size), intent(in) mb,
real(fp_real), dimension(n,4), intent(inout) a,
real(fp_real), dimension(nm,maxbin), intent(inout) b,
real(fp_real), dimension(n), intent(inout) const,
real(fp_real), dimension(n), intent(inout) z,
real(fp_real), dimension(n), intent(inout) zz,
real(fp_real), dimension(maxbin), intent(inout) u,
real(fp_real), dimension(m,4), intent(inout) q,
integer(fp_size), dimension(maxtr), intent(inout) info,
integer(fp_size), dimension(maxtr), intent(inout) up,
integer(fp_size), dimension(maxtr), intent(inout) left,
integer(fp_size), dimension(maxtr), intent(inout) right,
integer(fp_size), dimension(mb), intent(inout) jbind,
integer(fp_size), dimension(mb), intent(inout) ibind,
integer(fp_flag), intent(out) ier )
private

Core algorithm for convexity-constrained cubic spline fitting.

Given a fixed knot set, solves the constrained least-squares problem using the Theil-Van de Panne active-set enumeration (§7.2). For each candidate active-constraint set (tracked in a binary tree), solves the equality-constrained system and checks feasibility and optimality via the Lagrange multipliers.

Parameters
[in]mNumber of data points
[in]xData abscissae, length m
[in]yData ordinates, length m
[in]wData weights, length m
[in]nNumber of knots
[in]tKnot vector, length n
[in]eDiscontinuity jump coefficients, length n
[in]maxtrMax tree nodes
[in]maxbinMax active constraints
[in,out]cB-spline coefficients, length n
[out]sqWeighted sum of squared residuals
[in,out]sxSpline values at data points, length m
[in,out]bindActive constraint flags, length n
[in]nmDimension parameter
[in]mbDimension parameter
[in,out]aWork matrix (n, 4)
[in,out]bWork matrix (nm, maxbin)
[in,out]constConstraint vector, length n
[in,out]zWork vector, length n
[in,out]zzWork vector, length n
[in,out]uWork vector, length maxbin
[in,out]qWork matrix (m, 4)
[in,out]infoTree info array, length maxtr
[in,out]upTree parent pointers, length maxtr
[in,out]leftTree left-child pointers, length maxtr
[in,out]rightTree right-child pointers, length maxtr
[in,out]jbindWork array for constraint indices, length mb
[in,out]ibindWork array for constraint indices, length mb
[out]ierError flag
See also
Dierckx, Ch. 7, §7.1-7.2 (pp. 115-130)
fpcoco — driver routine; fpadno, fpdeno, fpseno — tree operations
Here is the call graph for this function:

◆ fpcsin()

pure elemental subroutine fitpack_core::fpcsin ( real(fp_real), intent(in) a,
real(fp_real), intent(in) b,
real(fp_real), intent(in) par,
real(fp_real), intent(in) sia,
real(fp_real), intent(in) coa,
real(fp_real), intent(in) sib,
real(fp_real), intent(in) cob,
real(fp_real), intent(out) ress,
real(fp_real), intent(out) resc )
private

Compute weighted Fourier integrals of a cubic polynomial.

Calculates the integrals:

\[ \text{ress} = \int_a^b (b-x)^3 \sin(\omega x) \, dx, \quad \text{resc} = \int_a^b (b-x)^3 \cos(\omega x) \, dx \]

given precomputed trigonometric values at the endpoints. Used by fpbfou to compute Fourier coefficients of B-splines.

Parameters
[in]aLeft endpoint
[in]bRight endpoint
[in]parFrequency \( \omega \)
[in]sia\( \sin(\omega a) \)
[in]coa\( \cos(\omega a) \)
[in]sib\( \sin(\omega b) \)
[in]cob\( \cos(\omega b) \)
[out]ressSine integral result
[out]rescCosine integral result
See also
Dierckx, Ch. 3, §3.3 (Fourier integrals)
fpbfou — B-spline Fourier coefficient computation

◆ fpcurf()

pure subroutine fitpack_core::fpcurf ( integer(fp_size), intent(in) iopt,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(m), intent(in) w,
integer(fp_size), intent(in) m,
real(fp_real), intent(in) xb,
real(fp_real), intent(in) xe,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nest,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(in) k1,
integer(fp_size), intent(in) k2,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
real(fp_real), dimension(nest), intent(inout) c,
real(fp_real), intent(out) fp,
real(fp_real), dimension(nest), intent(inout) fpint,
real(fp_real), dimension(nest), intent(inout) z,
real(fp_real), dimension(nest,k1), intent(inout) a,
real(fp_real), dimension(nest,k2), intent(inout) b,
real(fp_real), dimension(nest,k2), intent(inout) g,
real(fp_real), dimension(m,k1), intent(inout) q,
integer(fp_size), dimension(nest), intent(inout) nrdata,
integer(fp_flag), intent(out) ier )
private

Core algorithm for univariate spline curve fitting.

Determines a smooth spline approximation \( s(x) \) of degree \( k \) on the interval \( [x_b, x_e] \) that satisfies the smoothing criterion:

\[ F_g(p) = \sum_{i=1}^{m} \bigl( w_i (y_i - s(x_i)) \bigr)^2 \leq S \tag{4.12} \]

The algorithm iterates over three levels:

  1. Knot selection (§5.3): adds knots at locations of maximum residual (Eq. 5.37-5.43) until the smoothing condition can be met.
  2. Weighted least-squares (§4.1): for each knot set, solves the banded system via QR with Givens rotations (Eq. 4.14-4.15).
  3. Smoothing parameter search (§5.2.4): finds \( p \) such that \( F_g(p) = S \) using rational interpolation (Eq. 5.30-5.32).
Parameters
[in]iopt0 = new fit, 1 = continue with more knots
[in]xData abscissae, length m (strictly increasing)
[in]yData ordinates, length m
[in]wData weights, length m (positive)
[in]mNumber of data points
[in]xbLeft boundary of approximation interval
[in]xeRight boundary of approximation interval
[in]kSpline degree ( \( 1 \leq k \leq 5 \))
[in]sSmoothing factor \( S \geq 0 \)
[in]nestMax number of knots (workspace bound)
[in]tolTolerance for the smoothing condition
[in]maxitMaximum iterations for the \( p \)-search
[in]k1\( k + 1 \) (spline order)
[in]k2\( k + 2 \) (smoothing bandwidth)
[in,out]nNumber of knots
[in,out]tKnot vector, length nest
[out]cB-spline coefficients, length nest
[out]fpWeighted sum of squared residuals \( F_g(p) \)
[in,out]fpintResidual sums per knot interval, length nest
[in,out]zWork: transformed RHS, length nest
[in,out]aWork: band matrix, (nest, k1)
[in,out]bWork: smoothing matrix, (nest, k2)
[in,out]gWork: band matrix copy, (nest, k2)
[in,out]qWork: B-spline values, (m, k1)
[in,out]nrdataInterior data-point counts per interval, length nest
[out]ierError flag
See also
Dierckx, Ch. 4, §4.1-4.2 (pp. 53-65); Ch. 5, §5.2-5.3 (pp. 73-94)
Here is the call graph for this function:

◆ fpcuro()

pure subroutine fitpack_core::fpcuro ( real(fp_real), intent(in) a,
real(fp_real), intent(in) b,
real(fp_real), intent(in) c,
real(fp_real), intent(in) d,
real(fp_real), dimension(3), intent(out) x,
integer(fp_size), intent(out) n )
private

Find the real zeros of a cubic polynomial.

Computes all real roots of the cubic polynomial:

\[ p(x) = a x^3 + b x^2 + c x + d \]

Handles the degenerate cases (linear, quadratic) and uses the standard trigonometric method for the irreducible case (three real roots) and Cardano's formula otherwise.

Parameters
[in]aCoefficient of \( x^3 \)
[in]bCoefficient of \( x^2 \)
[in]cCoefficient of \( x \)
[in]dConstant term
[out]xArray of length 3 containing the real zeros
[out]nNumber of real zeros found ( \( 0 \leq n \leq 3 \))

◆ fpcyt1()

pure subroutine fitpack_core::fpcyt1 ( real(fp_real), dimension(nn,6), intent(inout) a,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) nn )
private

LU-decompose a cyclic tridiagonal matrix.

Computes the LU decomposition of an \( n \times n \) cyclic tridiagonal matrix arising from periodic spline fitting. The matrix has the structure:

\[ \begin{pmatrix} a_{1,2} & a_{1,3} & & & & a_{1,1} \\ a_{2,1} & a_{2,2} & a_{2,3} & & & \\ & \ddots & \ddots & \ddots & & \\ & & a_{n-1,1} & a_{n-1,2} & a_{n-1,3} \\ a_{n,3} & & & & a_{n,1} & a_{n,2} \end{pmatrix} \]

The decomposition factors are stored in columns 4-6 of the array a. The back-substitution is performed by fpcyt2.

Parameters
[in,out]aMatrix stored as a(nn,6). Columns 1-3 hold the tridiagonal + cyclic entries; columns 4-6 receive the LU factors.
[in]nMatrix dimension
[in]nnLeading dimension of a
See also
Dierckx, Ch. 6, §6.1 (pp. 95-100), Eq. 6.5-6.6
fpcyt2 — back-substitution using the LU factors

◆ fpcyt2()

pure subroutine fitpack_core::fpcyt2 ( real(fp_real), dimension(nn,6), intent(in) a,
integer(fp_size), intent(in) n,
real(fp_real), dimension(n), intent(in) b,
real(fp_real), dimension(n), intent(out) c,
integer(fp_size), intent(in) nn )
private

Solve a cyclic tridiagonal system using LU factors from fpcyt1.

Solves the \( n \times n \) linear system \( A \, c = b \) where \( A \) is a cyclic tridiagonal matrix whose LU decomposition has been computed by fpcyt1 and stored in columns 4-6 of the array a.

Parameters
[in]aLU-factored matrix from fpcyt1, dimension (nn, 6)
[in]nSystem dimension
[in]bRight-hand side vector, length n
[out]cSolution vector, length n
[in]nnLeading dimension of a
See also
Dierckx, Ch. 6, §6.1 (pp. 95-100), Eq. 6.5-6.6
fpcyt1 — LU decomposition of the cyclic tridiagonal matrix

◆ fpdeno()

pure subroutine fitpack_core::fpdeno ( integer(fp_size), intent(in) maxtr,
integer(fp_size), dimension(maxtr), intent(inout) up,
integer(fp_size), dimension(maxtr), intent(inout) left,
integer(fp_size), dimension(maxtr), intent(inout) right,
integer(fp_size), intent(in) nbind,
integer(fp_size), intent(out) merk )
private

Prune short branches from the constraint-set binary tree.

Frees all branches whose length is less than nbind by setting their up field to zero. This reclaims memory in the triply linked tree used by the Theil-Van de Panne procedure (§7.2), keeping only branches at the current search frontier.

On exit, merk points to the terminal node of the leftmost branch of length nbind, or is set to 1 if no such branch exists.

Parameters
[in]maxtrSize of the tree arrays
[in,out]upParent pointers; freed nodes get up = 0
[in]leftLeft-child pointers
[in]rightRight-child pointers
[in]nbindMinimum branch length to retain
[out]merkTerminal node of the leftmost surviving branch, or 1 if none
See also
Dierckx, Ch. 7, §7.2.4 (pp. 125-130)
fpadno, fpfrno, fpseno — companion tree operations

◆ fpdisc()

pure subroutine fitpack_core::fpdisc ( real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) k2,
real(fp_real), dimension(nest,k2), intent(inout) b,
integer(fp_size), intent(in) nest )
private

Compute the discontinuity jumps of the B-spline derivatives.

Calculates the discontinuity jumps of the \( k \)-th derivative of the B-splines of degree \( k \) at the interior knots \( \lambda_{k+2}, \ldots, \lambda_{n-k-1} \). These coefficients \( a_{i,q} \) appear in the smoothness measure:

\[ a_{i,q} = \frac{(-1)^{k+1} \, k! \, (\lambda_{i+k+1} - \lambda_i)} {\displaystyle\prod_{\substack{j=q-k \\ j \neq i}}^{q} (\lambda_{q+1} - \lambda_{j+1})} \tag{5.6} \]

for \( q - k - 1 \leq i \leq q \), and zero otherwise. The output matrix \( B \) stores these values for use in evaluating the smoothing functional \( \sum_q [\sum_i c_i \, a_{i,q}]^2 \) (Eq. 5.5).

Parameters
[in]tKnot vector \( \lambda_1, \ldots, \lambda_n \)
[in]nLength of the knot vector
[in]k2Spline order \( k + 1 \) (= degree + 1)
[out]bDiscontinuity jump matrix, stored as b(nest, k2). Row \( q \) contains the \( k+1 \) non-zero jumps at interior knot \( \lambda_{q+k+1} \).
[in]nestLeading dimension of array b
See also
Dierckx, Ch. 5, §5.2.2 (pp. 76-79), Eq. 5.5-5.6

◆ fpfrno()

pure subroutine fitpack_core::fpfrno ( integer(fp_size), intent(in) maxtr,
integer(fp_size), dimension(maxtr), intent(inout) up,
integer(fp_size), dimension(maxtr), intent(inout) left,
integer(fp_size), dimension(maxtr), intent(inout) right,
integer(fp_size), dimension(maxtr), intent(inout) info,
integer(fp_size), intent(inout) point,
integer(fp_size), intent(inout) merk,
integer(fp_size), intent(in) n1,
integer(fp_size), intent(out) count,
integer(fp_flag), intent(out) ier )
private

Collect free nodes from the constraint-set binary tree.

Scans the triply linked tree for free nodes (those with up = 0, previously released by fpdeno) and makes them available for reuse. If no free nodes are found, the error flag ier is set to 1.

This routine is called by fpadno when the tree needs a new node but the count pointer has exhausted the pre-allocated array.

Parameters
[in]maxtrSize of the tree arrays
[in,out]upParent pointers; up(i) = 0 marks a free node
[in,out]leftLeft-child pointers
[in,out]rightRight-child pointers
[in,out]infoConstraint index stored at each node
[in,out]pointPointer to the collected free-node chain
[in,out]merkTerminal node of the current branch
[in]n1Maximum branch length
[out]countNumber of free nodes found
[out]ierError flag: 0 = success, 1 = no free nodes
See also
Dierckx, Ch. 7, §7.2.4 (pp. 125-130)
fpadno, fpdeno, fpseno — companion tree operations

◆ fpgivs()

elemental subroutine fitpack_core::fpgivs ( real(fp_real), intent(in) piv,
real(fp_real), intent(inout) ww,
real(fp_real), intent(out) cos,
real(fp_real), intent(out) sin )
private

Compute parameters of a Givens plane rotation.

Given a pivot element \( e_i \) and a diagonal element \( r_i \), computes the cosine \( c \) and sine \( s \) of a Givens rotation that eliminates \( e_i \):

\[ r'_i = \sqrt{r_i^2 + e_i^2}, \quad c = \frac{r_i}{r'_i}, \quad s = \frac{e_i}{r'_i} \tag{4.15} \]

The rotation preserves orthogonality ( \( c^2 + s^2 = 1 \)) and is used to triangularize the observation matrix \( E \) row by row during the QR decomposition of the least-squares system.

Parameters
[in]pivPivot element \( e_i \) to be eliminated
[in,out]wwOn entry, diagonal element \( r_i \). On exit, updated value \( r'_i = \sqrt{r_i^2 + e_i^2} \).
[out]cosCosine of rotation angle
[out]sinSine of rotation angle
See also
Dierckx, Ch. 4, §4.1.2 (pp. 55-58), Eq. 4.15

◆ fpgrdi()

pure subroutine fitpack_core::fpgrdi ( integer(fp_size), intent(inout) ifsu,
integer(fp_size), intent(inout) ifsv,
integer(fp_size), intent(inout) ifbu,
integer(fp_size), intent(inout) ifbv,
logical(fp_bool), intent(in) lback,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mv), intent(in) v,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mz), intent(in) z,
integer(fp_size), intent(in) mz,
real(fp_real), dimension(3), intent(in) dz,
integer(fp_size), intent(in) iop0,
integer(fp_size), intent(in) iop1,
real(fp_real), dimension(nu), intent(in) tu,
integer(fp_size), intent(in) nu,
real(fp_real), dimension(nv), intent(in) tv,
integer(fp_size), intent(in) nv,
real(fp_real), intent(out) p,
real(fp_real), dimension(nc), intent(inout) c,
integer(fp_size), intent(in) nc,
real(fp_real), intent(out) sq,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(nu), intent(inout) fpu,
real(fp_real), dimension(nv), intent(inout) fpv,
integer(fp_size), intent(in) mm,
integer(fp_size), intent(in) mvnu,
real(fp_real), dimension(mu,4), intent(inout) spu,
real(fp_real), dimension(mv,4), intent(inout) spv,
real(fp_real), dimension(mm), intent(inout) right,
real(fp_real), dimension(mvnu), intent(inout) q,
real(fp_real), dimension(nu,5), intent(inout) au,
real(fp_real), dimension(nv,6), intent(inout) av1,
real(fp_real), dimension(nv,4), intent(inout) av2,
real(fp_real), dimension(nu,5), intent(inout) bu,
real(fp_real), dimension(nv,5), intent(inout) bv,
real(fp_real), dimension(2,mv), intent(inout) aa,
real(fp_real), dimension(2,nv), intent(inout) bb,
real(fp_real), dimension(nv), intent(inout) cc,
real(fp_real), dimension(nv,2), intent(inout) cosi,
integer(fp_size), dimension(mu), intent(inout) nru,
integer(fp_size), dimension(mv), intent(inout) nrv )
private

Compute spline coefficients on a polar/spherical grid via Kronecker product.

Grid-based variant of the Kronecker product decomposition (Eq. 10.4-10.8) adapted for polar and spherical coordinates. Handles the periodic \( v \)-direction using two-matrix rotations (fp_rotate_2mat_stride) and incorporates origin/pole boundary conditions via the iop0/iop1 flags. The dz parameter provides prescribed values at \( u = 0 \) and/or \( u = 1 \).

Uses lback = .true. for back-substitution only (coefficients from a previous triangularization).

Parameters
[in,out]ifsuFlag: 0 = recompute \( S_{pu} \)
[in,out]ifsvFlag: 0 = recompute \( S_{pv} \)
[in,out]ifbuFlag: 0 = recompute \( B_u \)
[in,out]ifbvFlag: 0 = recompute \( B_v \)
[in]lback.true. = back-substitution only
[in]uRadial grid values, length mu
[in]muNumber of radial grid points
[in]vAngular grid values, length mv
[in]mvNumber of angular grid points
[in]zData values, length mz
[in]mzLength of z
[in]dzBoundary values at origin/edge
[in]iop0Boundary condition at \( u = 0 \)
[in]iop1Boundary condition at \( u = 1 \)
[in]tuRadial knot vector
[in]nuNumber of radial knots
[in]tvAngular knot vector
[in]nvNumber of angular knots
[out]pSmoothing parameter (output)
[in,out]cB-spline coefficients, length nc
[in]ncLength of c
[out]sqSum of squared residuals
[in,out]fpWeighted sum of squared residuals
[in,out]fpuResidual sums per radial interval
[in,out]fpvResidual sums per angular interval
[in]mmWork dimension
[in]mvnuWork dimension
[in,out]spuRadial B-spline observation matrix
[in,out]spvAngular B-spline observation matrix
[in,out]rightWork: RHS vector
[in,out]qWork: RHS matrix
[in,out]auWork: radial band matrix
[in,out]av1Work: angular band matrix (main block)
[in,out]av2Work: angular band matrix (periodic block)
[in,out]buWork: radial discontinuity jumps
[in,out]bvWork: angular discontinuity jumps
[in,out]aaWork: boundary constraint matrix
[in,out]bbWork: boundary constraint matrix
[in,out]ccWork: boundary constraint matrix
[in,out]cosiWork: cosine integrals
[in,out]nruWork: radial knot interval indices
[in,out]nrvWork: angular knot interval indices
See also
Dierckx, Ch. 10, §10.2 (pp. 170-172), Eq. 10.4-10.8
fp_rotate_2mat_stride — periodic grid Givens rotation
Here is the call graph for this function:

◆ fpgrpa()

pure subroutine fitpack_core::fpgrpa ( integer(fp_size), intent(inout) ifsu,
integer(fp_size), intent(inout) ifsv,
integer(fp_size), intent(inout) ifbu,
integer(fp_size), intent(inout) ifbv,
integer(fp_size), intent(in) idim,
integer(fp_size), dimension(2), intent(in) ipar,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mv), intent(in) v,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mz*idim), intent(in) z,
integer(fp_size), intent(in) mz,
real(fp_real), dimension(nu), intent(in) tu,
integer(fp_size), intent(in) nu,
real(fp_real), dimension(nv), intent(in) tv,
integer(fp_size), intent(in) nv,
real(fp_real), intent(in) p,
real(fp_real), dimension(nc*idim), intent(inout) c,
integer(fp_size), intent(in) nc,
real(fp_real), intent(out) fp,
real(fp_real), dimension(nu), intent(out) fpu,
real(fp_real), dimension(nv), intent(out) fpv,
integer(fp_size), intent(in) mm,
integer(fp_size), intent(in) mvnu,
real(fp_real), dimension(mu,4), intent(inout) spu,
real(fp_real), dimension(mv,4), intent(inout) spv,
real(fp_real), dimension(mm*idim), intent(inout) right,
real(fp_real), dimension(mvnu), intent(inout) q,
real(fp_real), dimension(nu,5), intent(inout) au,
real(fp_real), dimension(nu,4), intent(inout) au1,
real(fp_real), dimension(nv,5), intent(inout) av,
real(fp_real), dimension(nv,4), intent(inout) av1,
real(fp_real), dimension(nu,5), intent(inout) bu,
real(fp_real), dimension(nv,5), intent(inout) bv,
integer(fp_size), dimension(mu), intent(inout) nru,
integer(fp_size), dimension(mv), intent(inout) nrv )
private

Compute parametric surface spline coefficients on a grid.

Grid-based Kronecker product decomposition (Eq. 10.9-10.12) for \( d \)-dimensional parametric surfaces. Computes the least-squares spline \( s_\infty(u,v) \) and the per-interval residual sums fpu(j) and fpv(j) needed for knot-placement decisions. Handles optional periodicity in \( u \) and/or \( v \) via the ipar flags, using two-matrix variants for periodic directions.

Parameters
[in,out]ifsuFlag: 0 = recompute \( S_{pu} \)
[in,out]ifsvFlag: 0 = recompute \( S_{pv} \)
[in,out]ifbuFlag: 0 = recompute \( B_u \)
[in,out]ifbvFlag: 0 = recompute \( B_v \)
[in]idimNumber of surface dimensions \( d \)
[in]iparPeriodicity flags (packed)
[in]u\( u \)-grid values, length mu
[in]muNumber of \( u \)-grid points
[in]v\( v \)-grid values, length mv
[in]mvNumber of \( v \)-grid points
[in]zData values, length mz
[in]mzLength of z
[in]tu\( u \)-knot vector
[in]nuNumber of \( u \)-knots
[in]tv\( v \)-knot vector
[in]nvNumber of \( v \)-knots
[in]pSmoothing parameter
[in,out]cB-spline coefficients, length nc
[in]ncLength of c
[in,out]fpTotal weighted sum of squared residuals
[in,out]fpuResidual sums per \( u \)-interval
[in,out]fpvResidual sums per \( v \)-interval
[in]mmWork dimension
[in]mvnuWork dimension
[in,out]spu\( u \)-B-spline observation matrix
[in,out]spv\( v \)-B-spline observation matrix
[in,out]rightWork: RHS vector
[in,out]qWork: RHS matrix
[in,out]auWork: \( u \)-band matrix (main)
[in,out]au1Work: \( u \)-band matrix (periodic)
[in,out]avWork: \( v \)-band matrix (main)
[in,out]av1Work: \( v \)-band matrix (periodic)
[in,out]buWork: \( u \)-discontinuity jumps
[in,out]bvWork: \( v \)-discontinuity jumps
[in,out]nruWork: \( u \)-knot interval indices
[in,out]nrvWork: \( v \)-knot interval indices
See also
Dierckx, Ch. 10, §10.3 (pp. 173-178), Eq. 10.9-10.12
fptrnp, fptrpe — tensor-product triangularization
Here is the call graph for this function:

◆ fpgrre()

pure subroutine fitpack_core::fpgrre ( integer(fp_size), intent(inout) ifsx,
integer(fp_size), intent(inout) ifsy,
integer(fp_size), intent(inout) ifbx,
integer(fp_size), intent(inout) ifby,
real(fp_real), dimension(mx), intent(in) x,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(my), intent(in) y,
integer(fp_size), intent(in) my,
real(fp_real), dimension(mz), intent(in) z,
integer(fp_size), intent(in) mz,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
real(fp_real), dimension(nx), intent(in) tx,
integer(fp_size), intent(in) nx,
real(fp_real), dimension(ny), intent(in) ty,
integer(fp_size), intent(in) ny,
real(fp_real), intent(in) p,
real(fp_real), dimension(nc), intent(inout) c,
integer(fp_size), intent(in) nc,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(nx), intent(inout) fpx,
real(fp_real), dimension(ny), intent(inout) fpy,
integer(fp_size), intent(in) mm,
integer(fp_size), intent(in) mynx,
integer(fp_size), intent(in) kx1,
integer(fp_size), intent(in) kx2,
integer(fp_size), intent(in) ky1,
integer(fp_size), intent(in) ky2,
real(fp_real), dimension(mx,kx1), intent(inout) spx,
real(fp_real), dimension(my,ky1), intent(inout) spy,
real(fp_real), dimension(mm), intent(inout) right,
real(fp_real), dimension(mynx), intent(inout) q,
real(fp_real), dimension(nx,kx2), intent(inout) ax,
real(fp_real), dimension(ny,ky2), intent(inout) ay,
real(fp_real), dimension(nx,kx2), intent(inout) bx,
real(fp_real), dimension(ny,ky2), intent(inout) by,
integer(fp_size), dimension(mx), intent(inout) nrx,
integer(fp_size), dimension(my), intent(inout) nry )
private

Compute grid-based spline coefficients via Kronecker product decomposition.

For data on a rectangular grid \( \{x_i\} \times \{y_j\} \), solves the smoothing least-squares system using the Kronecker product structure (Eq. 10.4-10.8):

\[ A_y \, C \, A_x^T = Q \tag{10.4} \]

where the augmented observation matrices are:

\[ A_x = \begin{pmatrix} S_{px} \\ \frac{1}{\sqrt{p}} B_x \end{pmatrix}, \quad A_y = \begin{pmatrix} S_{py} \\ \frac{1}{\sqrt{p}} B_y \end{pmatrix} \tag{10.5} \]

The \( x \)- and \( y \)-direction QR factorizations are performed independently using fp_rotate_row_stride (row-access RHS for \( A_y \)) and fp_rotate_row_block (column-access RHS for \( A_x \)), followed by back-substitution. Also computes residual sums fpx, fpy per knot interval for knot-placement decisions.

Parameters
[in,out]ifsxFlag: 0 = recompute \( S_{px} \)
[in,out]ifsyFlag: 0 = recompute \( S_{py} \)
[in,out]ifbxFlag: 0 = recompute \( B_x \)
[in,out]ifbyFlag: 0 = recompute \( B_y \)
[in]x\( x \)-grid values, length mx
[in]mxNumber of \( x \)-grid points
[in]y\( y \)-grid values, length my
[in]myNumber of \( y \)-grid points
[in]zData values on the grid, length mz
[in]mzLength of z ( \( = mx \cdot my \))
[in]kxDegree in \( x \)
[in]kyDegree in \( y \)
[in]tx\( x \)-knot vector
[in]nxNumber of \( x \)-knots
[in]ty\( y \)-knot vector
[in]nyNumber of \( y \)-knots
[in]pSmoothing parameter
[in,out]cB-spline coefficients, length nc
[in]ncLength of c
[in,out]fpTotal weighted sum of squared residuals
[in,out]fpxResidual sums per \( x \)-interval
[in,out]fpyResidual sums per \( y \)-interval
[in]mmWork dimension
[in]mynxWork dimension ( \( my \cdot (nx - kx - 1) \))
[in]kx1\( k_x + 1 \)
[in]kx2\( k_x + 2 \)
[in]ky1\( k_y + 1 \)
[in]ky2\( k_y + 2 \)
[in,out]spx\( x \)-B-spline observation matrix
[in,out]spy\( y \)-B-spline observation matrix
[in,out]rightWork: RHS vector for row rotations
[in,out]qWork: RHS matrix
[in,out]axWork: \( x \)-band matrix
[in,out]ayWork: \( y \)-band matrix
[in,out]bxWork: \( x \)-discontinuity jumps
[in,out]byWork: \( y \)-discontinuity jumps
[in,out]nrxWork: \( x \)-knot interval indices
[in,out]nryWork: \( y \)-knot interval indices
See also
Dierckx, Ch. 10, §10.2 (pp. 170-172), Eq. 10.4-10.8
fp_rotate_row_block, fp_rotate_row_stride — grid Givens rotations
Here is the call graph for this function:

◆ fpgrsp()

pure subroutine fitpack_core::fpgrsp ( integer(fp_size), intent(inout) ifsu,
integer(fp_size), intent(inout) ifsv,
integer(fp_size), intent(inout) ifbu,
integer(fp_size), intent(inout) ifbv,
logical(fp_bool), intent(in) lback,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mv), intent(in) v,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mr), intent(in) r,
integer(fp_size), intent(in) mr,
real(fp_real), dimension(6), intent(in) dr,
integer(fp_size), intent(in) iop0,
integer(fp_size), intent(in) iop1,
real(fp_real), dimension(nu), intent(in) tu,
integer(fp_size), intent(in) nu,
real(fp_real), dimension(nv), intent(in) tv,
integer(fp_size), intent(in) nv,
real(fp_real), intent(in) p,
real(fp_real), dimension(nc), intent(inout) c,
integer(fp_size), intent(in) nc,
real(fp_real), intent(inout) sq,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(nu), intent(inout) fpu,
real(fp_real), dimension(nv), intent(inout) fpv,
integer(fp_size), intent(in) mm,
integer(fp_size), intent(in) mvnu,
real(fp_real), dimension(mu,4), intent(inout) spu,
real(fp_real), dimension(mv,4), intent(inout) spv,
real(fp_real), dimension(mm), intent(inout) right,
real(fp_real), dimension(mvnu), intent(inout) q,
real(fp_real), dimension(nu,5), intent(inout) au,
real(fp_real), dimension(nv,6), intent(inout) av1,
real(fp_real), dimension(nv,4), intent(inout) av2,
real(fp_real), dimension(nu,5), intent(inout) bu,
real(fp_real), dimension(nv,5), intent(inout) bv,
real(fp_real), dimension(2,mv), intent(inout) a0,
real(fp_real), dimension(2,mv), intent(inout) a1,
real(fp_real), dimension(2,nv), intent(inout) b0,
real(fp_real), dimension(2,nv), intent(inout) b1,
real(fp_real), dimension(nv), intent(inout) c0,
real(fp_real), dimension(nv), intent(inout) c1,
real(fp_real), dimension(nv,2), intent(inout) cosi,
integer(fp_size), dimension(mu), intent(inout) nru,
integer(fp_size), dimension(mv), intent(inout) nrv )
private

Compute spherical grid spline coefficients via Kronecker product.

Spherical-coordinate variant of fpgrdi for data on a \( \theta \times \phi \) grid. Handles pole-continuity constraints at \( \theta = 0 \) and \( \theta = \pi \) via the iop0/iop1 flags, and the periodic \( \phi \)-direction using two-matrix rotations. The dr parameter provides prescribed pole values.

Parameters
[in,out]ifsuFlag: 0 = recompute \( S_{pu} \)
[in,out]ifsvFlag: 0 = recompute \( S_{pv} \)
[in,out]ifbuFlag: 0 = recompute \( B_u \)
[in,out]ifbvFlag: 0 = recompute \( B_v \)
[in]lback.true. = back-substitution only
[in]uCo-latitude grid values \( \theta \), length mu
[in]muNumber of \( \theta \)-grid points
[in]vLongitude grid values \( \phi \), length mv
[in]mvNumber of \( \phi \)-grid points
[in]rData values, length mr
[in]mrLength of r
[in]drPole boundary values
[in]iop0Boundary condition at north pole ( \( \theta = 0 \))
[in]iop1Boundary condition at south pole ( \( \theta = \pi \))
[in]tu\( \theta \)-knot vector
[in]nuNumber of \( \theta \)-knots
[in]tv\( \phi \)-knot vector
[in]nvNumber of \( \phi \)-knots
[in,out]pSmoothing parameter
[in,out]cB-spline coefficients, length nc
[in]ncLength of c
[in,out]sqSum of squared residuals
[in,out]fpWeighted sum of squared residuals
[in,out]fpuResidual sums per \( \theta \)-interval
[in,out]fpvResidual sums per \( \phi \)-interval
[in]mmWork dimension
[in]mvnuWork dimension
[in,out]spu\( \theta \)-B-spline observation matrix
[in,out]spv\( \phi \)-B-spline observation matrix
[in,out]rightWork: RHS vector
[in,out]qWork: RHS matrix
[in,out]auWork: \( \theta \)-band matrix
[in,out]av1Work: \( \phi \)-band matrix (main)
[in,out]av2Work: \( \phi \)-band matrix (periodic)
[in,out]buWork: \( \theta \)-discontinuity jumps
[in,out]bvWork: \( \phi \)-discontinuity jumps
[in,out]a0Work: north-pole constraint row
[in,out]a1Work: south-pole constraint row
[in,out]b0Work: north-pole smoothing row
[in,out]b1Work: south-pole smoothing row
[in,out]c0Work: north-pole cosine row
[in,out]c1Work: south-pole cosine row
[in,out]cosiWork: cosine integrals
[in,out]nruWork: \( \theta \)-knot interval indices
[in,out]nrvWork: \( \phi \)-knot interval indices
See also
Dierckx, Ch. 11, §11.2 (pp. 205-213)
fpgrdipolar grid variant; fp_rotate_2mat_stride — periodic rotation
Here is the call graph for this function:

◆ fpinst()

pure subroutine fitpack_core::fpinst ( integer(fp_size), intent(in) iopt,
real(fp_real), dimension(nest), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(nest), intent(in) c,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) x,
integer(fp_size), intent(in) l,
real(fp_real), dimension(nest), intent(out) tt,
integer(fp_size), intent(out) nn,
real(fp_real), dimension(nest), intent(out) cc,
integer(fp_size), intent(in) nest )
private

Insert a single knot into a B-spline representation.

Given the B-spline representation \( (t, c) \) of a degree- \( k \) spline, computes the new knot vector \( t' \) and coefficients \( c' \) that represent the same spline after inserting one additional knot \( x \in [\lambda_l, \lambda_{l+1}) \). Uses the Boehm (1980) one-knot-at-a-time algorithm:

\[ d_i = r_i \, c_i + (1 - r_i) \, c_{i-1} \tag{1.47} \]

where each weight \( r_i \in [0, 1] \) is a convex combination factor:

\[ r_i = \frac{\tau_{j+1} - \tau_i}{\tau_{i+k+1} - \tau_i} \tag{1.48} \]

For periodic splines (iopt /= 0), the boundary coefficients are wrapped accordingly. At least one of \( l > 2k \) or \( l < n - 2k \) must hold.

Parameters
[in]iopt0 = non-periodic spline, otherwise periodic
[in]tInput knot vector, length n
[in]nNumber of input knots
[in]cInput B-spline coefficients, length n-k-1
[in]kSpline degree
[in]xNew knot to insert, \( \lambda_l \leq x < \lambda_{l+1} \)
[in]lKnot interval index where x is inserted
[out]ttOutput knot vector, length nn
[out]nnNumber of output knots ( \( n + 1 \))
[out]ccOutput B-spline coefficients, length nn-k-1
[in]nestLeading dimension of arrays t, c, tt, cc
See also
Dierckx, Ch. 1, §1.3.4 (pp. 34-37), Eq. 1.46-1.48

◆ fpintb()

pure subroutine fitpack_core::fpintb ( real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(nk1), intent(out) bint,
integer(fp_size), intent(in) nk1,
real(fp_real), intent(in) x,
real(fp_real), intent(in) y )
private

Compute definite integrals of the normalized B-splines.

Calculates the definite integrals of each of the \( n-k-1 \) normalized B-splines \( N_{j,k+1}(u) \) of degree \( k \) over the interval \( [x, y] \):

\[ \text{bint}(j) = \int_x^y N_{j,k+1}(u) \, du \]

Uses the Gaffney formula for indefinite integrals of B-splines, which exploits the identity (Eq. 1.42):

\[ \int_{\lambda_j}^{u} N_{j,k+1}(v) \, dv = \frac{\lambda_{j+k+1} - \lambda_j}{k+1} \sum_{i=j+1}^{g+k+1} N_{i,k+2}(u) \tag{1.42} \]

Parameters
[in]tKnot vector \( \lambda_1, \ldots, \lambda_n \)
[in]nNumber of knots
[out]bintArray of length nk1; \( \text{bint}(j) = \int_x^y N_{j,k+1}(u)\,du \)
[in]nk1Number of B-splines ( \( n - k - 1 \))
[in]xLower integration limit
[in]yUpper integration limit
See also
Dierckx, Ch. 1, §1.3.3 (pp. 30-33), Eq. 1.42-1.44
Dierckx, Ch. 3, §3.2 (pp. 44-46), Eq. 3.8-3.10
Here is the call graph for this function:

◆ fpknot()

pure subroutine fitpack_core::fpknot ( real(fp_real), dimension(m), intent(in) x,
integer(fp_size), intent(in) m,
real(fp_real), dimension(nest), intent(inout) t,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) fpint,
integer(fp_size), dimension(nest), intent(inout) nrdata,
integer(fp_size), intent(inout) nrint,
integer(fp_size), intent(in) nest,
integer(fp_size), intent(in) istart )
private

Select and insert a new knot at the location of maximum residual.

Locates the knot interval \( [\lambda_j, \lambda_{j+1}] \) with the largest sum of squared residuals \( \delta_j \) (Eq. 5.43) and inserts a new knot at the midpoint of its interior data points. This is the greedy knot-placement strategy used by the iterative smoothing spline algorithm:

\[ \delta_j = \sideset{}{''}{\sum}_{r=u_j+1}^{u_j+m_j} \bigl( w_r (y_r - S_{g}(x_r)) \bigr)^2 \tag{5.43} \]

Only intervals with at least one interior data point ( \( m_j > 2 \)) are eligible. The new knot is placed at \( x_{u_j + \lceil m_j/2 \rceil + 1} \). After insertion, fpint and nrdata are split to reflect the two new sub-intervals.

Parameters
[in]xData abscissae, length m
[in]mNumber of data points
[in,out]tKnot vector; new knot inserted on exit
[in,out]nNumber of knots; incremented by 1 on exit
[in,out]fpintResidual sum of squares per knot interval
[in,out]nrdataNumber of interior data points per interval
[in,out]nrintNumber of knot intervals; incremented by 1
[in]nestLeading dimension of arrays t, fpint, nrdata
[in]istartSmallest eligible data index minus one
See also
Dierckx, Ch. 5, §5.3 (pp. 87-94), Eq. 5.37-5.43

◆ fpopdi()

pure subroutine fitpack_core::fpopdi ( integer(fp_size), intent(inout) ifsu,
integer(fp_size), intent(inout) ifsv,
integer(fp_size), intent(inout) ifbu,
integer(fp_size), intent(inout) ifbv,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mv), intent(in) v,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mz), intent(in) z,
integer(fp_size), intent(in) mz,
real(fp_real), intent(in) z0,
real(fp_real), dimension(3), intent(inout) dz,
integer(fp_size), dimension(3), intent(in) iopt,
integer(fp_size), dimension(2), intent(in) ider,
real(fp_real), dimension(nu), intent(in) tu,
integer(fp_size), intent(in) nu,
real(fp_real), dimension(nv), intent(in) tv,
integer(fp_size), intent(in) nv,
integer(fp_size), intent(in) nuest,
integer(fp_size), intent(in) nvest,
real(fp_real), intent(inout) p,
real(fp_real), intent(in) step,
real(fp_real), dimension(nc), intent(inout) c,
integer(fp_size), intent(in) nc,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(nu), intent(inout) fpu,
real(fp_real), dimension(nv), intent(inout) fpv,
integer(fp_size), dimension(mu), intent(inout) nru,
integer(fp_size), dimension(mv), intent(inout) nrv,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk )
private

Compute smoothing spline on a polar grid with origin constraints.

Given data on a \( (u, v) \) grid (radial \( \times \) angular), determines the B-spline coefficients of a bicubic smoothing spline \( s_p(u,v) \) periodic in \( v \), satisfying origin-continuity constraints:

  • \( s(\lambda_1^u, v) = z_0 \) (constant at origin)
  • \( \partial s / \partial u |_{u=0} = dz(2)\cos v + dz(3)\sin v \) (if iopt(2) = 1)
  • \( s(\lambda_{n_u}^u, v) = 0 \) (if iopt(3) = 1)

The unknown boundary parameters dz(i) (when not prescribed) are optimized to minimize the residual sum of squares, which is a quadratic function of dz. Delegates the grid QR factorization to fpgrdi.

Parameters
[in,out]ifsuFlag: 0 = recompute radial B-splines
[in,out]ifsvFlag: 0 = recompute angular B-splines
[in,out]ifbuFlag: 0 = recompute radial discontinuities
[in,out]ifbvFlag: 0 = recompute angular discontinuities
[in]uRadial grid values, length mu
[in]muNumber of radial points
[in]vAngular grid values, length mv
[in]mvNumber of angular points
[in]zData values, length mz
[in]mzLength of z
[in]z0Value at origin (prescribed or initial guess)
[in,out]dzBoundary derivative parameters (3 values)
[in]ioptConstraint options (3 flags)
[in]iderDerivative specification flags
[in]tuRadial knot vector
[in]nuNumber of radial knots
[in]tvAngular knot vector
[in]nvNumber of angular knots
[in]nuestMax radial knots
[in]nvestMax angular knots
[in,out]pSmoothing parameter
[in]stepSearch step for boundary parameter optimization
[in,out]cB-spline coefficients, length nc
[in]ncLength of c
[in,out]fpWeighted sum of squared residuals
[in,out]fpuResidual sums per radial interval
[in,out]fpvResidual sums per angular interval
[in,out]nruRadial knot interval indices
[in,out]nrvAngular knot interval indices
[in,out]wrkWork array
[in]lwrkLength of wrk
See also
Dierckx, Ch. 11, §11.1 (pp. 197-205)
fpgrdi — grid QR factorization; fppogrpolar grid driver
Here is the call graph for this function:

◆ fpopsp()

pure subroutine fitpack_core::fpopsp ( integer(fp_size), intent(inout) ifsu,
integer(fp_size), intent(inout) ifsv,
integer(fp_size), intent(inout) ifbu,
integer(fp_size), intent(inout) ifbv,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mv), intent(in) v,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mr), intent(in) r,
integer(fp_size), intent(in) mr,
real(fp_real), intent(in) r0,
real(fp_real), intent(in) r1,
real(fp_real), dimension(6), intent(inout) dr,
integer(fp_size), dimension(3), intent(in) iopt,
integer(fp_size), dimension(4), intent(in) ider,
real(fp_real), dimension(nu), intent(in) tu,
integer(fp_size), intent(in) nu,
real(fp_real), dimension(nv), intent(in) tv,
integer(fp_size), intent(in) nv,
integer(fp_size), intent(in) nuest,
integer(fp_size), intent(in) nvest,
real(fp_real), intent(inout) p,
real(fp_real), dimension(2), intent(inout) step,
real(fp_real), dimension(nc), intent(inout) c,
integer(fp_size), intent(in) nc,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(nu), intent(inout) fpu,
real(fp_real), dimension(nv), intent(inout) fpv,
integer(fp_size), dimension(mu), intent(inout) nru,
integer(fp_size), dimension(mv), intent(inout) nrv,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk )
private

Compute smoothing spline on a spherical grid with pole constraints.

Spherical counterpart of fpopdi. Given data on a \( (\theta, \phi) \) grid, determines a bicubic smoothing spline \( s_p(\theta,\phi) \) periodic in \( \phi \), satisfying pole-continuity constraints at both poles:

  • \( s(0, \phi) = r_0 \) (north pole value)
  • \( s(\pi, \phi) = r_1 \) (south pole value)
  • Optional derivative constraints: \( \partial s / \partial \theta |_{\theta=0} = dr(2)\cos\phi + dr(3)\sin\phi \)

Unknown pole parameters dr(i) are optimized to minimize the residual. Delegates to fpgrsp for the grid QR factorization.

Parameters
[in,out]ifsuFlag: 0 = recompute \( \theta \)-B-splines
[in,out]ifsvFlag: 0 = recompute \( \phi \)-B-splines
[in,out]ifbuFlag: 0 = recompute \( \theta \)-discontinuities
[in,out]ifbvFlag: 0 = recompute \( \phi \)-discontinuities
[in]uCo-latitude grid \( \theta \), length mu
[in]muNumber of \( \theta \)-points
[in]vLongitude grid \( \phi \), length mv
[in]mvNumber of \( \phi \)-points
[in]rData values, length mr
[in]mrLength of r
[in]r0North-pole value (prescribed or initial guess)
[in]r1South-pole value (prescribed or initial guess)
[in,out]drPole derivative parameters (6 values)
[in]ioptConstraint options
[in]iderDerivative specification flags
[in]tu\( \theta \)-knot vector
[in]nuNumber of \( \theta \)-knots
[in]tv\( \phi \)-knot vector
[in]nvNumber of \( \phi \)-knots
[in]nuestMax \( \theta \)-knots
[in]nvestMax \( \phi \)-knots
[in,out]pSmoothing parameter
[in]stepSearch step for pole parameter optimization
[in,out]cB-spline coefficients, length nc
[in]ncLength of c
[in,out]fpWeighted sum of squared residuals
[in,out]fpuResidual sums per \( \theta \)-interval
[in,out]fpvResidual sums per \( \phi \)-interval
[in,out]nru\( \theta \)-knot interval indices
[in,out]nrv\( \phi \)-knot interval indices
[in,out]wrkWork array
[in]lwrkLength of wrk
See also
Dierckx, Ch. 11, §11.2 (pp. 205-213)
fpgrsp — spherical grid QR factorization; fpspgr — spherical grid driver
Here is the call graph for this function:

◆ fporde()

pure subroutine fitpack_core::fporde ( real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
integer(fp_size), intent(in) m,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
real(fp_real), dimension(nx), intent(in) tx,
integer(fp_size), intent(in) nx,
real(fp_real), dimension(ny), intent(in) ty,
integer(fp_size), intent(in) ny,
integer(fp_size), dimension(m), intent(out) nummer,
integer(fp_size), dimension(nreg), intent(out) index,
integer(fp_size), intent(in) nreg )
private

Sort scattered data points into rectangular panels.

Assigns each data point \( (x_i, y_i) \), \( i = 1, \ldots, m \), to the rectangular panel \( R_{u,v} \) defined by \( \lambda_u^x \leq x < \lambda_{u+1}^x \) and \( \lambda_v^y \leq y < \lambda_{v+1}^y \).

For each panel, a linked-list stack is built:

  • index(j) points to the first data point in panel \( j \)
  • nummer(i) gives the next data point in the same panel

This panel ordering enables efficient row-by-row construction of the observation matrix, since only the \( (k_x+1)(k_y+1) \) B-splines supported on a given panel contribute non-zero entries.

Parameters
[in]xData abscissae, length m
[in]yData ordinates, length m
[in]mNumber of data points
[in]kxSpline degree in \( x \)
[in]kySpline degree in \( y \)
[in]txKnot vector in \( x \), length nx
[in]nxNumber of knots in \( x \)
[in]tyKnot vector in \( y \), length ny
[in]nyNumber of knots in \( y \)
[out]nummerLinked-list next pointers, length m
[out]indexPanel head pointers, length nreg
[in]nregNumber of panels \( = (n_x - 2k_x - 1)(n_y - 2k_y - 1) \)
See also
Dierckx, Ch. 9, §9.1 (pp. 147-150)
Here is the call graph for this function:

◆ fppara()

pure subroutine fitpack_core::fppara ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) idim,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) u,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(mx), intent(in) x,
real(fp_real), dimension(m), intent(in) w,
real(fp_real), intent(in) ub,
real(fp_real), intent(in) ue,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nest,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(in) k1,
integer(fp_size), intent(in) k2,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
integer(fp_size), intent(inout) nc,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(nest), intent(inout) fpint,
real(fp_real), dimension(nc), intent(inout) z,
real(fp_real), dimension(nest,k1), intent(inout) a,
real(fp_real), dimension(nest,k2), intent(inout) b,
real(fp_real), dimension(nest,k2), intent(inout) g,
real(fp_real), dimension(m,k1), intent(inout) q,
integer(fp_size), dimension(nest), intent(inout) nrdata,
integer(fp_flag), intent(inout) ier )
private

Core algorithm for open parametric curve fitting.

Fits a \( d \)-dimensional parametric spline curve \( s(u) = (s_1(u), \ldots, s_d(u)) \) of degree \( k \) on the parameter interval \( [u_b, u_e] \). All \( d \) coordinate curves share the same knot vector and are fitted simultaneously:

\[ \sum_{i=1}^{m} w_i^2 \sum_{j=1}^{d} (x_{i,j} - s_j(u_i))^2 \leq S \tag{6.9} \]

The algorithm follows the same three-level iteration as fpcurf (knot selection, QR factorization, smoothing-parameter search) but uses vector-RHS Givens rotations (fp_rotate_row_vec) to process all dimensions in a single pass.

Parameters
[in]iopt0 = new fit, 1 = continue
[in]idimNumber of curve dimensions \( d \)
[in]mNumber of data points
[in]uParameter values, length m
[in]mxLength of x ( \( = m \cdot d \))
[in]xData coordinates, interleaved, length mx
[in]wData weights, length m
[in]ubLeft boundary of parameter interval
[in]ueRight boundary of parameter interval
[in]kSpline degree
[in]sSmoothing factor \( S \geq 0 \)
[in]nestMax knots
[in]tolTolerance for smoothing condition
[in]maxitMaximum smoothing-parameter iterations
[in]k1\( k + 1 \)
[in]k2\( k + 2 \)
[in,out]nNumber of knots
[in,out]tKnot vector, length nest
[in,out]ncLength of coefficient array c
[in,out]cB-spline coefficients, length nc
[in,out]fpWeighted sum of squared residuals
[in,out]fpintResidual sums per knot interval
[in,out]zWork: transformed RHS
[in,out]aWork: band matrix
[in,out]bWork: smoothing matrix
[in,out]gWork: band matrix copy
[in,out]qWork: B-spline values
[in,out]nrdataInterior data-point counts
[in,out]ierError flag
See also
Dierckx, Ch. 6, §6.3 (pp. 112-114), Eq. 6.9
fp_rotate_row_vec — vector-RHS Givens rotation
Here is the call graph for this function:

◆ fppasu()

pure subroutine fitpack_core::fppasu ( integer(fp_size), intent(in) iopt,
integer(fp_size), dimension(2), intent(in) ipar,
integer(fp_size), intent(in) idim,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mv), intent(in) v,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mz*idim), intent(in) z,
integer(fp_size), intent(in) mz,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nuest,
integer(fp_size), intent(in) nvest,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(inout) nc,
integer(fp_size), intent(inout) nu,
real(fp_real), dimension(nuest), intent(inout) tu,
integer(fp_size), intent(inout) nv,
real(fp_real), dimension(nvest), intent(inout) tv,
real(fp_real), dimension(nc*idim), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), intent(inout) fp0,
real(fp_real), intent(inout) fpold,
real(fp_real), intent(inout) reducu,
real(fp_real), intent(inout) reducv,
real(fp_real), dimension(nuest), intent(inout) fpintu,
real(fp_real), dimension(nvest), intent(inout) fpintv,
integer(fp_size), intent(inout) lastdi,
integer(fp_size), intent(inout) nplusu,
integer(fp_size), intent(inout) nplusv,
integer(fp_size), dimension(mu), intent(inout) nru,
integer(fp_size), dimension(mv), intent(inout) nrv,
integer(fp_size), dimension(nuest), intent(inout) nrdatu,
integer(fp_size), dimension(nvest), intent(inout) nrdatv,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(inout) lwrk,
integer(fp_flag), intent(inout) ier )
private

Core algorithm for parametric surface fitting on a grid.

Fits a \( d \)-dimensional parametric tensor-product spline surface \( s(u,v) = (s_1(u,v), \ldots, s_d(u,v)) \) to data on a rectangular grid \( \{u_i\} \times \{v_j\} \). Uses the Kronecker product decomposition (Eq. 10.9-10.12) that separates the bivariate problem into sequences of univariate operations:

\[ (A_u \otimes A_v) \, c = z \tag{10.9} \]

The \( u \)- and \( v \)-direction triangularizations are performed independently (via fp_rotate_row_block and fp_rotate_row_stride), followed by back-substitution.

Parameters
[in]iopt0 = new fit, 1 = continue
[in]iparPeriodicity flags (packed)
[in]idimNumber of surface dimensions \( d \)
[in]u\( u \)-grid values, length mu
[in]muNumber of \( u \)-grid points
[in]v\( v \)-grid values, length mv
[in]mvNumber of \( v \)-grid points
[in]zData values, length mz ( \( = mu \cdot mv \cdot d \))
[in]mzLength of z
[in]sSmoothing factor \( S \geq 0 \)
[in]nuestMax \( u \)-knots
[in]nvestMax \( v \)-knots
[in]tolSmoothing condition tolerance
[in]maxitMaximum smoothing-parameter iterations
[in,out]ncLength of coefficient array
[in,out]nuNumber of \( u \)-knots
[in,out]tu\( u \)-knot vector
[in,out]nvNumber of \( v \)-knots
[in,out]tv\( v \)-knot vector
[in,out]cB-spline coefficients
[in,out]fpWeighted sum of squared residuals
[in,out]fp0Initial residual sum
[in,out]fpoldPrevious residual sum
[in,out]reducuResidual reduction in \( u \)
[in,out]reducvResidual reduction in \( v \)
[in,out]fpintuResidual sums per \( u \)-interval
[in,out]fpintvResidual sums per \( v \)-interval
[in,out]lastdiLast direction of knot addition
[in,out]nplusuNumber of \( u \)-knots to add
[in,out]nplusvNumber of \( v \)-knots to add
[in,out]nruWork: \( u \)-knot interval indices
[in,out]nrvWork: \( v \)-knot interval indices
[in,out]nrdatuInterior data counts per \( u \)-interval
[in,out]nrdatvInterior data counts per \( v \)-interval
[in,out]wrkWork array
[in,out]lwrkLength of wrk
[in,out]ierError flag
See also
Dierckx, Ch. 10, §10.3 (pp. 173-178), Eq. 10.9-10.12
fpgrre, fpgrdi — grid triangularization helpers
Here is the call graph for this function:

◆ fpperi()

pure subroutine fitpack_core::fpperi ( integer(fp_size), intent(in) iopt,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(m), intent(in) w,
integer(fp_size), intent(in) m,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nest,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(in) k1,
integer(fp_size), intent(in) k2,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
real(fp_real), dimension(nest), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(nest), intent(inout) fpint,
real(fp_real), dimension(nest), intent(inout) z,
real(fp_real), dimension(nest,k1), intent(inout) a1,
real(fp_real), dimension(nest,k), intent(inout) a2,
real(fp_real), dimension(nest,k2), intent(inout) b,
real(fp_real), dimension(nest,k2), intent(inout) g1,
real(fp_real), dimension(nest,k1), intent(inout) g2,
real(fp_real), dimension(m,k1), intent(inout) q,
integer(fp_size), dimension(nest), intent(inout) nrdata,
integer(fp_flag), intent(inout) ier )
private

Core algorithm for univariate periodic spline fitting.

Fits a periodic spline \( s(x) \) of degree \( k \) where \( s^{(j)}(x_1) = s^{(j)}(x_m) \) for \( j = 0, \ldots, k-1 \). The periodicity reduces the number of free coefficients to \( n - 2k - 1 \) and wraps the B-spline columns into the block-triangular structure (Eq. 6.13) analogous to fpclos.

This is the scalar-valued counterpart of fpclos (which handles multi-dimensional parametric curves). Uses two-matrix Givens rotations (fp_rotate_row_2mat) for the periodic block structure.

Parameters
[in]iopt0 = new fit, 1 = continue
[in]xData abscissae, length m (strictly increasing)
[in]yData ordinates, length m
[in]wData weights, length m
[in]mNumber of data points
[in]kSpline degree
[in]sSmoothing factor \( S \geq 0 \)
[in]nestMax knots
[in]tolTolerance for smoothing condition
[in]maxitMaximum smoothing-parameter iterations
[in]k1\( k + 1 \)
[in]k2\( k + 2 \)
[in,out]nNumber of knots
[in,out]tKnot vector, length nest
[in,out]cB-spline coefficients, length nest
[in,out]fpWeighted sum of squared residuals
[in,out]fpintResidual sums per knot interval
[in,out]zWork: transformed RHS
[in,out]a1Work: band matrix \( R_{11}^* \)
[in,out]a2Work: band matrix \( R_{12}^*/R_{22}^* \)
[in,out]bWork: smoothing matrix
[in,out]g1Work: band matrix copy
[in,out]g2Work: band matrix copy
[in,out]qWork: B-spline values
[in,out]nrdataInterior data-point counts
[in,out]ierError flag
See also
Dierckx, Ch. 6, §6.1-6.2 (pp. 95-112), Eq. 6.1-6.8
fp_rotate_row_2mat — two-matrix scalar Givens rotation
Here is the call graph for this function:

◆ fpperi_reset_interp()

pure subroutine fitpack_core::fpperi_reset_interp ( integer(fp_size), intent(in) k,
integer(fp_size), intent(in) m,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) nest,
integer(fp_size), intent(inout) kk,
integer(fp_size), intent(inout) kk1,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(nest), intent(inout) t,
real(fp_real), dimension(nest), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), intent(in) per,
real(fp_real), intent(in) fp0,
real(fp_real), intent(in) s,
real(fp_real), dimension(nest), intent(inout) fpint,
integer(fp_size), dimension(nest), intent(inout) nrdata,
logical(fp_bool), intent(out) done )
private

Set up the initial knot configuration for periodic spline interpolation.

When \( s = 0 \) (interpolation) and \( k \) is odd, places interior knots at the data abscissae. For \( k = 1 \) (linear), directly sets the B-spline coefficients from the data and returns the exact interpolant. When \( k \) is even, knots are placed at midpoints of consecutive abscissae.

Parameters
[in]kSpline degree
[in]mNumber of data points
[in]nNumber of knots
[in]nestMaximum knots allowed
[in,out]kkAdjusted degree for iteration
[in,out]kk1Adjusted order for iteration
[in]xData abscissae, length m
[in]yData ordinates, length m
[in,out]tKnot vector, length nest
[in,out]cB-spline coefficients, length nest
[in,out]fpWeighted sum of squared residuals
[in]perPeriod \( = x_m - x_1 \)
[in]fp0Upper bound for the smoothing factor
[in]sSmoothing factor
[in,out]fpintKnot interval contributions, length nest
[in,out]nrdataData point counts per interval, length nest
[out]done.true. if the interpolant was fully determined
See also
Dierckx, Ch. 6, §6.1-6.2 (pp. 95-112): periodic spline fitting

◆ fppocu()

pure subroutine fitpack_core::fppocu ( integer(fp_size), intent(in) idim,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) a,
real(fp_real), intent(in) b,
integer(fp_size), intent(in) ib,
real(fp_real), dimension(nb), intent(in) db,
integer(fp_size), intent(in) nb,
integer(fp_size), intent(in) ie,
real(fp_real), dimension(ne), intent(in) de,
integer(fp_size), intent(in) ne,
real(fp_real), dimension(np), intent(inout) cp,
integer(fp_size), intent(in) np )
private

Construct a polynomial curve satisfying endpoint derivative constraints.

Finds a \( d \)-dimensional polynomial curve \( p(u) = (p_1(u), \ldots, p_d(u)) \) of degree \( k \) that satisfies prescribed derivative values at the endpoints \( a \) and \( b \):

\[ p_j^{(l)}(a) = \text{db}(d \cdot l + j), \quad l = 0, \ldots, i_b - 1 \]

\[ p_j^{(l)}(b) = \text{de}(d \cdot l + j), \quad l = 0, \ldots, i_e - 1 \]

The result is returned as B-spline coefficients cp(1:np) on the knot vector \( [a, \ldots, a, b, \ldots, b] \) (each with multiplicity \( k+1 \)). Used by concur to build an initial polynomial approximation for constrained parametric curves.

Parameters
[in]idimNumber of curve dimensions \( d \)
[in]kPolynomial degree
[in]aLeft endpoint
[in]bRight endpoint
[in]ibNumber of derivative conditions at \( a \)
[in]dbDerivative values at \( a \), length nb
[in]nbLength of db ( \( = d \cdot i_b \))
[in]ieNumber of derivative conditions at \( b \)
[in]deDerivative values at \( b \), length ne
[in]neLength of de ( \( = d \cdot i_e \))
[out]cpB-spline coefficients of the polynomial, length np
[in]npLength of cp ( \( = d \cdot (k+1) \))
See also
Dierckx, Ch. 7, §7.1 (pp. 115-120)

◆ fppogr()

pure subroutine fitpack_core::fppogr ( integer(fp_size), dimension(3), intent(in) iopt,
integer(fp_size), dimension(2), intent(in) ider,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mv), intent(in) v,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mz), intent(in) z,
integer(fp_size), intent(in) mz,
real(fp_real), intent(in) z0,
real(fp_real), intent(in) r,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nuest,
integer(fp_size), intent(in) nvest,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(in) nc,
integer(fp_size), intent(inout) nu,
real(fp_real), dimension(nuest), intent(inout) tu,
integer(fp_size), intent(inout) nv,
real(fp_real), dimension(nvest), intent(inout) tv,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), intent(inout) fp0,
real(fp_real), intent(inout) fpold,
real(fp_real), intent(inout) reducu,
real(fp_real), intent(inout) reducv,
real(fp_real), dimension(nuest), intent(inout) fpintu,
real(fp_real), dimension(nvest), intent(inout) fpintv,
real(fp_real), dimension(3), intent(inout) dz,
real(fp_real), intent(inout) step,
integer(fp_size), intent(inout) lastdi,
integer(fp_size), intent(inout) nplusu,
integer(fp_size), intent(inout) nplusv,
integer(fp_size), intent(inout) lasttu,
integer(fp_size), dimension(mu), intent(inout) nru,
integer(fp_size), dimension(mv), intent(inout) nrv,
integer(fp_size), dimension(nuest), intent(inout) nrdatu,
integer(fp_size), dimension(nvest), intent(inout) nrdatv,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_flag), intent(inout) ier )
private

Driver for polar grid smoothing spline with knot selection.

Outer iteration loop for fitting a smoothing spline on a polar grid. Manages the knot-selection strategy (adding knots in the radial or angular direction based on residuals) and the smoothing-parameter search, delegating the actual grid computation to fpopdi at each step.

Parameters
[in]ioptFitting options (3 flags)
[in]iderDerivative specification flags
[in]uRadial grid, length mu
[in]muNumber of radial points
[in]vAngular grid, length mv
[in]mvNumber of angular points
[in]zData values, length mz
[in]mzLength of z
[in]z0Origin value
[in]rBoundary function values, length mv
[in]sSmoothing factor \( S \geq 0 \)
[in]nuestMax radial knots
[in]nvestMax angular knots
[in]tolSmoothing condition tolerance
[in]maxitMaximum smoothing-parameter iterations
[in]ncLength of coefficient array
[in,out]nuNumber of radial knots
[in,out]tuRadial knot vector
[in,out]nvNumber of angular knots
[in,out]tvAngular knot vector
[in,out]cB-spline coefficients
[in,out]fpWeighted sum of squared residuals
[in,out]fp0Initial residual
[in,out]fpoldPrevious residual
[in,out]reducuResidual reduction in radial direction
[in,out]reducvResidual reduction in angular direction
[in,out]fpintuResidual sums per radial interval
[in,out]fpintvResidual sums per angular interval
[in,out]dzBoundary derivative parameters
[in]stepSearch step for boundary optimization
[in,out]lastdiLast direction of knot addition
[in,out]nplusuNumber of radial knots to add
[in,out]nplusvNumber of angular knots to add
[in,out]lasttuLast radial knot change flag
[in,out]nruRadial knot interval indices
[in,out]nrvAngular knot interval indices
[in,out]nrdatuInterior data counts per radial interval
[in,out]nrdatvInterior data counts per angular interval
[in,out]wrkWork array
[in]lwrkLength of wrk
[in,out]ierError flag
See also
Dierckx, Ch. 11, §11.1 (pp. 197-205)
fpopdi — grid computation; fppola — scattered polar fitting
Here is the call graph for this function:

◆ fppola()

pure subroutine fitpack_core::fppola ( integer(fp_size), intent(in) iopt1,
integer(fp_size), intent(in) iopt2,
integer(fp_size), intent(in) iopt3,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) u,
real(fp_real), dimension(m), intent(in) v,
real(fp_real), dimension(m), intent(in) z,
real(fp_real), dimension(m), intent(in) w,
procedure(fitpack_polar_boundary) rad,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nuest,
integer(fp_size), intent(in) nvest,
real(fp_real), intent(in) eta,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(in) ib1,
integer(fp_size), intent(in) ib3,
integer(fp_size), intent(in) nc,
integer(fp_size), intent(in) ncc,
integer(fp_size), intent(in) intest,
integer(fp_size), intent(in) nrest,
integer(fp_size), intent(inout) nu,
real(fp_real), dimension(nuest), intent(inout) tu,
integer(fp_size), intent(inout) nv,
real(fp_real), dimension(nvest), intent(inout) tv,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), intent(inout) sup,
real(fp_real), dimension(intest), intent(inout) fpint,
real(fp_real), dimension(intest), intent(inout) coord,
real(fp_real), dimension(ncc), intent(inout) f,
real(fp_real), dimension(nc), intent(inout) ff,
real(fp_real), dimension(nvest), intent(inout) row,
real(fp_real), dimension(nvest), intent(inout) cs,
real(fp_real), dimension(5,nvest), intent(inout) cosi,
real(fp_real), dimension(ncc,ib1), intent(inout) a,
real(fp_real), dimension(ncc,ib3), intent(inout) q,
real(fp_real), dimension(nuest,5), intent(inout) bu,
real(fp_real), dimension(nvest,5), intent(inout) bv,
real(fp_real), dimension(m,4), intent(inout) spu,
real(fp_real), dimension(m,4), intent(inout) spv,
real(fp_real), dimension(ib3), intent(inout) h,
integer(fp_size), dimension(nrest), intent(inout) index,
integer(fp_size), dimension(m), intent(inout) nummer,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_flag), intent(inout) ier )
private

Core algorithm for spline fitting on a polar domain.

Fits a smooth bivariate spline to data on a polar-like domain \( D = \{(x,y) : x^2 + y^2 \leq r(\theta)^2\} \) by transforming to coordinates \( (u, v) \) where \( u = r/r(\theta) \) (radial) and \( v = \theta \) (angular). The boundary function \( r(\theta) \) is user-supplied.

Continuity at the origin ( \( u = 0 \)) imposes constraints on the B-spline coefficients (Eq. 11.3-11.5):

  • \( s(0, v) \) must be independent of \( v \)
  • Derivatives at the origin must satisfy symmetry conditions

The algorithm uses the same iterative scheme as fpsurf (knot placement, QR factorization with rank-deficiency handling, smoothing search) with additional logic for origin-continuity constraints and the periodic \( v \)-direction.

Parameters
[in]iopt1Fitting option (0 = new, 1 = continue)
[in]iopt2Origin BC option (0 = free, 1 = given)
[in]iopt3Derivative BC option at origin
[in]mNumber of data points
[in]uRadial coordinates, length m
[in]vAngular coordinates, length m
[in]zData values, length m
[in]wData weights, length m
[in]radBoundary function values at data angles
[in]sSmoothing factor \( S \geq 0 \)
[in]nuestMax radial knots
[in]nvestMax angular knots
[in]etaRank-deficiency tolerance factor
[in]tolSmoothing condition tolerance
[in]maxitMaximum smoothing-parameter iterations
[in]ib1Bandwidth parameter
[in]ib3Extended bandwidth parameter
[in]ncLength of coefficient array
[in]nccAuxiliary coefficient dimension
[in]intestLength of fpint
[in]nrestLength of index
[in,out]nuNumber of radial knots
[in,out]tuRadial knot vector
[in,out]nvNumber of angular knots
[in,out]tvAngular knot vector
[in,out]cB-spline coefficients
[in,out]fpWeighted sum of squared residuals
[in,out]supUpper bound for residual
[in,out]fpintWork: residual sums per panel
[in,out]coordWork: coordinates
[in,out]fWork: RHS vector
[in,out]ffWork: RHS copy
[in,out]rowWork: observation row
[in,out]csWork: cosine values
[in,out]cosiWork: cosine integrals
[in,out]aWork: band matrix
[in,out]qWork: extended band matrix
[in,out]buWork: radial discontinuity coefficients
[in,out]bvWork: angular discontinuity coefficients
[in,out]spuWork: radial B-spline values
[in,out]spvWork: angular B-spline values
[in,out]hWork vector
[in,out]indexWork: panel sorting indices
[in,out]nummerWork: data-to-panel mapping
[in,out]wrkWork array
[in]lwrkLength of wrk
[in,out]ierError flag
See also
Dierckx, Ch. 11, §11.1 (pp. 197-205), Eq. 11.1-11.9
fprppopolar representation; fpopdipolar derivatives
Here is the call graph for this function:

◆ fprank()

pure subroutine fitpack_core::fprank ( real(fp_real), dimension(na,m), intent(out) a,
real(fp_real), dimension(n), intent(out) f,
integer(fp_size), intent(in) n,
integer(fp_size), intent(in) m,
integer(fp_size), intent(in) na,
real(fp_real), intent(in) tol,
real(fp_real), dimension(n), intent(out) c,
real(fp_real), intent(out) sq,
integer(fp_size), intent(out) rank,
real(fp_real), dimension(n,m), intent(inout) aa,
real(fp_real), dimension(n), intent(inout) ff,
real(fp_real), dimension(m), intent(inout) h )
private

Compute the minimum-norm least-squares solution under rank deficiency.

When the QR-triangularized observation matrix \( R \) has rank \( r < n \) (detected by near-zero diagonal elements \( |R_{ii}| < \varepsilon \)), the least-squares solution is not unique. This routine computes the minimum-norm B-spline coefficient vector \( \tilde{c} \) by factoring the reduced upper trapezoidal matrix \( W = [W_1 \ W_2] \) (Eq. 9.9):

Here is the call graph for this function:

◆ fprati()

elemental subroutine fitpack_core::fprati ( real(fp_real), intent(inout) p1,
real(fp_real), intent(inout) f1,
real(fp_real), intent(in) p2,
real(fp_real), intent(in) f2,
real(fp_real), intent(inout) p3,
real(fp_real), intent(inout) f3,
real(fp_real), intent(out) p )
private

Rational interpolation for the smoothing parameter search.

Given three points \( (p_1, F_1) \), \( (p_2, F_2) \), \( (p_3, F_3) \) on the curve \( F(p) \), computes the zero of the rational interpolant:

\[ R(p) = \frac{u \, p + v}{p + w} \tag{5.30} \]

that passes through the three points. The zero \( \tilde{p} \) gives the next estimate of the smoothing parameter \( p \) satisfying \( F(p) = S \) during the iterative knot-placement strategy.

When \( p_3 = \infty \) (indicated by p3 <= 0), the formula simplifies to:

\[ \tilde{p} = \frac{p_1 (F_1 - F_3)(F_2 - S) - p_2 (F_2 - F_3)(F_1 - S)} {(F_1 - F_2)(F_3 - S)} \tag{5.31} \]

On exit, \( (p_1, F_1) \) and \( (p_3, F_3) \) are updated to bracket the root: \( F_1 > 0 \) and \( F_3 < 0 \).

Parameters
[in,out]p1First abscissa; updated to maintain \( F_1 > 0 \)
[in,out]f1First ordinate; updated with \( p_1 \)
[in]p2Second abscissa (most recent iterate)
[in]f2Second ordinate \( F(p_2) - S \)
[in,out]p3Third abscissa; \( p_3 \leq 0 \) means \( p_3 = \infty \). Updated to maintain \( F_3 < 0 \).
[in,out]f3Third ordinate; updated with \( p_3 \)
[out]pThe new estimate \( \tilde{p} \)
See also
Dierckx, Ch. 5, §5.2.4 (pp. 83-86), Eq. 5.30-5.32

◆ fpregr()

pure subroutine fitpack_core::fpregr ( integer(fp_size), intent(in) iopt,
real(fp_real), dimension(mx), intent(in) x,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(my), intent(in) y,
integer(fp_size), intent(in) my,
real(fp_real), dimension(mz), intent(in) z,
integer(fp_size), intent(in) mz,
real(fp_real), intent(in) xb,
real(fp_real), intent(in) xe,
real(fp_real), intent(in) yb,
real(fp_real), intent(in) ye,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nxest,
integer(fp_size), intent(in) nyest,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(in) nc,
integer(fp_size), intent(inout) nx,
real(fp_real), dimension(nxest), intent(inout) tx,
integer(fp_size), intent(inout) ny,
real(fp_real), dimension(nyest), intent(inout) ty,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), intent(inout) fp0,
real(fp_real), intent(inout) fpold,
real(fp_real), intent(inout) reducx,
real(fp_real), intent(inout) reducy,
real(fp_real), dimension(nxest), intent(inout) fpintx,
real(fp_real), dimension(nyest), intent(inout) fpinty,
integer(fp_size), intent(inout) lastdi,
integer(fp_size), intent(inout) nplusx,
integer(fp_size), intent(inout) nplusy,
integer(fp_size), dimension(mx), intent(inout) nrx,
integer(fp_size), dimension(my), intent(inout) nry,
integer(fp_size), dimension(nxest), intent(inout) nrdatx,
integer(fp_size), dimension(nyest), intent(inout) nrdaty,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_flag), intent(inout) ier )
private

Driver for rectangular grid smoothing surface with knot selection.

Outer iteration loop for fitting a smoothing spline surface on a rectangular grid \( \{x_i\} \times \{y_j\} \). Manages the knot selection strategy (alternating between \( x \) and \( y \) directions based on residuals) and the smoothing-parameter search, delegating the grid computation to fpgrre at each step.

Parameters
[in]iopt0 = new fit, 1 = continue
[in,out]x\( x \)-grid values, length mx
[in]mxNumber of \( x \)-grid points
[in,out]y\( y \)-grid values, length my
[in]myNumber of \( y \)-grid points
[in]zData values, length mz
[in]mzLength of z
[in]xbLeft \( x \)-boundary
[in]xeRight \( x \)-boundary
[in]ybLower \( y \)-boundary
[in]yeUpper \( y \)-boundary
[in]kxDegree in \( x \)
[in]kyDegree in \( y \)
[in]sSmoothing factor \( S \geq 0 \)
[in]nxestMax \( x \)-knots
[in]nyestMax \( y \)-knots
[in]tolSmoothing condition tolerance
[in]maxitMaximum smoothing-parameter iterations
[in]ncLength of coefficient array
[in,out]nxNumber of \( x \)-knots
[in,out]tx\( x \)-knot vector
[in,out]nyNumber of \( y \)-knots
[in,out]ty\( y \)-knot vector
[in,out]cB-spline coefficients
[in,out]fpWeighted sum of squared residuals
[in,out]fp0Initial residual
[in,out]fpoldPrevious residual
[in,out]reducxResidual reduction in \( x \)
[in,out]reducyResidual reduction in \( y \)
[in,out]fpintxResidual sums per \( x \)-interval
[in,out]fpintyResidual sums per \( y \)-interval
[in,out]lastdiLast direction of knot addition
[in,out]nplusxNumber of \( x \)-knots to add
[in,out]nplusyNumber of \( y \)-knots to add
[in,out]nrx\( x \)-knot interval indices
[in,out]nry\( y \)-knot interval indices
[in,out]nrdatxInterior data counts per \( x \)-interval
[in,out]nrdatyInterior data counts per \( y \)-interval
[in,out]wrkWork array
[in]lwrkLength of wrk
[in,out]ierError flag
See also
Dierckx, Ch. 10, §10.2 (pp. 170-172), Eq. 10.4-10.8
fpgrre — grid Kronecker product computation
Here is the call graph for this function:

◆ fprota()

elemental subroutine fitpack_core::fprota ( real(fp_real), intent(in) cos,
real(fp_real), intent(in) sin,
real(fp_real), intent(inout) a,
real(fp_real), intent(inout) b )
private

Apply a Givens plane rotation to two scalars.

Given the cosine \( c \) and sine \( s \) of a Givens rotation (as computed by fpgivs), transforms a pair of values \( (a, b) \):

\[ a' = c \, a - s \, b, \qquad b' = s \, a + c \, b \tag{4.15} \]

This is used to propagate each Givens rotation through the remaining columns of the observation matrix and the right-hand side vector during QR factorization.

Parameters
[in]cosCosine of the rotation angle
[in]sinSine of the rotation angle
[in,out]aFirst element; replaced by \( c \, a - s \, b \)
[in,out]bSecond element; replaced by \( s \, a + c \, b \)
See also
Dierckx, Ch. 4, §4.1.2 (pp. 55-58), Eq. 4.15

◆ fprppo()

pure subroutine fitpack_core::fprppo ( integer(fp_size), intent(in) nu,
integer(fp_size), intent(in) nv,
integer(fp_size), intent(in) if1,
integer(fp_size), intent(in) if2,
real(fp_real), dimension(5,nv), intent(in) cosi,
real(fp_real), intent(in) ratio,
real(fp_real), dimension(ncoff), intent(inout) c,
real(fp_real), dimension(ncoff), intent(inout) f,
integer(fp_size), intent(in) ncoff )
private

Convert constrained polar spline coefficients to standard form.

Transforms the coefficients of a constrained bicubic spline (as computed by fppola with origin-continuity constraints) into the standard B-spline coefficient representation. The constrained form encodes the origin conditions via cosine-weighted combinations; this routine expands them into independent coefficients.

Parameters
[in]nuNumber of radial knots
[in]nvNumber of angular knots
[in]if1Origin constraint type (position)
[in]if2Origin constraint type (derivative)
[in]cosiCosine integral values
[in]ratioKnot ratio for origin constraint
[in,out]cConstrained coefficients on entry; work on exit
[in,out]fStandard B-spline coefficients on exit
[in]ncoffNumber of coefficients
See also
Dierckx, Ch. 11, §11.1 (pp. 197-205), Eq. 11.3-11.5
fppolapolar fitting; fprpsp — spherical variant

◆ fprpsp()

pure subroutine fitpack_core::fprpsp ( integer(fp_size), intent(in) nt,
integer(fp_size), intent(in) np,
real(fp_real), dimension(np), intent(in) co,
real(fp_real), dimension(np), intent(in) si,
real(fp_real), dimension(ncoff), intent(inout) c,
real(fp_real), dimension(ncoff), intent(inout) f,
integer(fp_size), intent(in) ncoff )
private

Convert constrained spherical spline coefficients to standard form.

Transforms the coefficients of a constrained bicubic spline (as computed by fpsphe with pole-continuity constraints) into the standard B-spline coefficient representation. The constrained form encodes pole conditions via cosine/sine-weighted combinations at \( \theta = 0 \) and \( \theta = \pi \).

Parameters
[in]ntNumber of \( \theta \)-knots
[in]npNumber of \( \phi \)-knots
[in]coCosine values for pole constraints
[in]siSine values for pole constraints
[in,out]cConstrained coefficients on entry; work on exit
[in,out]fStandard B-spline coefficients on exit
[in]ncoffNumber of coefficients
See also
Dierckx, Ch. 11, §11.2 (pp. 205-213), Eq. 11.14-11.16
fpsphe — spherical fitting; fprppopolar variant

◆ fpseno()

pure subroutine fitpack_core::fpseno ( integer(fp_size), intent(in) maxtr,
integer(fp_size), dimension(maxtr), intent(in) up,
integer(fp_size), dimension(maxtr), intent(in) left,
integer(fp_size), dimension(maxtr), intent(in) right,
integer(fp_size), dimension(maxtr), intent(in) info,
integer(fp_size), intent(inout) merk,
integer(fp_size), dimension(nbind), intent(out) ibind,
integer(fp_size), intent(in) nbind )
private

Fetch and advance to the next branch in the constraint-set tree.

Extracts the constraint indices of the branch ending at terminal node merk (length nbind) into the array ibind(1:nbind). Then advances merk to point to the next branch of the same length, or sets merk = 1 if no further branch exists.

Used by the Theil-Van de Panne procedure (§7.2) to enumerate candidate active-constraint sets level by level.

Parameters
[in]maxtrSize of the tree arrays
[in]upParent pointers
[in]leftLeft-child pointers
[in]rightRight-child pointers
[in]infoConstraint index stored at each node
[in,out]merkOn entry, terminal node of the branch to fetch. On exit, terminal node of the next branch of length nbind, or 1 if none.
[out]ibindConstraint indices of the fetched branch, length nbind
[in]nbindRequired branch length
See also
Dierckx, Ch. 7, §7.2.4 (pp. 125-130)
fpadno, fpdeno, fpfrno — companion tree operations

◆ fpspgr()

pure subroutine fitpack_core::fpspgr ( integer(fp_size), dimension(3), intent(in) iopt,
integer(fp_size), dimension(4), intent(in) ider,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mv), intent(in) v,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mr), intent(in) r,
integer(fp_size), intent(in) mr,
real(fp_real), intent(in) r0,
real(fp_real), intent(in) r1,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nuest,
integer(fp_size), intent(in) nvest,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(in) nc,
integer(fp_size), intent(inout) nu,
real(fp_real), dimension(nuest), intent(inout) tu,
integer(fp_size), intent(inout) nv,
real(fp_real), dimension(nvest), intent(inout) tv,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), intent(inout) fp0,
real(fp_real), intent(inout) fpold,
real(fp_real), intent(inout) reducu,
real(fp_real), intent(inout) reducv,
real(fp_real), dimension(nuest), intent(inout) fpintu,
real(fp_real), dimension(nvest), intent(inout) fpintv,
real(fp_real), dimension(6), intent(inout) dr,
real(fp_real), dimension(2), intent(inout) step,
integer(fp_size), intent(inout) lastdi,
integer(fp_size), intent(inout) nplusu,
integer(fp_size), intent(inout) nplusv,
integer(fp_size), intent(inout) lastu0,
integer(fp_size), intent(inout) lastu1,
integer(fp_size), dimension(mu), intent(inout) nru,
integer(fp_size), dimension(mv), intent(inout) nrv,
integer(fp_size), dimension(nuest), intent(inout) nrdatu,
integer(fp_size), dimension(nvest), intent(inout) nrdatv,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_flag), intent(out) ier )
private

Driver for spherical grid smoothing spline with knot selection.

Outer iteration loop for fitting a smoothing spline on a spherical grid. Manages knot selection in \( \theta \) and \( \phi \) directions and the smoothing-parameter search, delegating grid computation to fpopsp. Handles pole constraints at both \( \theta = 0 \) and \( \theta = \pi \).

Parameters
[in]ioptFitting options
[in]iderDerivative specification flags
[in]uCo-latitude grid \( \theta \), length mu
[in]muNumber of \( \theta \)-points
[in]vLongitude grid \( \phi \), length mv
[in]mvNumber of \( \phi \)-points
[in]rData values, length mr
[in]mrLength of r
[in]r0North-pole value
[in]r1South-pole value
[in]sSmoothing factor \( S \geq 0 \)
[in]nuestMax \( \theta \)-knots
[in]nvestMax \( \phi \)-knots
[in]tolSmoothing condition tolerance
[in]maxitMaximum smoothing-parameter iterations
[in]ncLength of coefficient array
[in,out]nuNumber of \( \theta \)-knots
[in,out]tu\( \theta \)-knot vector
[in,out]nvNumber of \( \phi \)-knots
[in,out]tv\( \phi \)-knot vector
[in,out]cB-spline coefficients
[in,out]fpWeighted sum of squared residuals
[in,out]fp0Initial residual
[in,out]fpoldPrevious residual
[in,out]reducuResidual reduction in \( \theta \)
[in,out]reducvResidual reduction in \( \phi \)
[in,out]fpintuResidual sums per \( \theta \)-interval
[in,out]fpintvResidual sums per \( \phi \)-interval
[in,out]drPole derivative parameters
[in]stepSearch step for pole parameter optimization
[in,out]lastdiLast direction of knot addition
[in,out]nplusuNumber of \( \theta \)-knots to add
[in,out]nplusvNumber of \( \phi \)-knots to add
[in,out]lastu0Last north-pole knot change flag
[in,out]lastu1Last south-pole knot change flag
[in,out]nru\( \theta \)-knot interval indices
[in,out]nrv\( \phi \)-knot interval indices
[in,out]nrdatuInterior data counts per \( \theta \)-interval
[in,out]nrdatvInterior data counts per \( \phi \)-interval
[in,out]wrkWork array
[in]lwrkLength of wrk
[in,out]ierError flag
See also
Dierckx, Ch. 11, §11.2 (pp. 205-213)
fpopsp — grid computation; fpsphe — scattered spherical fitting
Here is the call graph for this function:

◆ fpsphe()

pure subroutine fitpack_core::fpsphe ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) teta,
real(fp_real), dimension(m), intent(in) phi,
real(fp_real), dimension(m), intent(in) r,
real(fp_real), dimension(m), intent(in) w,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) ntest,
integer(fp_size), intent(in) npest,
real(fp_real), intent(in) eta,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(in) ib1,
integer(fp_size), intent(in) ib3,
integer(fp_size), intent(in) nc,
integer(fp_size), intent(in) ncc,
integer(fp_size), intent(in) intest,
integer(fp_size), intent(in) nrest,
integer(fp_size), intent(inout) nt,
real(fp_real), dimension(ntest), intent(inout) tt,
integer(fp_size), intent(inout) np,
real(fp_real), dimension(npest), intent(inout) tp,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), intent(inout) sup,
real(fp_real), dimension(intest), intent(inout) fpint,
real(fp_real), dimension(intest), intent(inout) coord,
real(fp_real), dimension(ncc), intent(inout) f,
real(fp_real), dimension(nc), intent(inout) ff,
real(fp_real), dimension(npest), intent(inout) row,
real(fp_real), dimension(npest), intent(inout) coco,
real(fp_real), dimension(npest), intent(inout) cosi,
real(fp_real), dimension(ncc,ib1), intent(inout) a,
real(fp_real), dimension(ncc,ib3), intent(inout) q,
real(fp_real), dimension(ntest,5), intent(inout) bt,
real(fp_real), dimension(npest,5), intent(inout) bp,
real(fp_real), dimension(m,4), intent(inout) spt,
real(fp_real), dimension(m,4), intent(inout) spp,
real(fp_real), dimension(ib3), intent(inout) h,
integer(fp_size), dimension(nrest), intent(inout) index,
integer(fp_size), dimension(m), intent(inout) nummer,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_flag), intent(out) ier )
private

Core algorithm for spline fitting on the sphere.

Fits a smooth bivariate spline to data on the unit sphere using coordinates \( (\theta, \phi) \) where \( \theta \in [0, \pi] \) is co-latitude and \( \phi \in [0, 2\pi) \) is longitude. The spline is periodic in \( \phi \) and must satisfy pole-continuity conditions at \( \theta = 0 \) and \( \theta = \pi \) (Eq. 11.12):

\[ s(0, \phi) = \text{const}, \quad s(\pi, \phi) = \text{const} \tag{11.12} \]

with derivative conditions analogous to the polar case (Eq. 11.14-11.16). The algorithm follows the same iterative framework as fpsurf with additional handling for pole constraints and the periodic \( \phi \)-direction.

Parameters
[in]iopt0 = new fit, 1 = continue
[in]mNumber of data points
[in]tetaCo-latitude values \( \theta \), length m
[in]phiLongitude values \( \phi \), length m
[in]rData values, length m
[in]wData weights, length m
[in]sSmoothing factor \( S \geq 0 \)
[in]ntestMax \( \theta \)-knots
[in]npestMax \( \phi \)-knots
[in]etaRank-deficiency tolerance factor
[in]tolSmoothing condition tolerance
[in]maxitMaximum smoothing-parameter iterations
[in]ib1Bandwidth parameter
[in]ib3Extended bandwidth parameter
[in]ncLength of coefficient array
[in]nccAuxiliary coefficient dimension
[in]intestLength of fpint
[in]nrestLength of index
[in,out]ntNumber of \( \theta \)-knots
[in,out]tt\( \theta \)-knot vector
[in,out]npNumber of \( \phi \)-knots
[in,out]tp\( \phi \)-knot vector
[in,out]cB-spline coefficients
[in,out]fpWeighted sum of squared residuals
[in,out]supUpper bound for residual
[in,out]fpintWork: residual sums per panel
[in,out]coordWork: coordinates
[in,out]fWork: RHS vector
[in,out]ffWork: RHS copy
[in,out]rowWork: observation row
[in,out]cocoWork: cosine values for pole constraints
[in,out]cosiWork: cosine integrals for pole constraints
[in,out]aWork: band matrix
[in,out]qWork: extended band matrix
[in,out]btWork: \( \theta \)-discontinuity coefficients
[in,out]bpWork: \( \phi \)-discontinuity coefficients
[in,out]sptWork: \( \theta \)-B-spline values
[in,out]sppWork: \( \phi \)-B-spline values
[in,out]hWork vector
[in,out]indexWork: panel sorting indices
[in,out]nummerWork: data-to-panel mapping
[in,out]wrkWork array
[in]lwrkLength of wrk
[out]ierError flag
See also
Dierckx, Ch. 11, §11.2 (pp. 205-213), Eq. 11.12-11.16
fprpsp — spherical representation; fpopsp — spherical operations
Here is the call graph for this function:

◆ fpsuev()

pure subroutine fitpack_core::fpsuev ( integer(fp_size), intent(in) idim,
real(fp_real), dimension(nu), intent(in) tu,
integer(fp_size), intent(in) nu,
real(fp_real), dimension(nv), intent(in) tv,
integer(fp_size), intent(in) nv,
real(fp_real), dimension((nu-4)*(nv-4)*idim), intent(in) c,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mv), intent(in) v,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mu*mv*idim), intent(out) f,
real(fp_real), dimension(mu,4), intent(out) wu,
real(fp_real), dimension(mv,4), intent(out) wv,
integer(fp_size), dimension(mu), intent(out) lu,
integer(fp_size), dimension(mv), intent(out) lv )
private

Evaluate a parametric bicubic tensor-product spline surface.

Computes the values of a \( d \)-dimensional bicubic spline surface \( (s_1(u,v), \ldots, s_d(u,v)) \) at the grid points \( (u_i, v_j) \), \( i = 1, \ldots, m_u \), \( j = 1, \ldots, m_v \).

For each dimension, the evaluation uses the tensor-product decomposition:

\[ s(u, v) = \sum_{i} \left( \sum_{j} c_{i,j} \, M_{j,4}(v) \right) N_{i,4}(u) \]

This is the computational core called by surev after input validation.

Parameters
[in]idimNumber of coordinate dimensions
[in]tuKnot vector in \( u \), length nu
[in]nuNumber of knots in \( u \)
[in]tvKnot vector in \( v \), length nv
[in]nvNumber of knots in \( v \)
[in]cB-spline coefficients, length (nu-4)*(nv-4)*idim
[in]uEvaluation points in \( u \), length mu
[in]muNumber of evaluation points in \( u \)
[in]vEvaluation points in \( v \), length mv
[in]mvNumber of evaluation points in \( v \)
[out]fSurface values, length mu * mv * idim
[out]wuB-spline basis values in \( u \), wu(mu, 4)
[out]wvB-spline basis values in \( v \), wv(mv, 4)
[out]luKnot interval indices in \( u \), length mu
[out]lvKnot interval indices in \( v \), length mv
See also
Dierckx, Ch. 2, §2.1.2 (pp. 28-30), Eq. 2.14-2.17
Here is the call graph for this function:

◆ fpsurf()

pure subroutine fitpack_core::fpsurf ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(inout) x,
real(fp_real), dimension(m), intent(inout) y,
real(fp_real), dimension(m), intent(in) z,
real(fp_real), dimension(m), intent(in) w,
real(fp_real), intent(in) xb,
real(fp_real), intent(in) xe,
real(fp_real), intent(in) yb,
real(fp_real), intent(in) ye,
integer(fp_size), intent(in) kxx,
integer(fp_size), intent(in) kyy,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nxest,
integer(fp_size), intent(in) nyest,
real(fp_real), intent(in) eta,
real(fp_real), intent(in) tol,
integer(fp_size), intent(in) maxit,
integer(fp_size), intent(in) nmax,
integer(fp_size), intent(in) km1,
integer(fp_size), intent(in) km2,
integer(fp_size), intent(in) ib1,
integer(fp_size), intent(in) ib3,
integer(fp_size), intent(in) nc,
integer(fp_size), intent(in) intest,
integer(fp_size), intent(in) nrest,
integer(fp_size), intent(inout) nx0,
real(fp_real), dimension(nmax), intent(inout) tx,
integer(fp_size), intent(inout) ny0,
real(fp_real), dimension(nmax), intent(inout) ty,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), intent(inout) fp0,
real(fp_real), dimension(intest), intent(inout) fpint,
real(fp_real), dimension(intest), intent(inout) coord,
real(fp_real), dimension(nc), intent(inout) f,
real(fp_real), dimension(nc), intent(inout) ff,
real(fp_real), dimension(nc,ib1), intent(inout) a,
real(fp_real), dimension(nc,ib3), intent(inout) q,
real(fp_real), dimension(nmax,km2), intent(inout) bx,
real(fp_real), dimension(nmax,km2), intent(inout) by,
real(fp_real), dimension(m,km1), intent(inout) spx,
real(fp_real), dimension(m,km1), intent(inout) spy,
real(fp_real), dimension(ib3), intent(inout) h,
integer(fp_size), dimension(nrest), intent(inout) index,
integer(fp_size), dimension(m), intent(inout) nummer,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_flag), intent(inout) ier )
private

Core algorithm for bivariate tensor-product spline surface fitting.

Fits a tensor-product spline surface \( s(x,y) \) of degrees \( k_x \) and \( k_y \) to scattered data by minimizing:

\[ \sum_{i=1}^{m} \bigl( w_i (z_i - s(x_i, y_i)) \bigr)^2 \leq S \tag{9.2} \]

The B-spline representation has \( (g+k_x+1)(h+k_y+1) \) coefficients on the knot grid \( \{t_x\} \times \{t_y\} \). The algorithm iterates:

  1. Knot placement in \( x \) and \( y \) based on residuals
  2. QR factorization of the observation matrix via Givens rotations, with rank-deficiency handling via fprank (Eq. 9.7-9.10)
  3. Smoothing-parameter search via rational interpolation

Data points are sorted into knot-interval panels using fporde for efficient row-by-row processing.

Parameters
[in]iopt0 = new fit, 1 = continue
[in]mNumber of data points
[in,out]xData \( x \)-coordinates, length m
[in,out]yData \( y \)-coordinates, length m
[in]zData values, length m
[in]wData weights, length m
[in]xbLeft \( x \)-boundary
[in]xeRight \( x \)-boundary
[in]ybLower \( y \)-boundary
[in]yeUpper \( y \)-boundary
[in]kxxDegree in \( x \)
[in]kyyDegree in \( y \)
[in]sSmoothing factor \( S \geq 0 \)
[in]nxestMax knots in \( x \)
[in]nyestMax knots in \( y \)
[in]etaRank-deficiency tolerance factor
[in]tolSmoothing condition tolerance
[in]maxitMaximum smoothing-parameter iterations
[in]nmaxMax of nxest, nyest
[in]km1\( \max(k_x, k_y) + 1 \)
[in]km2\( k_x + k_y + 2 \)
[in]ib1\( k_x k_y + 2 \)
[in]ib3\( k_x k_y + \max(k_x, k_y) + 2 \)
[in]ncLength of coefficient array
[in]intestLength of fpint
[in]nrestLength of index
[in,out]nx0Number of \( x \)-knots
[in,out]tx\( x \)-knot vector
[in,out]ny0Number of \( y \)-knots
[in,out]ty\( y \)-knot vector
[in,out]cB-spline coefficients
[in,out]fpWeighted sum of squared residuals
[in,out]fp0Initial unweighted residual sum
[in,out]fpintWork: residual sums per panel
[in,out]coordWork: coordinates
[in,out]fWork: RHS vector
[in,out]ffWork: RHS copy
[in,out]aWork: band matrix
[in,out]qWork: extended band matrix
[in,out]bxWork: \( x \)-discontinuity coefficients
[in,out]byWork: \( y \)-discontinuity coefficients
[in,out]spxWork: \( x \)-B-spline values
[in,out]spyWork: \( y \)-B-spline values
[in,out]hWork vector
[in,out]indexWork: panel sorting indices
[in,out]nummerWork: data-to-panel mapping
[in,out]wrkWork array
[in]lwrkLength of wrk
[in,out]ierError flag
See also
Dierckx, Ch. 9, §9.1-9.2 (pp. 147-167), Eq. 9.2-9.10
fporde — panel sorting; fprank — rank-deficient solver
Here is the call graph for this function:

◆ fpsysy()

pure subroutine fitpack_core::fpsysy ( real(fp_real), dimension(6,6), intent(inout) a,
integer(fp_size), intent(in) n,
real(fp_real), dimension(6), intent(inout) g )
private

Solve a small symmetric linear system by Cholesky factorization.

Solves the \( n \times n \) symmetric positive definite system \( A \, b = g \) with \( n \leq 6 \) using Cholesky decomposition. On exit, g contains the solution \( b \).

Used by fpopdi and fpopsp for the small optimization problems that determine the optimal origin/pole boundary parameters.

Parameters
[in,out]aSymmetric matrix, dimension (6, 6). Only the first n rows and columns are used.
[in]nSystem dimension ( \( n \leq 6 \))
[in,out]gOn entry, right-hand side. On exit, solution.

◆ fptrnp()

pure subroutine fitpack_core::fptrnp ( integer(fp_size), intent(in) m,
integer(fp_size), intent(in) mm,
integer(fp_size), intent(in) idim,
integer(fp_size), intent(in) n,
integer(fp_size), dimension(m), intent(in) nr,
real(fp_real), dimension(m,4), intent(in) sp,
real(fp_real), intent(in) p,
real(fp_real), dimension(n,5), intent(in) b,
real(fp_real), dimension(m*mm*idim), intent(in) z,
real(fp_real), dimension(n,5), intent(out) a,
real(fp_real), dimension((n-4)*mm*idim), intent(out) q,
real(fp_real), dimension(mm*idim), intent(out) right )
private

Triangularize the tensor-product system for non-periodic grids.

Reduces the \( (m + n - 7) \times (n - 4) \) augmented observation matrix to upper triangular form using Givens rotations (Eq. 10.8), simultaneously transforming the \( m \times mm \times d \) data matrix \( Z \) into the \( (n-4) \times mm \times d \) RHS matrix \( Q \). Used in the second phase of the Kronecker product decomposition for parametric grid surfaces (fppasu via fpgrpa).

Parameters
[in]mNumber of grid points in this direction
[in]mmNumber of columns in the RHS (other direction size)
[in]idimNumber of surface dimensions \( d \)
[in]nNumber of knots in this direction
[in]nrKnot interval indices, length m
[in]spB-spline values at grid points, (m, 4)
[in]pSmoothing parameter
[in]bDiscontinuity jump matrix, (n, 5)
[in]zData matrix, length \( m \cdot mm \cdot d \)
[out]aTriangularized band matrix, (n, 5)
[out]qTransformed RHS, length \( (n-4) \cdot mm \cdot d \)
[out]rightWork: RHS row vector, length \( mm \cdot d \)
See also
Dierckx, Ch. 10, §10.2 (pp. 170-172), Eq. 10.8
fptrpe — periodic variant; fp_rotate_row_stride — stride rotation
Here is the call graph for this function:

◆ fptrpe()

pure subroutine fitpack_core::fptrpe ( integer(fp_size), intent(in) m,
integer(fp_size), intent(in) mm,
integer(fp_size), intent(in) idim,
integer(fp_size), intent(in) n,
integer(fp_size), dimension(m), intent(in) nr,
real(fp_real), dimension(m,4), intent(in) sp,
real(fp_real), intent(in) p,
real(fp_real), dimension(n,5), intent(in) b,
real(fp_real), dimension(m*mm*idim), intent(in) z,
real(fp_real), dimension(n,5), intent(out) a,
real(fp_real), dimension(n,4), intent(out) aa,
real(fp_real), dimension((n-7)*mm*idim), intent(out) q,
real(fp_real), dimension(mm*idim), intent(out) right )
private

Triangularize the tensor-product system for periodic grids.

Periodic variant of fptrnp. Reduces the \( (m + n - 7) \times (n - 7) \) cyclic band matrix to upper triangular form using two-matrix Givens rotations (fp_rotate_2mat_stride), simultaneously transforming the data matrix \( Z \) into the RHS matrix \( Q \). The periodicity wraps the last columns into the first, creating the block-triangular structure stored in a (main) and aa (periodic block).

Parameters
[in]mNumber of grid points in this direction
[in]mmNumber of columns in the RHS
[in]idimNumber of surface dimensions \( d \)
[in]nNumber of knots in this direction
[in]nrKnot interval indices, length m
[in]spB-spline values at grid points, (m, 4)
[in]pSmoothing parameter
[in]bDiscontinuity jump matrix, (n, 5)
[in]zData matrix, length \( m \cdot mm \cdot d \)
[out]aTriangularized band matrix (main block), (n, 5)
[out]aaTriangularized periodic block, (n, 4)
[out]qTransformed RHS, length \( (n-7) \cdot mm \cdot d \)
[out]rightWork: RHS row vector, length \( mm \cdot d \)
See also
Dierckx, Ch. 10, §10.2 (pp. 170-172), Eq. 10.8 (periodic)
fptrnp — non-periodic variant; fp_rotate_2mat_stride — periodic rotation
Here is the call graph for this function:

◆ get_smoothing()

subroutine, public fitpack_core::get_smoothing ( real(fp_real), intent(in) old_smoothing,
real(fp_real), intent(in), optional user_smoothing,
integer(fp_size), intent(out) nit,
real(fp_real), dimension(3), intent(out) smooth_now )

Choose the smoothing parameter(s) for an iterative fit.

Selects one or more values of the smoothing factor \( s \) for the next fitting iteration(s). If a user-supplied value is present it is used directly; if a previous value exists it is re-used; otherwise a default decreasing trajectory is applied.

Parameters
[in]old_smoothingPrevious smoothing factor.
[in]user_smoothingOptional user-supplied value.
[out]nitNumber of smoothing iterations to perform.
[out]smooth_nowArray of 3 smoothing values for the iterations.

◆ insert()

pure subroutine, public fitpack_core::insert ( integer(fp_size), intent(in) iopt,
real(fp_real), dimension(nest), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(nest), intent(in) c,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) x,
real(fp_real), dimension(nest), intent(out) tt,
integer(fp_size), intent(out) nn,
real(fp_real), dimension(nest), intent(out) cc,
integer(fp_size), intent(in) nest,
integer(fp_flag), intent(out) ier )

Insert a single knot into a spline, returning a new B-spline representation.

Inserts the knot \( x \) into the B-spline representation of \( s(x) \) using the Boehm knot insertion algorithm. The spline itself is unchanged; only its representation (knots and coefficients) is updated.

Can be called with output arrays aliased to input arrays to replace the representation in place: call insert(iopt,t,n,c,k,x,t,n,c,nest,ier).

Parameters
[in]ioptPeriodicity flag: 0 = non-periodic; /=0 = periodic spline.
[in]tInput knot positions (length nest).
[in]nNumber of knots before insertion.
[in]cInput B-spline coefficients (length nest).
[in]kDegree of the spline.
[in]xLocation of the knot to insert. Must satisfy \( t_{k+1} \le x \le t_{n-k} \).
[out]ttOutput knot positions (length nest).
[out]nnNumber of knots after insertion ( \( n + 1 \)).
[out]ccOutput B-spline coefficients (length nest).
[in]nestArray dimension. Must satisfy nest > n.
[out]ierError flag: 0 = normal return; 10 = invalid input.
See also
Dierckx, Ch. 1, §1.3.4 (pp. 13–14), Eq. 1.46–1.48; fpinst — knot insertion kernel
Here is the call graph for this function:

◆ insert_inplace()

pure subroutine, public fitpack_core::insert_inplace ( integer(fp_size), intent(in) iopt,
real(fp_real), dimension(nest), intent(inout) t,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) c,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) x,
integer(fp_size), intent(in) nest,
integer(fp_flag), intent(out) ier )

Insert a single knot into a spline in place (avoiding aliasing issues).

Wrapper around insert that uses temporary arrays to safely update the knot and coefficient arrays in place, avoiding the aliasing of input/output arguments present in the original Fortran 77 calling convention.

Parameters
[in]ioptPeriodicity flag: 0 = non-periodic; /=0 = periodic.
[in,out]tKnot positions (length nest). Updated on exit.
[in,out]nNumber of knots. Updated to \( n + 1 \) on exit.
[in,out]cB-spline coefficients (length nest). Updated on exit.
[in]kDegree of the spline.
[in]xLocation of the knot to insert.
[in]nestArray dimension. Must satisfy nest > n.
[out]ierError flag: 0 = normal return; 10 = invalid input.
See also
insert — non-aliased variant
Here is the call graph for this function:

◆ iopt_message()

pure character(len=:) function, allocatable, public fitpack_core::iopt_message ( integer(fp_flag), intent(in) iopt)

Convert an iopt computation-mode flag to a human-readable string.

Parameters
[in]ioptComputation mode flag (-1 = Least-Squares, 0 = Smoothing, 1 = Old).
Returns
Allocatable character string describing the mode.

◆ is_after()

elemental logical(fp_bool) function fitpack_core::is_after ( real(fp_real), intent(in) a,
real(fp_real), intent(in) b )
private

Test \( a > b \) (strict greater-than).

Here is the call graph for this function:

◆ is_before()

elemental logical(fp_bool) function fitpack_core::is_before ( real(fp_real), intent(in) a,
real(fp_real), intent(in) b )
private

Test \( a < b \) (strict less-than).

Here is the call graph for this function:

◆ is_ge()

elemental logical(fp_bool) function fitpack_core::is_ge ( real(fp_real), intent(in) a,
real(fp_real), intent(in) b )
private

Test \( a \ge b \).

Here is the call graph for this function:

◆ is_le()

elemental logical(fp_bool) function fitpack_core::is_le ( real(fp_real), intent(in) a,
real(fp_real), intent(in) b )
private

Test \( a \le b \).

Here is the call graph for this function:

◆ new_knot_dimension()

elemental integer function fitpack_core::new_knot_dimension ( integer(fp_size), intent(in) n1,
integer(fp_size), intent(in) n1add,
integer(fp_size), intent(in) n1max,
integer(fp_size), intent(in) n2,
integer(fp_size), intent(in) n2add,
integer(fp_size), intent(in) n2max,
integer(fp_size), intent(in) last )
private

Choose which dimension receives the next knot during bivariate fitting.

Selects whether to add a knot in dimension 1 or 2, balancing knot insertion across dimensions. Prefers dimension 2 when it has fewer added knots, unless dimension 1 is at its maximum or no knot has been added yet.

Parameters
[in]n1Current number of knots in dimension 1
[in]n1addNumber of knots added to dimension 1 this iteration
[in]n1maxMaximum allowed knots in dimension 1
[in]n2Current number of knots in dimension 2
[in]n2addNumber of knots added to dimension 2 this iteration
[in]n2maxMaximum allowed knots in dimension 2
[in]lastLast dimension a knot was added to (KNOT_DIM_1, KNOT_DIM_2, or KNOT_DIM_NONE)
Returns
KNOT_DIM_1 or KNOT_DIM_2

◆ not_equal()

elemental logical(fp_bool) function fitpack_core::not_equal ( real(fp_real), intent(in) a,
real(fp_real), intent(in) b )
private

Test whether two reals differ beyond machine precision.

Here is the call graph for this function:

◆ parcur()

pure subroutine, public fitpack_core::parcur ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) ipar,
integer(fp_size), intent(in) idim,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(inout) u,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(idim,m), intent(in) x,
real(fp_real), dimension(m), intent(inout) w,
real(fp_real), intent(inout) ub,
real(fp_real), intent(inout) ue,
integer(fp_size), intent(in) k,
real(fp_real), intent(inout) s,
integer(fp_size), intent(in) nest,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
integer(fp_size), intent(in) nc,
real(fp_real), dimension(nc), intent(inout) c,
real(fp_real), intent(out) fp,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(nest), intent(inout) iwrk,
integer(fp_flag), intent(out) ier )

Determine a smooth parametric spline curve approximation.

Given \( m \) ordered points \( \mathbf{x}_i \in \mathbb{R}^{\text{idim}} \) with weights \( w_i > 0 \) and parameter values \( u_i \), computes an open parametric spline curve \( \mathbf{s}(u) = (s_1(u),\ldots,s_{\text{idim}}(u)) \) of degree \( k \) on \( [u_b, u_e] \).

If ipar=0, parameter values are computed automatically from cumulative chord lengths: \( u_i = v_i / v_m \) where \( v_i = v_{i-1} + \|\mathbf{x}_i - \mathbf{x}_{i-1}\| \), with \( u_b = 0 \) and \( u_e = 1 \).

Smoothness is controlled by requiring \( F(p) = \sum w_i^2 \|\mathbf{x}_i - \mathbf{s}(u_i)\|^2 \le S \).

Parameters
[in]ioptComputation mode: -1 (LSQ), 0 (new smoothing), 1 (continue).
[in]iparParameter mode: 0 = automatic, 1 = user-supplied.
[in]idimDimension of the curve, \( 1 \le \text{idim} \le 10 \).
[in]mNumber of data points, \( m > k \).
[in,out]uParameter values (length \( m \)). Output when ipar=0.
[in]mxDeclared dimension of x, \( \ge \text{idim} \times m \).
[in]xData coordinates (length mx): x(idim*(i-1)+j) = \( j \)-th coordinate of point \( i \).
[in,out]wWeights (length \( m \)), strictly positive.
[in,out]ubLower parameter bound. Set to 0 when ipar=0.
[in,out]ueUpper parameter bound. Set to 1 when ipar=0.
[in]kSpline degree, \( 1 \le k \le 5 \). Cubic recommended.
[in,out]sSmoothing factor \( S \ge 0 \).
[in]nestOver-estimate of total knots. nest=m+k+1 always suffices.
[in,out]nTotal number of knots.
[in,out]tKnot positions (length nest).
[in]ncDeclared dimension of c, \( \ge \text{nest} \times \text{idim} \).
[in,out]cB-spline coefficients (length nc).
[out]fpWeighted sum of squared residuals.
[in,out]wrkReal workspace, length \( \ge m(k+1) + \text{nest}(6+\text{idim}+3k) \).
[in]lwrkDeclared dimension of wrk.
[in,out]iwrkInteger workspace (length nest).
[out]ierError flag (same codes as curfit).
See also
Dierckx, Ch. 6, §6.3; fppara — core parametric fitting algorithm
Here is the call graph for this function:

◆ parder()

pure subroutine, public fitpack_core::parder ( real(fp_real), dimension(nx), intent(in) tx,
integer(fp_size), intent(in) nx,
real(fp_real), dimension(ny), intent(in) ty,
integer(fp_size), intent(in) ny,
real(fp_real), dimension((nx-kx-1)*(ny-ky-1)), intent(in) c,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
integer(fp_size), intent(in) nux,
integer(fp_size), intent(in) nuy,
real(fp_real), dimension(mx), intent(in) x,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(my), intent(in) y,
integer(fp_size), intent(in) my,
real(fp_real), dimension(mx*my), intent(out) z,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Evaluate a partial derivative of a bivariate spline on a rectangular grid.

Computes the partial derivative \( \frac{\partial^{\nu_x+\nu_y}}{\partial x^{\nu_x}\,\partial y^{\nu_y}} s(x,y) \) of a bivariate spline of degrees \( k_x \) and \( k_y \) on the grid \( (x_i, y_j) \), \( i=1,\ldots,m_x;\ j=1,\ldots,m_y \).

Here is the call graph for this function:

◆ pardeu()

pure subroutine, public fitpack_core::pardeu ( real(fp_real), dimension(nx), intent(in) tx,
integer(fp_size), intent(in) nx,
real(fp_real), dimension(ny), intent(in) ty,
integer(fp_size), intent(in) ny,
real(fp_real), dimension((nx-kx-1)*(ny-ky-1)), intent(in) c,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
integer(fp_size), intent(in) nux,
integer(fp_size), intent(in) nuy,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(m), intent(out) z,
integer(fp_size), intent(in) m,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_size), intent(out) ier )

Evaluate a partial derivative of a bivariate spline at scattered points.

Computes \( \frac{\partial^{\nu_x+\nu_y}}{\partial x^{\nu_x}\,\partial y^{\nu_y}} s(x_i,y_i) \) for \( i=1,\ldots,m \) at arbitrary (unstructured) points. This is the scattered-point counterpart of parder, which evaluates on a rectangular grid.

Parameters
[in]txKnot positions in \( x \)-direction (length \( n_x \)).
[in]nxTotal number of knots in \( x \).
[in]tyKnot positions in \( y \)-direction (length \( n_y \)).
[in]nyTotal number of knots in \( y \).
[in]cB-spline coefficients, length \( (n_x{-}k_x{-}1)(n_y{-}k_y{-}1) \).
[in]kxDegree in \( x \).
[in]kyDegree in \( y \).
[in]nuxDerivative order in \( x \), \( 0 \le \nu_x < k_x \).
[in]nuyDerivative order in \( y \), \( 0 \le \nu_y < k_y \).
[in]x\( x \)-coordinates of evaluation points (length \( m \)).
[in]y\( y \)-coordinates of evaluation points (length \( m \)).
[out]zDerivative values (length \( m \)).
[in]mNumber of evaluation points, \( m \ge 1 \).
[in,out]wrkReal workspace, length \( \ge m(k_x{+}1{-}\nu_x) + m(k_y{+}1{-}\nu_y) + (n_x{-}k_x{-}1)(n_y{-}k_y{-}1) \).
[in]lwrkDeclared dimension of wrk.
[in,out]iwrkInteger workspace (length \( \ge 2m \)).
[in]kwrkDeclared dimension of iwrk.
[out]ierError flag: 0 = normal return; 10 = invalid input.
See also
parder — grid variant; pardtc — coefficient transformation only; de Boor (1972), J. Approx. Theory 6, 50–62
Here is the call graph for this function:

◆ pardtc()

pure subroutine, public fitpack_core::pardtc ( real(fp_real), dimension(nx), intent(in) tx,
integer(fp_size), intent(in) nx,
real(fp_real), dimension(ny), intent(in) ty,
integer(fp_size), intent(in) ny,
real(fp_real), dimension((nx-kx-1)*(ny-ky-1)), intent(in) c,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
integer(fp_size), intent(in) nux,
integer(fp_size), intent(in) nuy,
real(fp_real), dimension((nx-kx-1)*(ny-ky-1)), intent(out) newc,
integer(fp_flag), intent(out) ier )

Transform B-spline coefficients to obtain the partial derivative spline.

Given a bivariate spline \( s(x,y) \) of degrees \( k_x, k_y \), computes the B-spline coefficients of the derivative spline \( \frac{\partial^{\nu_x+\nu_y}}{\partial x^{\nu_x}\,\partial y^{\nu_y}} s(x,y) \) of degrees \( k_x - \nu_x, k_y - \nu_y \).

Unlike parder / pardeu, this routine does not evaluate the derivative at any point; it only transforms the coefficient array. The resulting spline can then be evaluated with bispev or bispeu.

Parameters
[in]txKnot positions in \( x \)-direction (length \( n_x \)).
[in]nxTotal number of knots in \( x \).
[in]tyKnot positions in \( y \)-direction (length \( n_y \)).
[in]nyTotal number of knots in \( y \).
[in]cB-spline coefficients, length \( (n_x{-}k_x{-}1)(n_y{-}k_y{-}1) \).
[in]kxDegree in \( x \).
[in]kyDegree in \( y \).
[in]nuxDerivative order in \( x \), \( 0 \le \nu_x < k_x \).
[in]nuyDerivative order in \( y \), \( 0 \le \nu_y < k_y \).
[out]newcDerivative-spline coefficients, dimension \( (n_x{-}\nu_x{-}k_x{-}1)(n_y{-}\nu_y{-}k_y{-}1) \).
[out]ierError flag: 0 = normal return; 10 = invalid input.
See also
parder — evaluate derivative on a grid; pardeu — evaluate at scattered points; de Boor (1972), J. Approx. Theory 6, 50–62

◆ parsur()

pure subroutine, public fitpack_core::parsur ( integer(fp_size), intent(in) iopt,
integer(fp_size), dimension(2), intent(in) ipar,
integer(fp_size), intent(in) idim,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mv), intent(in) v,
real(fp_real), dimension(mu*mv*idim), intent(in) f,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nuest,
integer(fp_size), intent(in) nvest,
integer(fp_size), intent(inout) nu,
real(fp_real), dimension(nuest), intent(inout) tu,
integer(fp_size), intent(inout) nv,
real(fp_real), dimension(nvest), intent(inout) tv,
real(fp_real), dimension((nuest-4)*(nvest-4)*idim), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Fit a smooth parametric surface to gridded data.

Given data points \( \mathbf{f}(i,j) \in \mathbb{R}^d \) at the grid nodes \( (u_i, v_j) \), \( i=1,\ldots,m_u;\ j=1,\ldots,m_v \), determines a smooth \( d \)-dimensional bicubic spline

Here is the call graph for this function:

◆ percur()

pure subroutine, public fitpack_core::percur ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(m), intent(in) w,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nest,
integer(fp_size), intent(inout) n,
real(fp_real), dimension(nest), intent(inout) t,
real(fp_real), dimension(nest), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(nest), intent(inout) iwrk,
integer(fp_flag), intent(inout) ier )

Determine a smooth periodic spline approximation to data.

Given data points \( (x_i, y_i) \) with weights \( w_i > 0 \), \( i=1,\ldots,m \), computes a periodic spline \( s(x) \) of degree \( k \) with period \( P = x_m - x_1 \). The periodicity means \( s(x_1) = s(x_m) \) and all derivatives match at the boundary.

  • If iopt=-1: weighted least-squares spline with user-specified knots.
  • If iopt>=0: automatic knot placement minimizing the discontinuity jumps of the \( k \)-th derivative, subject to \( F(p) \le S \).
Parameters
[in]ioptComputation mode: -1 (LSQ), 0 (new smoothing), 1 (continue).
[in]mNumber of data points, \( m > 1 \).
[in]xAbscissae (strictly ascending). \( x_m \) defines the period length.
[in]yOrdinates \( y_1,\ldots,y_{m-1} \) (element \( y_m \) not used).
[in]wWeights \( w_1,\ldots,w_{m-1} > 0 \) ( \( w_m \) not used).
[in]kSpline degree, \( 1 \le k \le 5 \). Cubic ( \( k=3 \)) recommended.
[in]sSmoothing factor \( S \ge 0 \) (used when iopt>=0).
[in]nestOver-estimate of total knots. nest>=2*k+2; nest=m+2*k always suffices.
[in,out]nTotal number of knots.
[in,out]tKnot positions (length nest).
[in,out]cB-spline coefficients (length nest).
[in,out]fpWeighted sum of squared residuals.
[in,out]wrkReal workspace, length \( \ge m(k+1) + \text{nest}(8+5k) \).
[in]lwrkDeclared dimension of wrk.
[in,out]iwrkInteger workspace (length nest).
[in,out]ierError flag (same codes as curfit, plus periodic constraints).
See also
Dierckx, Ch. 6, §6.1–6.2; fpperi — core periodic fitting algorithm
Here is the call graph for this function:

◆ pogrid()

subroutine, public fitpack_core::pogrid ( integer(fp_size), dimension(3), intent(in) iopt,
integer(fp_size), dimension(2), intent(in) ider,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mv), intent(in) v,
real(fp_real), dimension(mu*mv), intent(in) z,
real(fp_real), intent(in) z0,
real(fp_real), intent(in) r,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nuest,
integer(fp_size), intent(in) nvest,
integer(fp_size), intent(inout) nu,
real(fp_real), dimension(nuest), intent(inout) tu,
integer(fp_size), intent(inout) nv,
real(fp_real), dimension(nvest), intent(inout) tv,
real(fp_real), dimension((nuest-4)*(nvest-4)), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Fit a smooth bivariate spline to gridded data on a polar (disc) domain.

Fits a function \( f(x,y) \) to data \( z_{ij} \) at the nodes \( (x,y) = (u_i \cos v_j,\ u_i \sin v_j) \) of a radius-angle grid over the disc

Here is the call graph for this function:

◆ polar()

pure subroutine, public fitpack_core::polar ( integer(fp_size), dimension(3), intent(in) iopt,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(in) y,
real(fp_real), dimension(m), intent(in) z,
real(fp_real), dimension(m), intent(in) w,
procedure(fitpack_polar_boundary) rad,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nuest,
integer(fp_size), intent(in) nvest,
real(fp_real), intent(in) eps,
integer(fp_size), intent(out) nu,
real(fp_real), dimension(nuest), intent(out) tu,
integer(fp_size), intent(out) nv,
real(fp_real), dimension(nvest), intent(out) tv,
real(fp_real), dimension(m), intent(out) u,
real(fp_real), dimension(m), intent(out) v,
real(fp_real), dimension((nuest-4)*(nvest-4)), intent(out) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(lwrk1), intent(inout) wrk1,
integer(fp_size), intent(in) lwrk1,
real(fp_real), dimension(lwrk2), intent(inout) wrk2,
integer(fp_size), intent(in) lwrk2,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Fit a smooth bivariate spline to scattered data on a polar domain.

Given weighted data points \( (x_i, y_i, z_i, w_i) \) on a polar domain bounded by \( x = r(v)\cos v,\ y = r(v)\sin v \) for \( -\pi \le v \le \pi \), determines a

Here is the call graph for this function:

◆ profil()

pure subroutine, public fitpack_core::profil ( integer(fp_size), intent(in) iopt,
real(fp_real), dimension(nx), intent(in) tx,
integer(fp_size), intent(in) nx,
real(fp_real), dimension(ny), intent(in) ty,
integer(fp_size), intent(in) ny,
real(fp_real), dimension((nx-kx-1)*(ny-ky-1)), intent(in) c,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
real(fp_real), intent(in) u,
integer(fp_size), intent(in) nu,
real(fp_real), dimension(nu), intent(out) cu,
integer(fp_flag), intent(out) ier )

Extract a cross-section (profile) of a bivariate spline.

Given a bivariate spline \( s(x,y) \), computes the B-spline coefficients of a univariate cross-section:

  • iopt=0: \( f(y) = s(u, y) \) — profile at fixed \( x = u \).
  • iopt=1: \( g(x) = s(x, u) \) — profile at fixed \( y = u \).

The resulting 1-D spline can be evaluated using splev or other univariate routines.

Parameters
[in]ioptProfile direction: 0 = fix \( x \), extract \( f(y) \); 1 = fix \( y \), extract \( g(x) \).
[in]txKnot positions in \( x \)-direction (length \( n_x \)).
[in]nxTotal number of knots in \( x \).
[in]tyKnot positions in \( y \)-direction (length \( n_y \)).
[in]nyTotal number of knots in \( y \).
[in]cB-spline coefficients, length \( (n_x{-}k_x{-}1)(n_y{-}k_y{-}1) \).
[in]kxDegree in \( x \).
[in]kyDegree in \( y \).
[in]uCross-section coordinate. Must satisfy \( t_{k_x+1} \le u \le t_{n_x-k_x} \) if iopt=0, or \( t_{k_y+1} \le u \le t_{n_y-k_y} \) if iopt=1.
[in]nuDeclared dimension of cu. Must be \( \ge n_y \) if iopt=0, \( \ge n_x \) if iopt=1.
[out]cuB-spline coefficients of the 1-D cross-section (length nu).
[out]ierError flag: 0 = normal return; 10 = invalid input.
See also
bispev — full surface evaluation; fpbspl — B-spline basis evaluation
Here is the call graph for this function:

◆ regrid()

pure subroutine, public fitpack_core::regrid ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) mx,
real(fp_real), dimension(mx), intent(in) x,
integer(fp_size), intent(in) my,
real(fp_real), dimension(my), intent(in) y,
real(fp_real), dimension(mx*my), intent(in) z,
real(fp_real), intent(in) xb,
real(fp_real), intent(in) xe,
real(fp_real), intent(in) yb,
real(fp_real), intent(in) ye,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nxest,
integer(fp_size), intent(in) nyest,
integer(fp_size), intent(inout) nx,
real(fp_real), dimension(nxest), intent(inout) tx,
integer(fp_size), intent(inout) ny,
real(fp_real), dimension(nyest), intent(inout) ty,
real(fp_real), dimension((nxest-kx-1)*(nyest-ky-1)), intent(inout) c,
real(fp_real), intent(out) fp,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Fit a smoothing bivariate spline to data on a rectangular grid.

Determines a smooth bivariate spline \( s(x,y) \) of degrees \( k_x, k_y \) approximating data values \( z_{ij} \) at the grid nodes \( (x_i, y_j) \), \( i=1,\ldots,m_x;\ j=1,\ldots,m_y \), on the rectangle \( [x_b, x_e] \times [y_b, y_e] \).

The smoothing factor \( s \ge 0 \) controls the trade-off: the routine minimizes discontinuity jumps in the spline derivatives subject to

\[ \sum_{i=1}^{m_x} \sum_{j=1}^{m_y} \bigl(z_{ij} - s(x_i, y_j)\bigr)^2 \le s. \]

Setting \( s = 0 \) produces an interpolating spline.

Parameters
[in]ioptComputation mode: -1 = least-squares with user knots; 0 = smoothing, fresh start; 1 = smoothing, continue with previous knots.
[in]mxNumber of grid points along \( x \), \( m_x > k_x \).
[in]xStrictly increasing \( x \)-grid coordinates (length \( m_x \)).
[in]myNumber of grid points along \( y \), \( m_y > k_y \).
[in]yStrictly increasing \( y \)-grid coordinates (length \( m_y \)).
[in]zData values, length \( m_x \cdot m_y \): z(my*(i-1)+j) = value at \( (x_i, y_j) \).
[in]xbLower \( x \)-boundary, \( x_b \le x_1 \).
[in]xeUpper \( x \)-boundary, \( x_e \ge x_{m_x} \).
[in]ybLower \( y \)-boundary, \( y_b \le y_1 \).
[in]yeUpper \( y \)-boundary, \( y_e \ge y_{m_y} \).
[in]kxDegree in \( x \), \( 1 \le k_x \le 5 \) (bicubic \( k_x{=}3 \) recommended).
[in]kyDegree in \( y \), \( 1 \le k_y \le 5 \).
[in]sSmoothing factor, \( s \ge 0 \) (ignored when iopt=-1).
[in]nxestUpper bound for \( n_x \), \( \ge 2(k_x{+}1) \).
[in]nyestUpper bound for \( n_y \), \( \ge 2(k_y{+}1) \).
[in,out]nxTotal number of knots in \( x \).
[in,out]txKnot positions in \( x \) (length nxest).
[in,out]nyTotal number of knots in \( y \).
[in,out]tyKnot positions in \( y \) (length nyest).
[out]cB-spline coefficients, length \( (n_x{-}k_x{-}1)(n_y{-}k_y{-}1) \).
[out]fpSum of squared residuals \( F_p \).
[in,out]wrkReal workspace (length lwrk).
[in]lwrkDeclared dimension of wrk.
[in,out]iwrkInteger workspace (length kwrk).
[in]kwrkDeclared dimension of iwrk.
[out]ierError flag: \( \le 0 \) = success, 15 = convergence warnings, 10 = invalid input.
Note
Unlike surfit, this routine exploits the grid structure for a significantly faster algorithm.
See also
Dierckx, Ch. 5, §5.4 (pp. 117–121); surfit — scattered-data variant; Dierckx (1982), SIAM J. Numer. Anal. 19, 1286–1304
Here is the call graph for this function:

◆ root_finding_iterate()

elemental subroutine fitpack_core::root_finding_iterate ( real(fp_real), intent(inout) p1,
real(fp_real), intent(inout) f1,
real(fp_real), intent(inout) p2,
real(fp_real), intent(inout) f2,
real(fp_real), intent(inout) p3,
real(fp_real), intent(inout) f3,
real(fp_real), intent(inout) p,
real(fp_real), intent(in) fpms,
real(fp_real), intent(in) acc,
logical(fp_bool), intent(inout) check1,
logical(fp_bool), intent(inout) check3,
logical(fp_bool), intent(out) success )
private

Update the smoothing parameter \( p \) during iterative knot selection.

Given the current iterate \( (p, F(p) - S) \) and the bracketing triple \( (p_1, F_1), (p_2, F_2), (p_3, F_3) \) with \( F_1 > 0 \) and \( F_3 < 0 \), updates the bracket and computes the next estimate via rational interpolation (fprati, Eq. 5.30).

During the initial phase (before the bracket is established), the routine adjusts \( p \) by multiplicative factors to find \( p \) values that bracket the root \( F(p) = 0 \).

Parameters
[in,out]p1Left bracket; satisfies \( F_1 > 0 \)
[in,out]f1\( F(p_1) - S \); updated with \( p_1 \)
[in,out]p2Most recent iterate; set to p on entry
[in,out]f2\( F(p_2) - S \); set to fpms on entry
[in,out]p3Right bracket; satisfies \( F_3 < 0 \)
[in,out]f3\( F(p_3) - S \); updated with \( p_3 \)
[in,out]pCurrent smoothing parameter; updated to next estimate
[in]fpmsCurrent residual \( F(p) - S \)
[in]accConvergence tolerance
[in,out]check1.true. once lower bracket is established
[in,out]check3.true. once upper bracket is established
[out]success.false. if iteration stalls (non-monotone \( F \))
See also
Dierckx, Ch. 5, §5.2.4 (pp. 83-86), Eq. 5.30-5.32
Here is the call graph for this function:

◆ spalde()

pure subroutine, public fitpack_core::spalde ( real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(n), intent(in) c,
integer(fp_size), intent(in) k1,
real(fp_real), intent(in) x,
real(fp_real), dimension(k1), intent(out) d,
integer(fp_flag), intent(out) ier )

Evaluate all derivatives of a spline at a single point.

Given a spline \( s(x) \) of order \( k_1 = k + 1 \) (degree \( k \)) in B-spline representation, computes \( d_j = s^{(j-1)}(x) \) for \( j = 1,\ldots,k_1 \) using the stable recurrence scheme of de Boor.

Parameters
[in]tKnot positions (length \( n \)).
[in]nTotal number of knots.
[in]cB-spline coefficients (length \( n \)).
[in]k1Order of the spline ( \( k_1 = k + 1 \)).
[in]xPoint where derivatives are evaluated. Must satisfy \( t_{k_1} \le x \le t_{n-k_1+1} \).
[out]dDerivative values (length \( k_1 \)): \( d(j) = s^{(j-1)}(x) \) for \( j = 1,\ldots,k_1 \).
[out]ierError flag: 0 = normal return; 10 = invalid input.
Note
At a knot, right derivatives are computed (left derivatives at the right boundary).
See also
Dierckx, Ch. 1, §1.3; fpader — derivative computation kernel
Here is the call graph for this function:

◆ spgrid()

pure subroutine, public fitpack_core::spgrid ( integer(fp_size), dimension(3), intent(in) iopt,
integer(fp_size), dimension(4), intent(in) ider,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mv), intent(in) v,
real(fp_real), dimension(mu*mv), intent(in) r,
real(fp_real), intent(in) r0,
real(fp_real), intent(in) r1,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nuest,
integer(fp_size), intent(in) nvest,
integer(fp_size), intent(inout) nu,
real(fp_real), dimension(nuest), intent(inout) tu,
integer(fp_size), intent(inout) nv,
real(fp_real), dimension(nvest), intent(inout) tv,
real(fp_real), dimension((nuest-4)*(nvest-4)), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Fit a smooth bivariate spline to gridded data on a sphere (latitude-longitude grid).

Given data values \( r_{ij} \) on the latitude-longitude grid \( (u_i, v_j) \) with \( 0 < u_i < \pi \) (colatitude), \( v_b \le v_j < v_b + 2\pi \) (longitude), determines a bicubic spline \( s(u,v) \) satisfying pole continuity constraints (value and optional gradient at \( u=0 \) and \( u=\pi \)) and periodicity in \( v \):

\[ \sum_{i,j}(r_{ij} - s(u_i,v_j))^2 + (r_0 - s(0,v))^2 + (r_1 - s(\pi,v))^2 \le s. \]

Parameters
[in]ioptInteger array(3): iopt(1) = computation mode (-1/0/1); iopt(2) = continuity order at pole \( u=0 \) (0/1); iopt(3) = continuity order at pole \( u=\pi \) (0/1).
[in]iderInteger array(4): pole data/derivative flags — ider(1) and ider(3) specify whether data at poles exist; ider(2) and ider(4) specify vanishing derivatives.
[in]muNumber of latitude grid points, \( 0 < u_i < \pi \).
[in]uStrictly increasing colatitudes (length \( m_u \)).
[in]mvNumber of longitude grid points, \( m_v > 3 \).
[in]vStrictly increasing longitudes (length \( m_v \)), \( -\pi \le v_1 < \pi,\ v_{m_v} < v_1 + 2\pi \).
Here is the call graph for this function:

◆ sphere()

pure subroutine, public fitpack_core::sphere ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(in) teta,
real(fp_real), dimension(m), intent(in) phi,
real(fp_real), dimension(m), intent(in) r,
real(fp_real), dimension(m), intent(in) w,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) ntest,
integer(fp_size), intent(in) npest,
real(fp_real), intent(in) eps,
integer(fp_size), intent(inout) nt,
real(fp_real), dimension(ntest), intent(inout) tt,
integer(fp_size), intent(inout) np,
real(fp_real), dimension(npest), intent(inout) tp,
real(fp_real), dimension((ntest-4)*(npest-4)), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(lwrk1), intent(inout) wrk1,
integer(fp_size), intent(in) lwrk1,
real(fp_real), dimension(lwrk2), intent(inout) wrk2,
integer(fp_size), intent(in) lwrk2,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Fit a smooth bicubic spherical spline to scattered data on a sphere.

Given weighted data points \( (\theta_i, \phi_i, r_i, w_i) \), \( i=1,\ldots,m \), with \( 0 \le \theta \le \pi \) (colatitude) and \( 0 \le \phi \le 2\pi \) (longitude), determines a bicubic spline \( s(\theta, \phi) \) satisfying:

  • Pole constraints: \( s(0,\phi) \) and \( s(\pi,\phi) \) are constant.
  • Periodicity in \( \phi \): derivatives match at \( \phi = 0 \) and \( \phi = 2\pi \).
  • Gradient constraints at poles for smooth angular dependence.

The smoothing factor \( s \ge 0 \) controls the trade-off:

\[ \sum_{i=1}^{m} \bigl[w_i\,(r_i - s(\theta_i, \phi_i))\bigr]^2 \le s. \]

Parameters
[in]ioptComputation mode: -1 = least-squares with user knots; 0 = smoothing, fresh start; 1 = smoothing, continue.
[in]mNumber of data points, \( m \ge 2 \).
[in]tetaColatitudes \( \theta_i \in [0, \pi] \) (length \( m \)).
[in]phiLongitudes \( \phi_i \in [0, 2\pi] \) (length \( m \)).
[in]rData values (length \( m \)).
[in]wPositive weights (length \( m \)).
[in]sSmoothing factor, \( s \ge 0 \) (ignored when iopt=-1).
[in]ntestUpper bound for \( n_\theta \), \( \ge 8 \).
[in]npestUpper bound for \( n_\phi \), \( \ge 8 \).
[in]epsRank-deficiency threshold, \( 0 < \varepsilon < 1 \).
[in,out]ntTotal number of knots in \( \theta \).
[in,out]ttKnot positions in \( \theta \) (length ntest).
[in,out]npTotal number of knots in \( \phi \).
[in,out]tpKnot positions in \( \phi \) (length npest).
[out]cB-spline coefficients, length \( (n_\theta{-}4)(n_\phi{-}4) \).
[out]fpWeighted sum of squared residuals \( F_p \).
[in,out]wrk1Real workspace (length lwrk1).
[in]lwrk1Declared dimension of wrk1.
[in,out]wrk2Secondary workspace for rank-deficient systems (length lwrk2).
[in]lwrk2Declared dimension of wrk2.
[in,out]iwrkInteger workspace (length kwrk).
[in]kwrkDeclared dimension of iwrk.
[out]ierError flag: \( \le 0 \) = success, 15 = convergence warnings, 10 = invalid input, >10 = lwrk2 too small.
See also
Dierckx, Ch. 11, §11.2 (pp. 254–270); spgrid — gridded spherical variant
Here is the call graph for this function:

◆ splder()

pure subroutine, public fitpack_core::splder ( real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(n), intent(in) c,
integer(fp_size), intent(in) k,
integer(fp_size), intent(in) nu,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(out) y,
integer(fp_size), intent(in) m,
integer(fp_flag), intent(in) e,
real(fp_real), dimension(n), intent(inout) wrk,
integer(fp_flag), intent(out) ier )

Evaluate the \( \nu \)-th derivative of a spline \( s(x) \) at a set of points.

Given a spline of degree \( k \) in B-spline representation, evaluates \( s^{(\nu)}(x_i) \) for \( i = 1,\ldots,m \) using the recurrence scheme of de Boor. The derivative of order \( \nu \) of a degree- \( k \) spline is a degree- \( (k{-}\nu) \) spline whose B-spline coefficients are computed via the de Boor recurrence.

Parameters
[in]tKnot positions (length \( n \)).
[in]nTotal number of knots.
[in]cB-spline coefficients (length \( n \)).
[in]kDegree of the spline.
[in]nuOrder of derivative, \( 0 \le \nu \le k \).
[in]xEvaluation points (length \( m \)).
[out]yDerivative values \( s^{(\nu)}(x_i) \) (length \( m \)).
[in]mNumber of evaluation points, \( m \ge 1 \).
[in]eExtrapolation mode for points outside the support:
  • 0: extrapolate from end spans.
  • 1: return zero.
  • 2: set ier=1 and return.
[in,out]wrkReal workspace (length \( n \)). Contains derivative coefficients on exit.
[out]ierError flag: 0 = normal; 1 = out of bounds with e=2; 10 = invalid input.
See also
Dierckx, Ch. 1, §1.3; fpbspl — B-spline basis evaluation
Here is the call graph for this function:

◆ splev()

pure subroutine, public fitpack_core::splev ( real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(n), intent(in) c,
integer(fp_size), intent(in) k,
real(fp_real), dimension(m), intent(in) x,
real(fp_real), dimension(m), intent(out) y,
integer(fp_size), intent(in) m,
integer(fp_flag), intent(in) e,
integer(fp_flag), intent(out) ier )

Evaluate a spline \( s(x) \) of degree \( k \) at a set of points.

Given a spline in its B-spline representation (knots \( t \), coefficients \( c \), degree \( k \)), evaluates \( s(x_i) \) for \( i = 1,\ldots,m \).

Parameters
[in]tKnot positions (length \( n \)).
[in]nTotal number of knots.
[in]cB-spline coefficients (length \( n \)).
[in]kDegree of the spline.
[in]xEvaluation points (length \( m \)).
[out]ySpline values \( s(x_i) \) (length \( m \)).
[in]mNumber of evaluation points. Must satisfy \( m \ge 1 \).
[in]eExtrapolation mode for points outside \( [t_{k+1}, t_{n-k}] \):
  • 0 (OUTSIDE_EXTRAPOLATE): extrapolate from end spans.
  • 1 (OUTSIDE_ZERO): return zero.
  • 2 (OUTSIDE_NOT_ALLOWED): set ier=1 and return.
  • 3 (OUTSIDE_NEAREST_BND): clamp to nearest boundary value.
[out]ierError flag: 0 = normal return; 10 = invalid input.
See also
Dierckx, Ch. 1, §1.3 (pp. 4–14); fpbspl — B-spline basis evaluation
Here is the call graph for this function:

◆ splint()

real(fp_real) function, public fitpack_core::splint ( real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(n), intent(in) c,
integer(fp_size), intent(in) k,
real(fp_real), intent(in) a,
real(fp_real), intent(in) b,
real(fp_real), dimension(n), intent(inout) wrk )

Compute the definite integral of a spline \( s(x) \) over \( [a, b] \).

Calculates \( \int_a^b s(x)\,dx \) for a spline of degree \( k \) given in B-spline representation. The spline is considered identically zero outside its support \( (t_{k+1}, t_{n-k}) \).

Uses the method of Gaffney (1976): first computes the integrals of each normalized B-spline \( N_{i,k+1}(x) \) over \( [a, b] \), then forms the weighted sum with the spline coefficients.

Parameters
[in]tKnot positions (length \( n \)).
[in]nTotal number of knots.
[in]cB-spline coefficients (length \( n \)).
[in]kDegree of the spline.
[in]aLeft endpoint of the integration interval.
[in]bRight endpoint of the integration interval.
[in,out]wrkReal workspace (length \( n \)). On exit, contains integrals of normalized B-splines.
Returns
The integral \( \int_a^b s(x)\,dx \).
See also
Dierckx, Ch. 1, §1.3.3 (pp. 10–12), Eq. 1.42–1.44; fpintb — B-spline integration
Here is the call graph for this function:

◆ sproot()

pure subroutine, public fitpack_core::sproot ( real(fp_real), dimension(n), intent(in) t,
integer(fp_size), intent(in) n,
real(fp_real), dimension(n), intent(in) c,
real(fp_real), dimension(mest), intent(out) zeros,
integer(fp_size), intent(in) mest,
integer(fp_size), intent(out) m,
integer(fp_flag), intent(out) ier )

Find the zeros of a cubic spline \( s(x) \) given in B-spline representation.

Locates all real roots of a cubic spline ( \( k = 3 \)) by reducing the problem to finding zeros of the cubic polynomial on each knot interval \( [t_l, t_{l+1}] \). Uses continuity of the spline and its derivative to propagate endpoint values across intervals, calling fpcuro for each cubic piece.

Parameters
[in]tKnot positions (length \( n \)). Must satisfy \( n \ge 8 \).
[in]nTotal number of knots.
[in]cB-spline coefficients (length \( n \)).
[out]zerosArray of zeros found (length mest).
[in]mestMaximum number of zeros that can be stored.
[out]mActual number of zeros found.
[out]ierError flag:
  • 0: normal return.
  • 1: number of zeros exceeds mest.
  • 10: invalid input data.
Note
Only works for cubic splines ( \( k = 3 \)).
See also
fpcuro — cubic polynomial root finder
Here is the call graph for this function:

◆ surev()

pure subroutine, public fitpack_core::surev ( integer(fp_size), intent(in) idim,
real(fp_real), dimension(nu), intent(in) tu,
integer(fp_size), intent(in) nu,
real(fp_real), dimension(nv), intent(in) tv,
integer(fp_size), intent(in) nv,
real(fp_real), dimension((nu-4)*(nv-4)*idim), intent(in) c,
real(fp_real), dimension(mu), intent(in) u,
integer(fp_size), intent(in) mu,
real(fp_real), dimension(mv), intent(in) v,
integer(fp_size), intent(in) mv,
real(fp_real), dimension(mf), intent(out) f,
integer(fp_size), intent(in) mf,
real(fp_real), dimension(lwrk), intent(inout) wrk,
integer(fp_size), intent(in) lwrk,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Evaluate a parametric bicubic spline surface on a grid.

Evaluates an \( d \)-dimensional ( \( d = \) idim) bicubic spline surface at the grid \( (u_i, v_j) \), \( i=1,\ldots,m_u;\ j=1,\ldots,m_v \).

Here is the call graph for this function:

◆ surfit()

pure subroutine, public fitpack_core::surfit ( integer(fp_size), intent(in) iopt,
integer(fp_size), intent(in) m,
real(fp_real), dimension(m), intent(inout) x,
real(fp_real), dimension(m), intent(inout) y,
real(fp_real), dimension(m), intent(in) z,
real(fp_real), dimension(m), intent(in) w,
real(fp_real), intent(in) xb,
real(fp_real), intent(in) xe,
real(fp_real), intent(in) yb,
real(fp_real), intent(in) ye,
integer(fp_size), intent(in) kx,
integer(fp_size), intent(in) ky,
real(fp_real), intent(in) s,
integer(fp_size), intent(in) nxest,
integer(fp_size), intent(in) nyest,
integer(fp_size), intent(in) nmax,
real(fp_real), intent(in) eps,
integer(fp_size), intent(inout) nx,
real(fp_real), dimension(nmax), intent(inout) tx,
integer(fp_size), intent(inout) ny,
real(fp_real), dimension(nmax), intent(inout) ty,
real(fp_real), dimension((nxest-kx-1)*(nyest-ky-1)), intent(inout) c,
real(fp_real), intent(inout) fp,
real(fp_real), dimension(lwrk1), intent(inout) wrk1,
integer(fp_size), intent(in) lwrk1,
real(fp_real), dimension(lwrk2), intent(inout) wrk2,
integer(fp_size), intent(in) lwrk2,
integer(fp_size), dimension(kwrk), intent(inout) iwrk,
integer(fp_size), intent(in) kwrk,
integer(fp_flag), intent(out) ier )

Fit a smoothing bivariate spline to scattered data.

Given weighted data points \( (x_i, y_i, z_i, w_i) \), \( i=1,\ldots,m \), determines a bivariate spline \( s(x,y) \) of degrees \( k_x, k_y \) on the rectangle \( [x_b, x_e] \times [y_b, y_e] \).

The smoothing factor \( s \ge 0 \) controls the trade-off: the routine minimizes discontinuity jumps in the spline derivatives subject to

\[ \sum_{i=1}^{m} \bigl[w_i\,(z_i - s(x_i, y_i))\bigr]^2 \le s. \]

Setting \( s = 0 \) produces an interpolating spline. The result is given in tensor-product B-spline representation and can be evaluated with bispev / bispeu.

Parameters
[in]ioptComputation mode: -1 = least-squares with user knots; 0 = smoothing, fresh start; 1 = smoothing, continue.
[in]mNumber of data points, \( m \ge (k_x{+}1)(k_y{+}1) \).
[in,out]x\( x \)-coordinates of data points (length \( m \)).
[in,out]y\( y \)-coordinates of data points (length \( m \)).
[in]zData values (length \( m \)).
[in]wPositive weights (length \( m \)).
[in]xbLower \( x \)-boundary.
[in]xeUpper \( x \)-boundary.
[in]ybLower \( y \)-boundary.
[in]yeUpper \( y \)-boundary.
[in]kxDegree in \( x \), \( 1 \le k_x \le 5 \) (bicubic recommended).
[in]kyDegree in \( y \), \( 1 \le k_y \le 5 \).
[in]sSmoothing factor, \( s \ge 0 \) (ignored when iopt=-1).
[in]nxestUpper bound for \( n_x \), \( \ge 2(k_x{+}1) \).
[in]nyestUpper bound for \( n_y \), \( \ge 2(k_y{+}1) \).
[in]nmaxDimension of tx/ty arrays, \( \ge \max(n_x^{\text{est}}, n_y^{\text{est}}) \).
[in]epsRank-deficiency threshold, \( 0 < \varepsilon < 1 \).
[in,out]nxTotal number of knots in \( x \).
[in,out]txKnot positions in \( x \) (length nmax).
[in,out]nyTotal number of knots in \( y \).
[in,out]tyKnot positions in \( y \) (length nmax).
[out]cB-spline coefficients, length \( (n_x{-}k_x{-}1)(n_y{-}k_y{-}1) \).
[out]fpWeighted sum of squared residuals \( F_p \).
[in,out]wrk1Real workspace (length lwrk1).
[in]lwrk1Declared dimension of wrk1.
[in,out]wrk2Secondary workspace for rank-deficient systems (length lwrk2).
[in]lwrk2Declared dimension of wrk2.
[in,out]iwrkInteger workspace (length kwrk).
[in]kwrkDeclared dimension of iwrk.
[out]ierError flag: \( \le 0 \) = success, 15 = convergence warnings, 10 = invalid input, >10 = lwrk2 too small.
Note
For gridded data, use regrid instead — it is significantly faster.
See also
Dierckx, Ch. 5, §5.3 (pp. 107–117); regrid — gridded variant; bispev — evaluate the result
Here is the call graph for this function:

◆ swap_data()

elemental subroutine fitpack_core::swap_data ( real(fp_real), intent(inout) a,
real(fp_real), intent(inout) b )
private

Swap two real values in place.

◆ swap_size()

elemental subroutine fitpack_core::swap_size ( integer(fp_size), intent(inout) a,
integer(fp_size), intent(inout) b )
private

Swap two integer values in place.

Variable Documentation

◆ concon_maxbin

integer(fp_flag), parameter, public fitpack_core::concon_maxbin = 14

◆ concon_maxtr

integer(fp_flag), parameter, public fitpack_core::concon_maxtr = 15

◆ concon_qp_fail

integer(fp_flag), parameter, public fitpack_core::concon_qp_fail = 16

◆ deg2rad

real(fp_real), parameter, public fitpack_core::deg2rad = pi/180.0_FP_REAL

◆ degree_3

integer(fp_size), parameter, public fitpack_core::degree_3 = 3

◆ degree_4

integer(fp_size), parameter, public fitpack_core::degree_4 = 4

◆ degree_5

integer(fp_size), parameter, public fitpack_core::degree_5 = 5

◆ fitpack_input_error

integer(fp_flag), parameter, public fitpack_core::fitpack_input_error = 10

◆ fitpack_insufficient_knots

integer(fp_flag), parameter, public fitpack_core::fitpack_insufficient_knots = 13

◆ fitpack_insufficient_storage

integer(fp_flag), parameter, public fitpack_core::fitpack_insufficient_storage = 1

◆ fitpack_interpolating_ok

integer(fp_flag), parameter, public fitpack_core::fitpack_interpolating_ok = -1

◆ fitpack_invalid_constraint

integer(fp_flag), parameter, public fitpack_core::fitpack_invalid_constraint = 12

◆ fitpack_invalid_range

integer(fp_flag), parameter, public fitpack_core::fitpack_invalid_range = 6

◆ fitpack_leastsquares_ok

integer(fp_flag), parameter, public fitpack_core::fitpack_leastsquares_ok = -2

◆ fitpack_maxit

integer(fp_flag), parameter, public fitpack_core::fitpack_maxit = 3

◆ fitpack_ok

integer(fp_flag), parameter, public fitpack_core::fitpack_ok = 0

◆ fitpack_overlapping_knots

integer(fp_flag), parameter, public fitpack_core::fitpack_overlapping_knots = 5

◆ fitpack_s_too_small

integer(fp_flag), parameter, public fitpack_core::fitpack_s_too_small = 2

◆ fitpack_test_error

integer(fp_flag), parameter, public fitpack_core::fitpack_test_error = 11

◆ fitpack_too_many_knots

integer(fp_flag), parameter, public fitpack_core::fitpack_too_many_knots = 4

◆ five

real(fp_real), parameter, public fitpack_core::five = 5.0_FP_REAL

◆ four

real(fp_real), parameter, public fitpack_core::four = 4.0_FP_REAL

◆ fourth

real(fp_real), parameter, public fitpack_core::fourth = 0.25_FP_REAL

◆ fp_bool

integer, parameter, public fitpack_core::fp_bool = c_bool

◆ fp_comm

integer, parameter, public fitpack_core::fp_comm = c_double

◆ fp_false

logical(fp_bool), parameter, public fitpack_core::fp_false = .false._FP_BOOL

◆ fp_flag

integer, parameter, public fitpack_core::fp_flag = c_int32_t

◆ fp_not_alloc

integer(fp_size), parameter fitpack_core::fp_not_alloc = -99999999_FP_SIZE
private

Marker for unallocated arrays in communication buffers.

◆ fp_real

integer, parameter, public fitpack_core::fp_real = c_double

◆ fp_size

integer, parameter, public fitpack_core::fp_size = c_int32_t

◆ fp_true

logical(fp_bool), parameter, public fitpack_core::fp_true = .true._FP_BOOL

◆ half

real(fp_real), parameter, public fitpack_core::half = 0.5_FP_REAL

◆ ifive

integer(fp_size), parameter fitpack_core::ifive = 5_FP_SIZE
private

◆ ifour

integer(fp_size), parameter fitpack_core::ifour = 4_FP_SIZE
private

◆ ione

integer(fp_size), parameter fitpack_core::ione = 1_FP_SIZE
private

◆ iopt_new_leastsquares

integer(fp_flag), parameter, public fitpack_core::iopt_new_leastsquares = -1

◆ iopt_new_smoothing

integer(fp_flag), parameter, public fitpack_core::iopt_new_smoothing = 0

◆ iopt_old_fit

integer(fp_flag), parameter, public fitpack_core::iopt_old_fit = 1

◆ ithree

integer(fp_size), parameter fitpack_core::ithree = 3_FP_SIZE
private

◆ itwo

integer(fp_size), parameter fitpack_core::itwo = 2_FP_SIZE
private

◆ izero

integer(fp_size), parameter fitpack_core::izero = 0_FP_SIZE
private

◆ knot_dim_1

integer(fp_flag), parameter, public fitpack_core::knot_dim_1 = -1

◆ knot_dim_2

integer(fp_flag), parameter, public fitpack_core::knot_dim_2 = 1

◆ knot_dim_none

integer(fp_flag), parameter, public fitpack_core::knot_dim_none = 0

◆ max_idim

integer(fp_size), parameter, public fitpack_core::max_idim = 10

◆ max_order

integer(fp_size), parameter, public fitpack_core::max_order = 19

◆ one

real(fp_real), parameter, public fitpack_core::one = 1.0_FP_REAL

◆ onep5

real(fp_real), parameter, public fitpack_core::onep5 = 1.5_FP_REAL

◆ outside_extrapolate

integer(fp_flag), parameter, public fitpack_core::outside_extrapolate = 0

◆ outside_nearest_bnd

integer(fp_flag), parameter, public fitpack_core::outside_nearest_bnd = 3

◆ outside_not_allowed

integer(fp_flag), parameter, public fitpack_core::outside_not_allowed = 2

◆ outside_zero

integer(fp_flag), parameter, public fitpack_core::outside_zero = 1

◆ pi

real(fp_real), parameter, public fitpack_core::pi = atan2(zero, -one)

◆ pi2

real(fp_real), parameter, public fitpack_core::pi2 = 2*pi

◆ pi4

real(fp_real), parameter, public fitpack_core::pi4 = 4*pi

◆ pio2

real(fp_real), parameter, public fitpack_core::pio2 = half*pi

◆ pio4

real(fp_real), parameter, public fitpack_core::pio4 = fourth*pi

◆ pio8

real(fp_real), parameter, public fitpack_core::pio8 = 0.125_FP_REAL*pi

◆ six

real(fp_real), parameter, public fitpack_core::six = 6.0_FP_REAL

◆ smallnum03

real(fp_real), parameter, public fitpack_core::smallnum03 = 1.0e-03_FP_REAL

◆ smallnum06

real(fp_real), parameter, public fitpack_core::smallnum06 = 1.0e-06_FP_REAL

◆ smallnum08

real(fp_real), parameter, public fitpack_core::smallnum08 = 1.0e-08_FP_REAL

◆ smallnum10

real(fp_real), parameter, public fitpack_core::smallnum10 = 1.0e-10_FP_REAL

◆ ten

real(fp_real), parameter, public fitpack_core::ten = 10.0_FP_REAL

◆ third

real(fp_real), parameter, public fitpack_core::third = one/3.0_FP_REAL

◆ three

real(fp_real), parameter, public fitpack_core::three = 3.0_FP_REAL

◆ two

real(fp_real), parameter, public fitpack_core::two = 2.0_FP_REAL

◆ zero

real(fp_real), parameter, public fitpack_core::zero = 0.0_FP_REAL