forked from johannesgerer/jburkardt-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spline.html
529 lines (493 loc) · 15.5 KB
/
spline.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
<html>
<head>
<title>
SPLINE - Interpolation and Approximation of Data
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
SPLINE <br> Interpolation and Approximation of Data
</h1>
<hr>
<p>
<b>SPLINE</b>
is a C++ library which
constructs and evaluates spline functions.
</p>
<p>
These spline functions are typically used to
<ul>
<li>
interpolate data exactly at a set of points;
</li>
<li>
approximate data at many points, or over an interval.
</li>
</ul>
</p>
<p>
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".
</p>
<p>
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 <b>SPLINE</b> offer a variety of choices for
slinky curves that will make pleasing interpolants of your data.
</p>
<p>
There are a variety of types of approximation curves
available, including:
<ul>
<li>
least squares polynomials,
</li>
<li>
divided difference polynomials,
</li>
<li>
piecewise polynomials,
</li>
<li>
B splines,
</li>
<li>
Bernstein splines,
</li>
<li>
beta splines,
</li>
<li>
Bezier splines,
</li>
<li>
Hermite splines,
</li>
<li>
Overhauser (or Catmull-Rom) splines.
</li>
</ul>
</p>
<p>
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.
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this web page
are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>SPLINE</b> is available in
<a href = "../../c_src/spline/spline.html">a C version</a> and
<a href = "../../cpp_src/spline/spline.html">a C++ version</a> and
<a href = "../../f77_src/spline/spline.html">a FORTRAN77 version</a> and
<a href = "../../f_src/spline/spline.html">a FORTRAN90 version</a> and
<a href = "../../m_src/spline/spline.html">a MATLAB version.</a>
</p>
<h3 align = "center">
Related Data and Programs:
</h3>
<p>
<a href = "../../cpp_src/bernstein_polynomial/bernstein_polynomial.html">
BERNSTEIN_POLYNOMIAL</a>,
a C++ library which
evaluates the Bernstein polynomials,
useful for uniform approximation of functions;
</p>
<p>
<a href = "../../cpp_src/chebyshev/chebyshev.html">
CHEBYSHEV</a>,
a C++ library which
computes the Chebyshev interpolant/approximant to a given function
over an interval.
</p>
<p>
<a href = "../../cpp_src/divdif/divdif.html">
DIVDIF</a>,
a C++ library which
uses divided differences to interpolate data.
</p>
<p>
<a href = "../../cpp_src/hermite_cubic/hermite_cubic.html">
HERMITE_CUBIC</a>,
a C++ 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.
</p>
<p>
<a href = "../../cpp_src/lagrange_interp_1d/lagrange_interp_1d.html">
LAGRANGE_INTERP_1D</a>,
a C++ library which
defines and evaluates the Lagrange polynomial p(x)
which interpolates a set of data, so that p(x(i)) = y(i).
</p>
<p>
<a href = "../../cpp_src/test_approx/test_approx.html">
TEST_APPROX</a>,
a C++ library which
defines test problems for approximation,
provided as a set of (x,y) data.
</p>
<p>
<a href = "../../cpp_src/test_interp_1d/test_interp_1d.html">
TEST_INTERP_1D</a>,
a C++ library which
defines test problems for interpolation of data y(x),
depending on a 1D argument.
</p>
<h3 align = "center">
Reference:
</h3>
<p>
<ol>
<li>
JA Brewer, DC Anderson,<br>
Visual Interaction with Overhauser Curves and Surfaces,<br>
SIGGRAPH 77,<br>
in Proceedings of the 4th Annual Conference on Computer Graphics
and Interactive Techniques,<br>
ASME, July 1977, pages 132-137.
</li>
<li>
Edwin Catmull, Raphael Rom,<br>
A Class of Local Interpolating Splines,<br>
in Computer Aided Geometric Design,<br>
edited by Robert Barnhill, Richard Reisenfeld,<br>
Academic Press, 1974,<br>
ISBN: 0120790505.
</li>
<li>
Samuel Conte, Carl deBoor,<br>
Elementary Numerical Analysis,<br>
Second Edition,<br>
McGraw Hill, 1972,<br>
ISBN: 07-012446-4.
</li>
<li>
Alan Davies, Philip Samuels,<br>
An Introduction to Computational Geometry for Curves and Surfaces,<br>
Clarendon Press, 1996,<br>
ISBN: 0-19-851478-6,<br>
LC: QA448.D38.
</li>
<li>
Carl deBoor,<br>
A Practical Guide to Splines,<br>
Springer, 2001,<br>
ISBN: 0387953663.
</li>
<li>
Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart,<br>
LINPACK User's Guide,<br>
SIAM, 1979,<br>
ISBN13: 978-0-898711-72-1.
</li>
<li>
Gisela Engeln-Muellges, Frank Uhlig,<br>
Numerical Algorithms with C,<br>
Springer, 1996,<br>
ISBN: 3-540-60530-4.
</li>
<li>
James Foley, Andries vanDam, Steven Feiner, John Hughes,<br>
Computer Graphics, Principles and Practice,<br>
Second Edition,<br>
Addison Wesley, 1995,<br>
ISBN: 0201848406,<br>
LC: T385.C5735.
</li>
<li>
Fred Fritsch, Judy Butland,<br>
A Method for Constructing Local Monotone Piecewise
Cubic Interpolants,<br>
SIAM Journal on Scientific and Statistical Computing,<br>
Volume 5, Number 2, 1984, pages 300-304.
</li>
<li>
Fred Fritsch, Ralph Carlson,<br>
Monotone Piecewise Cubic Interpolation,<br>
SIAM Journal on Numerical Analysis,<br>
Volume 17, Number 2, April 1980, pages 238-246.
</li>
<li>
David Kahaner, Cleve Moler, Steven Nash,<br>
Numerical Methods and Software,<br>
Prentice Hall, 1989,<br>
ISBN: 0-13-627258-4,<br>
LC: TA345.K34.
</li>
<li>
David Rogers, Alan Adams,<br>
Mathematical Elements of Computer Graphics,<br>
Second Edition,<br>
McGraw Hill, 1989,<br>
ISBN: 0070535299.
</li>
</ol>
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<ul>
<li>
<a href = "spline.cpp">spline.cpp</a>, the source code;
</li>
<li>
<a href = "spline.hpp">spline.hpp</a>, the include file;
</li>
<li>
<a href = "spline.sh">spline.sh</a>,
commands to compile the source code;
</li>
</ul>
</p>
<h3 align = "center">
Examples and Tests:
</h3>
<p>
<ul>
<li>
<a href = "spline_prb.cpp">spline_prb.cpp</a>, the calling program;
</li>
<li>
<a href = "spline_prb.sh">spline_prb.sh</a>,
commands to compile, link and run the calling program;
</li>
<li>
<a href = "spline_prb_output.txt">spline_prb_output.txt</a>,
the output file.
</li>
</ul>
</p>
<h3 align = "center">
List of Routines:
</h3>
<p>
<ul>
<li>
<b>BASIS_FUNCTION_B_VAL</b> evaluates the B spline basis function.
</li>
<li>
<b>BASIS_FUNCTION_BETA_VAL</b> evaluates the beta spline basis function.
</li>
<li>
<b>BASIS_MATRIX_B_UNI</b> sets up the uniform B spline basis matrix.
</li>
<li>
<b>BASIS_MATRIX_BETA_UNI</b> sets up the uniform beta spline basis matrix.
</li>
<li>
<b>BASIS_MATRIX_BEZIER_UNI</b> sets up the cubic Bezier spline basis matrix.
</li>
<li>
<b>BASIS_MATRIX_HERMITE</b> sets up the Hermite spline basis matrix.
</li>
<li>
<b>BASIS_MATRIX_OVERHAUSER_NONUNI</b> sets the nonuniform Overhauser spline basis matrix.
</li>
<li>
<b>BASIS_MATRIX_OVERHAUSER_NUL</b> sets the nonuniform left Overhauser spline basis matrix.
</li>
<li>
<b>BASIS_MATRIX_OVERHAUSER_NUR</b> sets the nonuniform right Overhauser spline basis matrix.
</li>
<li>
<b>BASIS_MATRIX_OVERHAUSER_UNI</b> sets the uniform Overhauser spline basis matrix.
</li>
<li>
<b>BASIS_MATRIX_OVERHAUSER_UNI_L</b> sets the left uniform Overhauser spline basis matrix.
</li>
<li>
<b>BASIS_MATRIX_OVERHAUSER_UNI_R</b> sets the right uniform Overhauser spline basis matrix.
</li>
<li>
<b>BASIS_MATRIX_TMP</b> computes Q = T * MBASIS * P
</li>
<li>
<b>BC_VAL</b> evaluates a parameterized Bezier curve.
</li>
<li>
<b>BEZ_VAL</b> evaluates a Bezier function at a point.
</li>
<li>
<b>BP_APPROX</b> evaluates the Bernstein polynomial for F(X) on [A,B].
</li>
<li>
<b>BP01</b> evaluates the Bernstein basis polynomials for [0,1] at a point.
</li>
<li>
<b>BPAB</b> evaluates the Bernstein basis polynomials for [A,B] at a point.
</li>
<li>
<b>CHFEV</b> evaluates a cubic polynomial given in Hermite form.
</li>
<li>
<b>D3_MXV</b> multiplies a D3 matrix times a vector.
</li>
<li>
<b>D3_NP_FS</b> factors and solves a D3 system.
</li>
<li>
<b>D3_PRINT</b> prints a D3 matrix.
</li>
<li>
<b>D3_PRINT_SOME</b> prints some of a D3 matrix.
</li>
<li>
<b>D3_UNIFORM</b> randomizes a D3 matrix.
</li>
<li>
<b>DATA_TO_DIF</b> sets up a divided difference table from raw data.
</li>
<li>
<b>DIF_VAL</b> evaluates a divided difference polynomial at a point.
</li>
<li>
<b>I4_MAX</b> returns the maximum of two I4's.
</li>
<li>
<b>I4_MIN</b> returns the smaller of two I4's.
</li>
<li>
<b>LEAST_SET</b> defines a least squares polynomial for given data.
</li>
<li>
<b>LEAST_VAL</b> evaluates a least squares polynomial defined by LEAST_SET.
</li>
<li>
<b>LEAST_VAL2</b> evaluates a least squares polynomial defined by LEAST_SET.
</li>
<li>
<b>LEAST_SET_OLD</b> constructs the least squares polynomial approximation to data.
</li>
<li>
<b>LEAST_VAL_OLD</b> evaluates a least squares polynomial defined by LEAST_SET_OLD.
</li>
<li>
<b>PARABOLA_VAL2</b> evaluates a parabolic function through 3 points in a table.
</li>
<li>
<b>PCHST:</b> PCHIP sign-testing routine.
</li>
<li>
<b>R8_MAX</b> returns the maximum of two R8's.
</li>
<li>
<b>R8_MIN</b> returns the minimum of two R8's.
</li>
<li>
<b>R8_UNIFORM_01</b> is a portable pseudorandom number generator.
</li>
<li>
<b>R8VEC_BRACKET</b> searches a sorted array for successive brackets of a value.
</li>
<li>
<b>R8VEC_BRACKET3</b> finds the interval containing or nearest a given value.
</li>
<li>
<b>R8VEC_EVEN</b> returns N real values, evenly spaced between ALO and AHI.
</li>
<li>
<b>R8VEC_INDICATOR</b> sets an R8VEC to the indicator vector.
</li>
<li>
<b>R8VEC_ORDER_TYPE</b> determines if an R8VEC is (non)strictly ascending/descending.
</li>
<li>
<b>R8VEC_PRINT</b> prints an R8VEC.
</li>
<li>
<b>R8VEC_SORT_BUBBLE_A</b> ascending sorts an R8VEC using bubble sort.
</li>
<li>
<b>R8VEC_UNIFORM</b> returns a scaled pseudorandom R8VEC.
</li>
<li>
<b>R8VEC_UNIQUE_COUNT</b> counts the unique elements in an unsorted real array.
</li>
<li>
<b>R8VEC_ZERO</b> zeroes an R8VEC.
</li>
<li>
<b>SPLINE_B_VAL</b> evaluates a cubic B spline approximant.
</li>
<li>
<b>SPLINE_BETA_VAL</b> evaluates a cubic beta spline approximant.
</li>
<li>
<b>SPLINE_CONSTANT_VAL</b> evaluates a piecewise constant spline at a point.
</li>
<li>
<b>SPLINE_CUBIC_SET</b> computes the second derivatives of a piecewise cubic spline.
</li>
<li>
<b>SPLINE_CUBIC_VAL</b> evaluates a piecewise cubic spline at a point.
</li>
<li>
<b>SPLINE_CUBIC_VAL2</b> evaluates a piecewise cubic spline at a point.
</li>
<li>
<b>SPLINE_HERMITE_SET</b> sets up a piecewise cubic Hermite interpolant.
</li>
<li>
<b>SPLINE_HERMITE_VAL</b> evaluates a piecewise cubic Hermite interpolant.
</li>
<li>
<b>SPLINE_LINEAR_INT</b> evaluates the integral of a piecewise linear spline.
</li>
<li>
<b>SPLINE_LINEAR_INTSET</b> sets a piecewise linear spline with given integral properties.
</li>
<li>
<b>SPLINE_LINEAR_VAL</b> evaluates a piecewise linear spline at a point.
</li>
<li>
<b>SPLINE_OVERHAUSER_NONUNI_VAL</b> evaluates the nonuniform Overhauser spline.
</li>
<li>
<b>SPLINE_OVERHAUSER_UNI_VAL</b> evaluates the uniform Overhauser spline.
</li>
<li>
<b>SPLINE_OVERHAUSER_VAL</b> evaluates an Overhauser spline.
</li>
<li>
<b>SPLINE_PCHIP_SET</b> sets derivatives for a piecewise cubic Hermite interpolant.
</li>
<li>
<b>SPLINE_PCHIP_VAL</b> evaluates a piecewise cubic Hermite function.
</li>
<li>
<b>SPLINE_QUADRATIC_VAL</b> evaluates a piecewise quadratic spline at a point.
</li>
<li>
<b>TIMESTAMP</b> prints the current YMDHMS date as a time stamp.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../cpp_src.html">
the C++ source codes</a>.
</p>
<hr>
<i>
Last revised on 10 October 2012.
</i>
<!-- John Burkardt -->
</body>
</html>