c++ cubic spline library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.



c++ cubic spline library


It generates a piecewise polynomial function of degree 3 and is twice continuously differentiable everywhere. Boundary conditions default to zero-curvature at the end points. It extrapolates linearly, if default boundary conditions are used, or otherwise extrapolation is a quadratic function.


The library is a header-only file and can be used like this:

#include "spline.h"
int main(int argc, char** argv)
    std::vector<double> X, Y;
    tk::spline s;
    s.set_points(X,Y);    // X needs to be sorted, strictly increasing
    double value=s(1.5);  // interpolated value at 1.5

Optionally, boundary condition can be modified via set_boundary(), which needs to be called before set_points().