Enrico Bertolazzi - Homepage

Splines
Spline Interpolation
 All Classes Namespaces Functions Groups Pages
Author
Enrico Bertolazzi (enric.nosp@m.o.be.nosp@m.rtola.nosp@m.zzi@.nosp@m.unitn.nosp@m..it), homepage: http://www.ing.unitn.it/~bertolaz
Version
1.0.0
Date
2013

This library is available at

Splines

Splines is a set of C++ classes which implements varios spline interpolation. The classes are the following:

References

Usage

The usage is simple:

#include "Splines.hh"
using namespace SplinesLoad ;
....
CubicSpline spline ;
double x[] = {1,2,3,4} ;
double y[] = {3,1,1,3} ;
spline.build(x,y,4) ; // build a cubic spline with 4 points
cout << spline(1.1) << '\n'; // spline at x = 1.1
cout << spline.D(1.1) << '\n'; // spline first derivative at x = 1.1
cout << spline.DD(1.1) << '\n'; // spline second derivative at x = 1.1
cout << spline.DDD(1.1) << '\n'; // spline third derivative at x = 1.1

splines can be built incrementally

#include "Splines.hh"
using namespace SplinesLoad ;
....
CubicSpline spline ;
spline . pushBack( 1, 3 ) ;
spline . pushBack( 2, 1 ) ;
spline . pushBack( 3, 1 ) ;
spline . pushBack( 4, 3 ) ;
spline . build() ;
cout << spline(1.1) << '\n'; // spline at x = 1.1
cout << spline.D(1.1) << '\n'; // spline first derivative at x = 1.1
cout << spline.DD(1.1) << '\n'; // spline second derivative at x = 1.1
cout << spline.DDD(1.1) << '\n'; // spline third derivative at x = 1.1

or by using standard vector

#include "Splines.hh"
#include <vector>
using namespace SplinesLoad ;
using namespace std ;
....
CubicSpline spline ;
std::vector x, y ;
x.push_back(1) ; y.push_back(3) ;
x.push_back(2) ; y.push_back(1) ;
x.push_back(3) ; y.push_back(1) ;
x.push_back(4) ; y.push_back(3) ;
spline . build(x,y) ;
cout << spline(1.1) << '\n'; // spline at x = 1.1
cout << spline.D(1.1) << '\n'; // spline first derivative at x = 1.1
cout << spline.DD(1.1) << '\n'; // spline second derivative at x = 1.1
cout << spline.DDD(1.1) << '\n'; // spline third derivative at x = 1.1

Compile and tests

Edit makefile file to match compiler of your OS and do:

make

To run the test

make run

To generate documentation (using DOXYGEN: http://www.stack.nl/~dimitri/doxygen/index.html)

make doc

DOXYGEN documentation

Available at: http://www.ing.unitn.it/~bertolaz/4-software/Splines/index.html