This is a Modern Fortran translation of the FITPACK package for curve and surface fitting. The functions are modernized and translated from the original Fortran77 code FITPACK by Paul Dierckx. The starting code used the double precision version of FITPACK distributed with scipy.
An object-oriented interface wrapper was also built. A C/C++ interface is also being built.
Class | Description | Degree |
---|---|---|
fitpack_curve |
1D spline interpolation of scattered data, |
up to 5 |
fitpack_periodic_curve |
1D spline interpolation of scattered data on a periodic domain, |
up to 5 |
fitpack_parametric_curve |
Parametric 1D curves in N dimensions, |
up to 5 |
fitpack_closed_curve |
Closed parametric 1D curves in N dimensions, |
up to 5 |
fitpack_constrained_curve |
Parametric 1D curves in N dimensions with value/derivative constraints at the endpoints |
up to 5 |
Class | Description | Degree |
---|---|---|
fitpack_surface |
2D spline interpolation of scattered data, |
up to 5 |
fitpack_polar |
2D spline interpolation of scattered data in a user-defined polar domain |
3 |
fitpack_sphere |
2D spline interpolation of scattered data on a sphere domain |
3 |
fitpack_grid_surface |
2D spline interpolation of rectangular 2D data |
up to 5 |
fitpack_grid_polar |
2D spline interpolation of polar data |
3 |
The C and C++ header-only interfaces are found in the include
folder. The following scheme shows a comparison between the Fortran, C++ and C struct names for the currently available classes:
Fortran | C | C++ |
---|---|---|
fitpack_curve |
fitpack_curve_c |
fpCurve |
fitpack_periodic_curve |
fitpack_periodic_curve_c |
fpPeriodicCurve |
fitpack_parametric_curve |
fitpack_parametric_curve_c |
fpParametricCurve |
fitpack_closed_curve |
fitpack_closed_curve_c |
fpClosedCurve |
fitpack_constrained_curve |
fitpack_constrained_curve_c |
fpConstrainedCurve |
The choice to provide a header-only C++
implementation is motivated by the need to keep the library C-ABI compatible whatever compiler is being used to build it. For example, on macOS, one may build the library with g++/gfortran, that is not ABI-compatible with clang++. So, it is important that no C++ code is compiled together with the Fortran code in the library.
An automated build is available via the Fortran Package Manager. To use FITPACK within your FPM project, add the following to your fpm.toml file:
[dependencies]
fitpack = { git="https://github.com/perazz/fitpack.git" }
Otherwise, a simple command line build script that builds all modules in the src/ folder is possible.
Several test programs are available through the Fortran Package manager. To run them, just type
fpm test
Fitpack contains very robust algorithms for curve interpolation and fitting, based on algorithms described by Paul Dierckx in Ref [1-4]:
[1] P. Dierckx, "An algorithm for smoothing, differentiation and integration of experimental data using spline functions", J.Comp.Appl.Maths 1 (1975) 165-184.
[2] P. Dierckx, "A fast algorithm for smoothing data on a rectangular grid while using spline functions", SIAM J.Numer.Anal. 19 (1982) 1286-1304.
[3] P. Dierckx, "An improved algorithm for curve fitting with spline functions", report tw54, Dept. Computer Science,K.U. Leuven, 1981.
[4] P. Dierckx, "Curve and surface fitting with splines", Monographs on Numerical Analysis, Oxford University Press, 1993.
[5] P. Dierckx, R. Piessens, "Calculation of Fourier coefficients of discrete functions using cubic splines", Journal of Computational and Applied Mathematics 3(3), 207-209, 1977.
- Dierckx.jl, a Julia interface to FITPACK
- scipy.interpolate, which includes interfaces to FITPACK