spline
spline,
a MATLAB code which
sets up and evaluates splines.
These spline functions are typically used to

interpolate data exactly at a set of points;

approximate data at many points, or over an interval.
The most common use of this software is for situations where
a set of (X,Y) data points is known, and it is desired to
determine a smooth function which passes exactly through
those points, and which can be evaluated everywhere.
Thus, it is possible to get a formula that allows you to
"connect the dots".
Of course, you could could just connect the dots with
straight lines, but that would look ugly, and if there really
is some function that explains your data, you'd expect it to
curve around rather than make sudden angular turns. The
functions in SPLINE offer a variety of choices for
slinky curves that will make pleasing interpolants of your data.
There are a variety of types of approximation curves
available, including:

least squares polynomials,

divided difference polynomials,

piecewise polynomials,

B splines,

Bernstein splines,

beta splines,

Bezier splines,

Hermite splines,

Overhauser (or CatmullRom) splines.
Also included are a set of routines that return the local "basis matrix",
which allows the evaluation of the spline in terms of local function
data.
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Languages:
spline is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version.
Related Data and Programs:
bernstein_polynomial,
a MATLAB code which
evaluates the Bernstein polynomials,
useful for uniform approximation of functions;
chebyshev,
a MATLAB code which
computes the Chebyshev interpolant/approximant to a given function
over an interval.
divdif,
a MATLAB code which
uses divided differences to interpolate data.
hermite_interpolant,
a MATLAB code which
computes the Hermite interpolant, a polynomial that matches function values
and derivatives.
hermite_cubic,
a MATLAB code which
can compute the value, derivatives or integral of a Hermite cubic polynomial,
or manipulate an interpolating function made up of piecewise Hermite cubic
polynomials.
interp,
a MATLAB code which
can be used for parameterizing and interpolating data;
lagrange_interp_1d,
a MATLAB code which
defines and evaluates the Lagrange polynomial p(x)
which interpolates a set of data, so that p(x(i)) = y(i).
spline_test
test_approx,
a MATLAB code which
defines a number of test problems for approximation and interpolation.
test_interp,
a MATLAB code which
defines a number of test problems for interpolation.
test_interp_1d,
a MATLAB code which
defines test problems for interpolation of data y(x),
depending on a 1D argument.
vandermonde_approx_1d,
a MATLAB code which
finds a polynomial approximant to a function of 1D data
by setting up and solving an overdetermined linear system for the polynomial coefficients,
involving the Vandermonde matrix.
vandermonde_interp_1d,
a MATLAB code which
finds a polynomial interpolant to a function of 1D data
by setting up and solving a linear system for the polynomial coefficients,
involving the Vandermonde matrix.
Reference:

JA Brewer, DC Anderson,
Visual Interaction with Overhauser Curves and Surfaces,
SIGGRAPH 77,
in Proceedings of the 4th Annual Conference on Computer Graphics
and Interactive Techniques,
ASME, July 1977, pages 132137.

Edwin Catmull, Raphael Rom,
A Class of Local Interpolating Splines,
in Computer Aided Geometric Design,
edited by Robert Barnhill, Richard Reisenfeld,
Academic Press, 1974,
ISBN: 0120790505.

Samuel Conte, Carl deBoor,
Elementary Numerical Analysis,
Second Edition,
McGraw Hill, 1972,
ISBN: 070124464.

Alan Davies, Philip Samuels,
An Introduction to Computational Geometry for Curves and Surfaces,
Clarendon Press, 1996,
ISBN: 0198514786,
LC: QA448.D38.

Carl deBoor,
A Practical Guide to Splines,
Springer, 2001,
ISBN: 0387953663.

Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart,
LINPACK User's Guide,
SIAM, 1979,
ISBN13: 9780898711721.

Gisela EngelnMuellges, Frank Uhlig,
Numerical Algorithms with C,
Springer, 1996,
ISBN: 3540605304.

James Foley, Andries vanDam, Steven Feiner, John Hughes,
Computer Graphics, Principles and Practice,
Second Edition,
Addison Wesley, 1995,
ISBN: 0201848406,
LC: T385.C5735.

Fred Fritsch, Judy Butland,
A Method for Constructing Local Monotone Piecewise
Cubic Interpolants,
SIAM Journal on Scientific and Statistical Computing,
Volume 5, Number 2, 1984, pages 300304.

Fred Fritsch, Ralph Carlson,
Monotone Piecewise Cubic Interpolation,
SIAM Journal on Numerical Analysis,
Volume 17, Number 2, April 1980, pages 238246.

David Kahaner, Cleve Moler, Steven Nash,
Numerical Methods and Software,
Prentice Hall, 1989,
ISBN: 0136272584,
LC: TA345.K34.

