Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacobwilliams/pchip
Modern Fortran Piecewise Cubic Hermite Interpolation Package
https://github.com/jacobwilliams/pchip
fortran fortran-package-manager hermite-interpolation interpolation slatec
Last synced: about 6 hours ago
JSON representation
Modern Fortran Piecewise Cubic Hermite Interpolation Package
- Host: GitHub
- URL: https://github.com/jacobwilliams/pchip
- Owner: jacobwilliams
- License: other
- Created: 2019-10-19T15:10:24.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-27T15:56:58.000Z (10 months ago)
- Last Synced: 2024-01-30T09:09:26.641Z (9 months ago)
- Topics: fortran, fortran-package-manager, hermite-interpolation, interpolation, slatec
- Language: Fortran
- Homepage:
- Size: 1.5 MB
- Stars: 22
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
![pchip-logo](media/logo.png)
============PCHIP, a Fortran package for piecewise cubic Hermite interpolation of data. This is a modern Fortran update of the code in the [SLATEC](http://www.netlib.org/slatec/pchip/) library.
### Status
[![Language](https://img.shields.io/badge/-Fortran-734f96?logo=fortran&logoColor=white)](https://github.com/topics/fortran)
[![GitHub release](https://img.shields.io/github/release/jacobwilliams/pchip.svg)](https://github.com/jacobwilliams/pchip/releases/latest)
[![Build Status](https://github.com/jacobwilliams/pchip/actions/workflows/CI.yml/badge.svg)](https://github.com/jacobwilliams/pchip/actions)
[![codecov](https://codecov.io/gh/jacobwilliams/pchip/branch/master/graph/badge.svg)](https://codecov.io/gh/jacobwilliams/pchip)
[![last-commit](https://img.shields.io/github/last-commit/jacobwilliams/pchip)](https://github.com/jacobwilliams/pchip/commits/master)### Building pchip
The library can be built with the [Fortran Package Manager](https://github.com/fortran-lang/fpm) using the provided `fpm.toml` file like so:
```bash
fpm build --release
```To use PCHIP within your FPM project, add the following to your `fpm.toml` file:
```toml
[dependencies]
pchip = { git="https://github.com/jacobwilliams/pchip.git" }
```or, to use a specific version:
```toml
[dependencies]
pchip = { git="https://github.com/jacobwilliams/pchip.git", tag = "1.1.0" }
```### Documentation
The latest API documentation can be found [here](https://jacobwilliams.github.io/PCHIP/). This was generated from the source code using [FORD](https://github.com/Fortran-FOSS-Programmers/ford).
### Description
This document describes the contents of PCHIP, which is a Fortran package for piecewise cubic Hermite interpolation of data. It features software to produce a monotone and "visually pleasing" interpolant to monotone data. As is demonstrated in Reference 4, such an interpolant may be more reasonable than a cubic spline if the data contains both "steep" and "flat" sections. Interpolation of cumulative probability distribution functions is another application. (See References 2-4 for examples.)
All piecewise cubic functions in PCHIP are represented in cubic Hermite form; that is, f(x) is determined by its values F(I) and derivatives D(I) at the breakpoints X(I), I=1(1)N. Throughout the package a PCH function is represented by the five variables N, X, F, D, INCFD:
* N - number of data points;
* X - abscissa values for the data points;
* F - ordinates (function values) for the data points;
* D - slopes (derivative values) at the data points;
* INCFD - increment between successive elements in the F- and D-arrays (more on this later).These appear together and in the same order in all calls.
### Routines
The contents of the package are as follows:
1. Determine Derivative Values.
NOTE: These routines provide alternate ways of determining D if these values are not already known.
* `DPCHIM` -- Piecewise Cubic Hermite Interpolation to Monotone data. Used if the data are monotonic or if the user wants to guarantee that the interpolant stays within the limits of the data. (See Reference 3.
* `DPCHIC` -- Piecewise Cubic Hermite Interpolation Coefficients. Used if neither of the above conditions holds, or if the user wishes control over boundary derivatives. Will generally reproduce monotonicity on subintervals over which the data are monotonic.
* `DPCHSP` -- Piecewise Cubic Hermite Spline. Produces a cubic spline interpolator in cubic Hermite form. Provided primarily for easy comparison of the spline with other piecewise cubic interpolants. (A modified version of de Boor's CUBSPL, Reference 1.)2. Evaluate, Differentiate, or Integrate Resulting PCH Function.
NOTE: If derivative values are available from some other source, these routines can be used without calling any of the previous routines.
* `DCHFEV` -- Cubic Hermite Function EValuator. Evaluates a single cubic Hermite function at an array of points. Used when the interval is known, as in graphing applications. Called by PCHFE.
* `DPCHFE` -- Piecewise Cubic Hermite Function Evaluator. Used when the interval is unknown or the evaluation array spans more than one data interval.
* `DCHFDV` -- Cubic Hermite Function and Derivative Evaluator. Evaluates a single cubic Hermite function and its first derivative at an array of points. Used when the interval is known, as in graphing applications. Called by PCHFD.
* `DPCHFD` -- Piecewise Cubic Hermite Function and Derivative Evaluator. Used when the interval is unknown or the evaluation array spans more than one data interval.
* `DPCHID` -- Piecewise Cubic Hermite Integrator, Data Limits. Computes the definite integral of a piecewise cubic Hermite function when the integration limits are data points.
* `DPCHIA` -- Piecewise Cubic Hermite Integrator, Arbitrary Limits. Computes the definite integral of a piecewise cubic Hermite function over an arbitrary finite interval.3. Utility routines.
* `DPCHBS` -- Piecewise Cubic Hermite to B-Spline converter. Converts a PCH function to B-representation, so that it can be used with other elements of the B-spline package (see `BSPDOC`).
* `DPCHCM` -- Piecewise Cubic Hermite, Check Monotonicity of. Checks the monotonicity of an arbitrary PCH function. Might be used with PCHSP to build a polyalgorithm for piecewise C-2 interpolation.### Notes
INCFD, the increment between successive elements in the F- and D-arrays is included in the representation of a PCH function in this package to facilitate two-dimensional applications. For "normal" usage INCFD=1, and F and D are one-dimensional arrays. one would call PCHxx (where "xx" is "IM", "IC", or "SP") with
`N, X, F, D, 1`
Suppose, however, that one has data on a rectangular mesh,
`F2D(I,J) = value at (X(I), Y(J)), I=1(1)NX, J=1(1)NY`
Assume the following dimensions:
`REAL(wp) X(NXMAX), Y(NYMAX)`
`REAL(wp) F2D(NXMAX,NYMAX), FX(NXMAX,NYMAX), FY(NXMAX,NYMAX)`where `2<=NX<=NXMAX AND 2<=NY<=NYMAX`. To interpolate in X along the line Y = Y(J), call PCHxx with
`NX, X, F2D(1,J), FX(1,J), 1`
To interpolate along the line X = X(I), call PCHxx with
`NY, Y, F2D(I,1), FY(I,1), NXMAX`
(This example assumes the usual columnwise storage of 2-D arrays in Fortran.)
### Keywords
* cubic hermite interpolation, documentation, monotone interpolation, pchip, piecewise cubic interpolation### Original Author
* F. N. Fritsch, Lawrence Livermore National Laboratory
### References
1. Carl de Boor, "A Practical Guide to Splines", Springer-Verlag, New York, 1978 (esp. Chapter IV, pp.49-62).
2. F. N. Fritsch, "Piecewise Cubic Hermite Interpolation Package", Report UCRL-87285, Lawrence Livermore National Laboratory, July 1982. [Poster presented at the SIAM 30th Anniversary Meeting, 19-23 July 1982.]
3. F. N. Fritsch and J. Butland, "A method for constructing local monotone piecewise cubic interpolants", SIAM Journal on Scientific and Statistical Computing 5, 2 (June 1984), pp. 300-304.
4. F. N. Fritsch and R. E. Carlson, "Monotone piecewise cubic interpolation", SIAM Journal on Numerical Analysis 17, 2 (April 1980), pp. 238-246.
5. F. N. Fritsch, "Representations for parametric cubic splines", Computer Aided Geometric Design 6 (1989), pp.79-82.