SPLINE
Interpolation and Approximation of Data
SPLINE
is a MATLAB library 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 Catmull-Rom) 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 FORTRAN77 version and
a FORTRAN90 version and
a MATLAB version.
Related Data and Programs:
BERNSTEIN,
a MATLAB library which
evaluates the Bernstein polynomials,
useful for uniform approximation of functions;
CHEBYSHEV,
a MATLAB library which
computes the Chebyshev interpolant/approximant to a given function
over an interval.
DIVDIF,
a MATLAB library which
uses divided differences to interpolate data.
HERMITE,
a MATLAB library which
computes the Hermite interpolant, a polynomial that matches function values
and derivatives.
HERMITE_CUBIC,
a MATLAB library 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 library which
can be used for parameterizing and interpolating data;
LAGRANGE_INTERP_1D,
a MATLAB library which
defines and evaluates the Lagrange polynomial p(x)
which interpolates a set of data, so that p(x(i)) = y(i).
TEST_APPROX,
a MATLAB library which
defines a number of test problems for approximation and interpolation.
TEST_INTERP,
a MATLAB library which
defines a number of test problems for interpolation.
TEST_INTERP_1D,
a MATLAB library which
defines test problems for interpolation of data y(x),
depending on a 1D argument.
VANDERMONDE_APPROX_1D,
a MATLAB library 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 library 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 132-137.
-
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: 07-012446-4.
-
Alan Davies, Philip Samuels,
An Introduction to Computational Geometry for Curves and Surfaces,
Clarendon Press, 1996,
ISBN: 0-19-851478-6,
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: 978-0-898711-72-1.
-
Gisela Engeln-Muellges, Frank Uhlig,
Numerical Algorithms with C,
Springer, 1996,
ISBN: 3-540-60530-4.
-
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 300-304.
-
Fred Fritsch, Ralph Carlson,
Monotone Piecewise Cubic Interpolation,
SIAM Journal on Numerical Analysis,
Volume 17, Number 2, April 1980, pages 238-246.
-
David Kahaner, Cleve Moler, Steven Nash,
Numerical Methods and Software,
Prentice Hall, 1989,
ISBN: 0-13-627258-4,
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_even.m,
returns N real values evenly spaced between ALO and AHI.
-
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_uniform.m,
returns a random real vector.
-
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.
-
timestamp.m,
prints the current YMDHMS date as a timestamp.
Examples and Tests:
-
spline_test.m,
runs all the tests;
-
spline_test_output.txt,
output from all the tests;
-
fcube.m,
evaluates a cubic function;
-
fpcube.m,
evaluates the derivative of a cubic function;
-
fppcube.m,
evaluates the second derivative of a cubic function;
-
frunge.m,
evaluates the Runge function;
-
fprunge.m,
evaluates the derivative of the Runge function;
-
fpprunge.m,
evaluates the second derivative of the Runge function;
-
spline_test001.m,
tests PARABOLA_VAL2;
-
spline_test002.m,
tests R8VEC_BRACKET;
-
spline_test003.m,
tests R8VEC_BRACKET3;
-
spline_test004.m,
tests R8VEC_ORDER_TYPE;
-
spline_test005.m,
tests D3_NP_FS;
-
spline_test006.m,
tests DATA_TO_DIF and DIF_VAL;
-
spline_test01.m,
tests BASIS_FUNCTION_B_VAL;
-
spline_test02.m,
tests BASIS_FUNCTION_BETA_VAL;
-
spline_test03.m,
tests BASIS_MATRIX_B_UNI and BASIS_MATRIX_TMP;
-
spline_test04.m,
tests BASIS_FUNCTION_BETA_UNI and BASIS_MATRIX_TMP;
-
spline_test05.m,
tests BASIS_FUNCTION_BEZIER and BASIS_MATRIX_TMP;
-
spline_test06.m,
tests BASIS_MATRIX_HERMITE and BASIS_MATRIX_TMP;
-
spline_test07.m,
tests BASIS_OVERHAUSER_UNI and BASIS_MATRIX_TMP;
-
spline_test08.m,
tests BASIS_OVERHAUSER_NONUNI and BASIS_MATRIX_TMP;
-
spline_test09.m,
tests BASIS_OVERHAUSER_NONUNI and BASIS_MATRIX_TMP;
-
spline_test10.m,
tests BC_VAL;
-
spline_test11.m,
tests BEZ_VAL;
-
spline_test115.m,
tests BP01;
-
spline_test116.m,
tests BPAB;
-
spline_test12.m,
tests BP_APPROX;
-
spline_test125.m,
tests LEAST_SET_OLD and LEAST_VAL_OLD;
-
subpak_test126.m,
tests LEAST_SET and LEAST_VAL;
-
subpak_test127.m,
tests LEAST_SET and LEAST_VAL2;
-
spline_test13.m,
tests SPLINE_B_VAL;
-
spline_test14.m,
tests SPLINE_BETA_VAL;
-
spline_test145.m,
tests SPLINE_CONSTANT_VAL;
-
spline_test15.m,
tests SPLINE_CUBIC_SET and SPLINE_CUBIC_VAL;
-
spline_test16.m,
tests SPLINE_CUBIC_SET and SPLINE_CUBIC_VAL2;
-
spline_test17.m,
tests SPLINE_CUBIC_SET and SPLINE_CUBIC_VAL;
-
spline_test18.m,
tests SPLINE_CUBIC_SET and SPLINE_CUBIC_VAL;
-
spline_test19.m,
tests SPLINE_CUBIC_SET and SPLINE_CUBIC_VAL;
-
spline_test20.m,
tests SPLINE_HERMITE_SET and SPLINE_HERMITE_VAL;
-
spline_test205.m,
tests SPLINE_LINEAR_INT and SPLINE_LINEAR_INTSET;
-
spline_test21.m,
tests SPLINE_LINEAR_VAL;
-
spline_test215.m,
tests SPLINE_LINEAR_INT;
-
spline_test22.m,
tests SPLINE_OVERHAUSER_UNI_VAL;
-
spline_test225.m,
tests SPLINE_OVERHAUSER_NONUNI_VAL;
-
spline_test23.m,
tests SPLINE_OVERHAUSER_VAL;
-
spline_test235.m,
tests SPLINE_PCHIP_SET and SPLINE_PCHIP_VAL;
-
spline_test24.m,
tests SPLINE_QUADRATIC_VAL;
You can go up one level to
the MATLAB source codes.
Last revised on 29 January 2007.