David Rogers, Alan Adams,
Mathematical Elements of Computer Graphics,
Second Edition,
McGraw Hill, 1989,
ISBN: 0070535299.
Source Code:

basis_function_b_val.m,
evaluates the B spline basis function at a point.

basis_function_beta_val.m,
evaluates the beta spline basis function at a point.

basis_matrix_b_uni.m,
sets up the uniform B spline basis matrix.

basis_matrix_beta_uni.m,
sets up the uniform beta spline basis matrix.

basis_matrix_bezier.m,
sets up a cubic Bezier spline basis matrix.

basis_matrix_hermite.m,
sets up a Hermite spline basis matrix.

basis_matrix_overhauser_nonuni.m,
sets up a nonuniform Overhauser spline basis matrix.

basis_matrix_overhauser_nul.m,
sets up a nonuniform left Overhauser spline basis matrix.

basis_matrix_overhauser_nur.m,
sets up a nonuniform right Overhauser spline basis matrix.

basis_matrix_overhauser_uni.m,
sets up the uniform Overhauser spline basis matrix.

basis_matrix_overhauser_uni_l.m,
sets up the left uniform Overhauser spline basis matrix.

basis_matrix_overhauser_uni_r.m,
sets up the right uniform Overhauser spline basis matrix.

basis_matrix_tmp.m,
computes Q = T * MBASIS * P.

bc_val.m,
evaluates a parameterized Bezier curve.

bez_val.m,
evaluates a Bezier function at a point.

bpab_approx.m,
evaluate the Bernstein polynomial for F(X) on [A,B].

bpab.m,
evaluates the Bernstein basis polynomials for [A,B] at a point.

chfev.m,
evaluates a Hermite cubic function.

d3_mxv.m,
multiplies an D3 matrix times a vector.

d3_np_fs.m,
factors and solves an D3 linear system with no pivoting.

d3_uniform.m,
returns a random D3 matrix.

data_to_dif.m,
sets up a divided difference table from raw data.

dif_val.m,
evaluates a divided difference polynomial at a point.

least_set_old.m,
constructs the least squares polynomial approximation to data.

least_val_old.m,
evaluates a least squares polynomial defined by LEAST_SET_OLD.

least_set.m,
returns the least squares polynomial that approximates
given data;

least_val.m,
evaluates the least squares polynomial that approximates
given data;

least_val2.m,
evaluates the least squares polynomial, and its derivative,
that approximates given data;

parabola_val2.m,
evaluates a parabolic interpolant through tabulated data.

pchst.m,
PCHIP sign change checker.

r8_uniform_01.m,
is a uniform random number generator.

r8vec_bracket.m,
searches a sorted array for successive brackets of a value.

r8vec_bracket3.m,
finds the interval containing or nearest a given value.

r8vec_distinct.m,
is true if the elements of a real vector are distinct.

r8vec_indicator.m,
sets a real vector to the indicator vector.

r8vec_order_type.m,
finds if a real vector is (non)strictly ascending/descending.

r8vec_print.m,
prints a real vector.

r8vec_sort_bubble_a.m,
ascending sorts a real vector using bubble sort.

r8vec_unique_count.m,
counts the number of unique elements in an unsorted R8VEC;

s_len_trim.m,
returns the length of a character string to the last nonblank.

spline_b_val.m,
evaluates a cubic spline approximant at a point.

spline_beta_val.m,
evaluates a cubic beta spline approximant at a point.

spline_constant_val.m,
evaluates a piecewise constant spline at a point.

spline_cubic_set.m,
computes the second derivatives of a cubic spline.

spline_cubic_val.m,
evaluates a piecewise cubic spline at a point.

spline_cubic_val2.m,
evaluates a piecewise cubic spline at a point.

spline_hermite_set.m,
sets up a piecewise cubic Hermite interpolant spline.

spline_hermite_val.m,
evaluates a piecewise cubic Hermite spline at a point.

spline_linear_int.m,
evaluates the integral of a piecewise linear spline.

spline_linear_intset.m,
sets a piecewise linear spline with given integral properties.

spline_linear_val.m,
evaluates a piecewise linear spline at a point.

spline_overhauser_nonuni_val.m,
evaluates a nonuniform Overhauser spline at a point.

spline_overhauser_uni_val.m,
evaluates a uniform Overhauser spline at a point.

spline_overhauser_val.m,
evaluates an Overhauser spline at a point.

spline_pchip_set.m,
defines a PCHIP spline for given data.

spline_pchip_val.m,
evaluates a PCHIP spline at a point.

spline_quadratic_val.m,
evaluates a piecewise quadratic spline at a point.
Last revised on 24 March 2019.