2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Merge branch 'develop' into complex_newton

This commit is contained in:
Nick Thompson
2018-12-04 14:28:52 -07:00
35 changed files with 1769 additions and 160 deletions

View File

@@ -69,7 +69,7 @@ boostbook standalone
<format>pdf:<xsl:param>preferred.mediaobject.role=print
<format>pdf:<xsl:param>img.src.path=$(images_location)/
<format>pdf:<xsl:param>draft.mode="no"
<format>pdf:<xsl:param>boost.url.prefix=https\://www.boost.org/doc/libs/release/libs/math/doc/html
<format>pdf:<xsl:param>boost.url.prefix=http\://www.boost.org/doc/libs/release/libs/math/doc/html
<auto-index>on <format>pdf:<auto-index-internal>off
<format>html:<auto-index-internal>on
<auto-index-script>$(here)/index.idx

View File

@@ -23,12 +23,14 @@ see [link math_toolkit.tutorial.templ use in template code].
* Tested - by comparison with other published sources, or separately computed at long double precision.
* Faster - can avoid (re-)calculation at runtime.
* If the value returned is a builtin type then it's returned by value as a `constexpr` (C++11 feature, if available).
* If the value is computed and cached (or constructed from a string representation and cached), then it's returned by constant reference.[br]
This can be significant if:
* Functions pow, trig or log are used.
* Inside an inner loop.
* Using a high-precision UDT like __multiprecision.
* Compiler optimizations possible with built-in types, especially `double`, are not available.
* If the value is computed and cached (or constructed from a string representation and cached), then it's returned by constant reference.
This can be
significant if:
* Functions pow, trig or log are used.
* Inside an inner loop.
* Using a high-precision UDT like __multiprecision.
* Compiler optimizations possible with built-in types, especially `double`, are not available.
[endsect] [/section:intro Introduction]
@@ -508,7 +510,8 @@ Some of the criteria we have used are:
* Expensive to compute.
* Requested by users.
* [@http://en.wikipedia.org/wiki/Mathematical_constant Used in science and mathematics.]
* No integer values (because so cheap to construct).[br]
* No integer values (because so cheap to construct).
(You can easily define your own if found convenient, for example: `FPT one =static_cast<FPT>(42);`).
[h4 How are constants named?]

View File

@@ -168,7 +168,8 @@ and [@http://en.wikipedia.org/wiki/Parameter distribution parameters]
are conventionally distinguished (for example in Wikipedia and Wolfram MathWorld)
by placing a semi-colon or vertical bar)
/after/ the __random_variable (whose value you 'choose'),
to separate the variate from the parameter(s) that defines the shape of the distribution.[br]
to separate the variate from the parameter(s) that defines the shape of the distribution.
For example, the binomial distribution probability distribution function (PDF) is written as
['f(k| n, p)] = Pr(K = k|n, p) = probability of observing k successes out of n trials.
K is the __random_variable, k is the __random_variate,

View File

@@ -122,7 +122,7 @@ This manual is also available in <a href="http://sourceforge.net/projects/boost/
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: November 22, 2018 at 17:45:57 GMT</small></p></td>
<td align="left"><p><small>Last revised: December 01, 2018 at 19:30:55 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id1788894"></a>Function Index</h2></div></div></div>
<a name="id1776547"></a>Function Index</h2></div></div></div>
<p><a class="link" href="s01.html#idx_id_0">1</a> <a class="link" href="s01.html#idx_id_1">2</a> <a class="link" href="s01.html#idx_id_2">4</a> <a class="link" href="s01.html#idx_id_3">A</a> <a class="link" href="s01.html#idx_id_4">B</a> <a class="link" href="s01.html#idx_id_5">C</a> <a class="link" href="s01.html#idx_id_6">D</a> <a class="link" href="s01.html#idx_id_7">E</a> <a class="link" href="s01.html#idx_id_8">F</a> <a class="link" href="s01.html#idx_id_9">G</a> <a class="link" href="s01.html#idx_id_10">H</a> <a class="link" href="s01.html#idx_id_11">I</a> <a class="link" href="s01.html#idx_id_12">J</a> <a class="link" href="s01.html#idx_id_13">K</a> <a class="link" href="s01.html#idx_id_14">L</a> <a class="link" href="s01.html#idx_id_15">M</a> <a class="link" href="s01.html#idx_id_16">N</a> <a class="link" href="s01.html#idx_id_17">O</a> <a class="link" href="s01.html#idx_id_18">P</a> <a class="link" href="s01.html#idx_id_19">Q</a> <a class="link" href="s01.html#idx_id_20">R</a> <a class="link" href="s01.html#idx_id_21">S</a> <a class="link" href="s01.html#idx_id_22">T</a> <a class="link" href="s01.html#idx_id_23">U</a> <a class="link" href="s01.html#idx_id_24">V</a> <a class="link" href="s01.html#idx_id_25">W</a> <a class="link" href="s01.html#idx_id_26">X</a> <a class="link" href="s01.html#idx_id_27">Y</a> <a class="link" href="s01.html#idx_id_28">Z</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
@@ -805,6 +805,7 @@
<p><span class="index-entry-level-0">defined</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_implementation.html" title="Additional Implementation Notes"><span class="index-entry-level-1">Additional Implementation Notes</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/exact_typdefs.html" title="Exact-Width Floating-Point typedefs"><span class="index-entry-level-1">Exact-Width Floating-Point typedef s</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sign_functions.html" title="Sign Manipulation Functions"><span class="index-entry-level-1">Sign Manipulation Functions</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/special_tut/special_tut_test.html" title="Testing"><span class="index-entry-level-1">Testing</span></a></p></li>
@@ -1624,6 +1625,7 @@
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/gauss.html" title="Gauss-Legendre quadrature"><span class="index-entry-level-1">Gauss-Legendre quadrature</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/naive_monte_carlo.html" title="Naive Monte Carlo Integration"><span class="index-entry-level-1">Naive Monte Carlo Integration</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/double_exponential/de_overview.html" title="Overview"><span class="index-entry-level-1">Overview</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/double_exponential/de_sinh_sinh.html" title="sinh_sinh"><span class="index-entry-level-1">sinh_sinh</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/double_exponential/de_tanh_sinh.html" title="tanh_sinh"><span class="index-entry-level-1">tanh_sinh</span></a></p></li>
</ul></div>
@@ -1750,6 +1752,7 @@
<p><span class="index-entry-level-0">k</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/root_finding_examples/elliptic_eg.html" title="A More complex example - Inverting the Elliptic Integrals"><span class="index-entry-level-1">A More complex example - Inverting the Elliptic Integrals</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/ellint/ellint_intro.html" title="Elliptic Integral Overview"><span class="index-entry-level-1">Elliptic Integral Overview</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/ellint/ellint_1.html" title="Elliptic Integrals of the First Kind - Legendre Form"><span class="index-entry-level-1">Elliptic Integrals of the First Kind - Legendre Form</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/dist_ref/dists/hypergeometric_dist.html" title="Hypergeometric Distribution"><span class="index-entry-level-1">Hypergeometric Distribution</span></a></p></li>
@@ -2321,6 +2324,7 @@
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/root_finding_examples/elliptic_eg.html" title="A More complex example - Inverting the Elliptic Integrals"><span class="index-entry-level-1">A More complex example - Inverting the Elliptic Integrals</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/barycentric.html" title="Barycentric Rational Interpolation"><span class="index-entry-level-1">Barycentric Rational Interpolation</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_poly/chebyshev.html" title="Chebyshev Polynomials"><span class="index-entry-level-1">Chebyshev Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/root_finding_examples/5th_root_eg.html" title="Computing the Fifth Root"><span class="index-entry-level-1">Computing the Fifth Root</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/cf.html" title="Continued Fraction Evaluation"><span class="index-entry-level-1">Continued Fraction Evaluation</span></a></p></li>
@@ -2330,6 +2334,7 @@
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">Graphing, Profiling, and Generating Test Data for Special Functions</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_poly/legendre_stieltjes.html" title="Legendre-Stieltjes Polynomials"><span class="index-entry-level-1">Legendre-Stieltjes Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/brent_minima.html" title="Locating Function Minima using Brent's algorithm"><span class="index-entry-level-1">Locating Function Minima using Brent's algorithm</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/series_evaluation.html" title="Series Evaluation"><span class="index-entry-level-1">Series Evaluation</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/roots_noderiv/root_termination.html" title="Termination Condition Functors"><span class="index-entry-level-1">Termination Condition Functors</span></a></p></li>
</ul></div>
@@ -2346,6 +2351,7 @@
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">P</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/cubic_b.html" title="Cubic B-spline interpolation"><span class="index-entry-level-1">Cubic B-spline interpolation</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_gamma/digamma.html" title="Digamma"><span class="index-entry-level-1">Digamma</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/dist_ref/dist_algorithms.html" title="Distribution Algorithms"><span class="index-entry-level-1">Distribution Algorithms</span></a></p></li>
@@ -2388,9 +2394,11 @@
<p><span class="index-entry-level-0">prime</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/barycentric.html" title="Barycentric Rational Interpolation"><span class="index-entry-level-1">Barycentric Rational Interpolation</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_poly/chebyshev.html" title="Chebyshev Polynomials"><span class="index-entry-level-1">Chebyshev Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/cubic_b.html" title="Cubic B-spline interpolation"><span class="index-entry-level-1">Cubic B-spline interpolation</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_poly/legendre_stieltjes.html" title="Legendre-Stieltjes Polynomials"><span class="index-entry-level-1">Legendre-Stieltjes Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/number_series/primes.html" title="Prime Numbers"><span class="index-entry-level-1">Prime Numbers</span></a></p></li>
</ul></div>
</li>
@@ -2699,7 +2707,9 @@
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_implementation.html" title="Additional Implementation Notes"><span class="index-entry-level-1">Additional Implementation Notes</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/stat_tut/weg/st_eg/tut_mean_intervals.html" title="Calculating confidence intervals on the mean with the Students-t distribution"><span class="index-entry-level-1">Calculating confidence intervals on the mean with the Students-t distribution</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">Graphing, Profiling, and Generating Test Data for Special Functions</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/point_type.html" title="Point types"><span class="index-entry-level-1">Point types</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">Polynomials</span></a></p></li>
</ul></div>
</li>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id1814239"></a>Class Index</h2></div></div></div>
<a name="id1803324"></a>Class Index</h2></div></div></div>
<p><a class="link" href="s02.html#idx_id_32">A</a> <a class="link" href="s02.html#idx_id_33">B</a> <a class="link" href="s02.html#idx_id_34">C</a> <a class="link" href="s02.html#idx_id_35">D</a> <a class="link" href="s02.html#idx_id_36">E</a> <a class="link" href="s02.html#idx_id_37">F</a> <a class="link" href="s02.html#idx_id_38">G</a> <a class="link" href="s02.html#idx_id_39">H</a> <a class="link" href="s02.html#idx_id_40">I</a> <a class="link" href="s02.html#idx_id_43">L</a> <a class="link" href="s02.html#idx_id_44">M</a> <a class="link" href="s02.html#idx_id_45">N</a> <a class="link" href="s02.html#idx_id_46">O</a> <a class="link" href="s02.html#idx_id_47">P</a> <a class="link" href="s02.html#idx_id_48">Q</a> <a class="link" href="s02.html#idx_id_49">R</a> <a class="link" href="s02.html#idx_id_50">S</a> <a class="link" href="s02.html#idx_id_51">T</a> <a class="link" href="s02.html#idx_id_52">U</a> <a class="link" href="s02.html#idx_id_54">W</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
@@ -48,6 +48,10 @@
</dt>
<dd><div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">catmull_rom</span></p>
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li></ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">cauchy_distribution</span></p>
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/dist_ref/dists/cauchy_dist.html" title="Cauchy-Lorentz Distribution"><span class="index-entry-level-1">Cauchy-Lorentz Distribution</span></a></p></li></ul></div>
</li>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id1813315"></a>Typedef Index</h2></div></div></div>
<a name="id1806579"></a>Typedef Index</h2></div></div></div>
<p><a class="link" href="s03.html#idx_id_61">A</a> <a class="link" href="s03.html#idx_id_62">B</a> <a class="link" href="s03.html#idx_id_63">C</a> <a class="link" href="s03.html#idx_id_64">D</a> <a class="link" href="s03.html#idx_id_65">E</a> <a class="link" href="s03.html#idx_id_66">F</a> <a class="link" href="s03.html#idx_id_67">G</a> <a class="link" href="s03.html#idx_id_68">H</a> <a class="link" href="s03.html#idx_id_69">I</a> <a class="link" href="s03.html#idx_id_72">L</a> <a class="link" href="s03.html#idx_id_74">N</a> <a class="link" href="s03.html#idx_id_75">O</a> <a class="link" href="s03.html#idx_id_76">P</a> <a class="link" href="s03.html#idx_id_78">R</a> <a class="link" href="s03.html#idx_id_79">S</a> <a class="link" href="s03.html#idx_id_80">T</a> <a class="link" href="s03.html#idx_id_81">U</a> <a class="link" href="s03.html#idx_id_82">V</a> <a class="link" href="s03.html#idx_id_83">W</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
@@ -410,6 +410,7 @@
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/oct_typedefs.html" title="Octonion Member Typedefs"><span class="index-entry-level-1">Octonion Member Typedefs</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/oct_specialization.html" title="Octonion Specializations"><span class="index-entry-level-1">Octonion Specializations</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/dist_ref/dists/pareto.html" title="Pareto Distribution"><span class="index-entry-level-1">Pareto Distribution</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/point_type.html" title="Point types"><span class="index-entry-level-1">Point types</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/dist_ref/dists/poisson_dist.html" title="Poisson Distribution"><span class="index-entry-level-1">Poisson Distribution</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/mem_typedef.html" title="Quaternion Member Typedefs"><span class="index-entry-level-1">Quaternion Member Typedefs</span></a></p></li>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id1816850"></a>Macro Index</h2></div></div></div>
<a name="id1810448"></a>Macro Index</h2></div></div></div>
<p><a class="link" href="s04.html#idx_id_91">B</a> <a class="link" href="s04.html#idx_id_95">F</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>

View File

@@ -23,7 +23,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id1821883"></a>Index</h2></div></div></div>
<a name="id1809618"></a>Index</h2></div></div></div>
<p><a class="link" href="s05.html#idx_id_116">1</a> <a class="link" href="s05.html#idx_id_117">2</a> <a class="link" href="s05.html#idx_id_118">4</a> <a class="link" href="s05.html#idx_id_119">A</a> <a class="link" href="s05.html#idx_id_120">B</a> <a class="link" href="s05.html#idx_id_121">C</a> <a class="link" href="s05.html#idx_id_122">D</a> <a class="link" href="s05.html#idx_id_123">E</a> <a class="link" href="s05.html#idx_id_124">F</a> <a class="link" href="s05.html#idx_id_125">G</a> <a class="link" href="s05.html#idx_id_126">H</a> <a class="link" href="s05.html#idx_id_127">I</a> <a class="link" href="s05.html#idx_id_128">J</a> <a class="link" href="s05.html#idx_id_129">K</a> <a class="link" href="s05.html#idx_id_130">L</a> <a class="link" href="s05.html#idx_id_131">M</a> <a class="link" href="s05.html#idx_id_132">N</a> <a class="link" href="s05.html#idx_id_133">O</a> <a class="link" href="s05.html#idx_id_134">P</a> <a class="link" href="s05.html#idx_id_135">Q</a> <a class="link" href="s05.html#idx_id_136">R</a> <a class="link" href="s05.html#idx_id_137">S</a> <a class="link" href="s05.html#idx_id_138">T</a> <a class="link" href="s05.html#idx_id_139">U</a> <a class="link" href="s05.html#idx_id_140">V</a> <a class="link" href="s05.html#idx_id_141">W</a> <a class="link" href="s05.html#idx_id_142">X</a> <a class="link" href="s05.html#idx_id_143">Y</a> <a class="link" href="s05.html#idx_id_144">Z</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
@@ -1492,6 +1492,23 @@
</ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">Catmull-Rom Splines</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">catmull_rom</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">defined</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">K</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">operator</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">P</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">performance</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">prime</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">size</span></a></p></li>
</ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">catmull_rom</span></p>
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li></ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">cauchy</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/dist_ref/dists/cauchy_dist.html" title="Cauchy-Lorentz Distribution"><span class="index-entry-level-1">Cauchy-Lorentz Distribution</span></a></p></li>
@@ -2271,6 +2288,7 @@
<p><span class="index-entry-level-0">defined</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_implementation.html" title="Additional Implementation Notes"><span class="index-entry-level-1">Additional Implementation Notes</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/exact_typdefs.html" title="Exact-Width Floating-Point typedefs"><span class="index-entry-level-1">Exact-Width Floating-Point typedef s</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sign_functions.html" title="Sign Manipulation Functions"><span class="index-entry-level-1">Sign Manipulation Functions</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/special_tut/special_tut_test.html" title="Testing"><span class="index-entry-level-1">Testing</span></a></p></li>
@@ -4505,6 +4523,7 @@
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/gauss.html" title="Gauss-Legendre quadrature"><span class="index-entry-level-1">Gauss-Legendre quadrature</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/naive_monte_carlo.html" title="Naive Monte Carlo Integration"><span class="index-entry-level-1">Naive Monte Carlo Integration</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/double_exponential/de_overview.html" title="Overview"><span class="index-entry-level-1">Overview</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/double_exponential/de_sinh_sinh.html" title="sinh_sinh"><span class="index-entry-level-1">sinh_sinh</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/double_exponential/de_tanh_sinh.html" title="tanh_sinh"><span class="index-entry-level-1">tanh_sinh</span></a></p></li>
</ul></div>
@@ -4791,6 +4810,7 @@
<p><span class="index-entry-level-0">k</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/root_finding_examples/elliptic_eg.html" title="A More complex example - Inverting the Elliptic Integrals"><span class="index-entry-level-1">A More complex example - Inverting the Elliptic Integrals</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/ellint/ellint_intro.html" title="Elliptic Integral Overview"><span class="index-entry-level-1">Elliptic Integral Overview</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/ellint/ellint_1.html" title="Elliptic Integrals of the First Kind - Legendre Form"><span class="index-entry-level-1">Elliptic Integrals of the First Kind - Legendre Form</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/dist_ref/dists/hypergeometric_dist.html" title="Hypergeometric Distribution"><span class="index-entry-level-1">Hypergeometric Distribution</span></a></p></li>
@@ -5853,6 +5873,7 @@
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/root_finding_examples/elliptic_eg.html" title="A More complex example - Inverting the Elliptic Integrals"><span class="index-entry-level-1">A More complex example - Inverting the Elliptic Integrals</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/barycentric.html" title="Barycentric Rational Interpolation"><span class="index-entry-level-1">Barycentric Rational Interpolation</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_poly/chebyshev.html" title="Chebyshev Polynomials"><span class="index-entry-level-1">Chebyshev Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/root_finding_examples/5th_root_eg.html" title="Computing the Fifth Root"><span class="index-entry-level-1">Computing the Fifth Root</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/cf.html" title="Continued Fraction Evaluation"><span class="index-entry-level-1">Continued Fraction Evaluation</span></a></p></li>
@@ -5862,6 +5883,7 @@
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">Graphing, Profiling, and Generating Test Data for Special Functions</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_poly/legendre_stieltjes.html" title="Legendre-Stieltjes Polynomials"><span class="index-entry-level-1">Legendre-Stieltjes Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/brent_minima.html" title="Locating Function Minima using Brent's algorithm"><span class="index-entry-level-1">Locating Function Minima using Brent's algorithm</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/series_evaluation.html" title="Series Evaluation"><span class="index-entry-level-1">Series Evaluation</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/roots_noderiv/root_termination.html" title="Termination Condition Functors"><span class="index-entry-level-1">Termination Condition Functors</span></a></p></li>
</ul></div>
@@ -5906,6 +5928,7 @@
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">P</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/cubic_b.html" title="Cubic B-spline interpolation"><span class="index-entry-level-1">Cubic B-spline interpolation</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_gamma/digamma.html" title="Digamma"><span class="index-entry-level-1">Digamma</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/dist_ref/dist_algorithms.html" title="Distribution Algorithms"><span class="index-entry-level-1">Distribution Algorithms</span></a></p></li>
@@ -5953,6 +5976,7 @@
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/config_macros.html#math_toolkit.config_macros.boost_math_tuning" title="Table&#160;1.12.&#160;Boost.Math Tuning"><span class="index-entry-level-1">Boost.Math Tuning</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/overview_tr1.html" title="C99 and C++ TR1 C-style Functions"><span class="index-entry-level-1">C99 and C++ TR1 C-style Functions</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/main_tr1.html" title="C99 and TR1 C Functions Overview"><span class="index-entry-level-1">C99 and TR1 C Functions Overview</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/comp_compilers.html" title="Comparing Different Compilers"><span class="index-entry-level-1">Comparing Different Compilers</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/root_comparison/cbrt_comparison.html" title="Comparison of Cube Root Finding Algorithms"><span class="index-entry-level-1">Comparison of Cube Root Finding Algorithms</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/comparisons.html" title="Comparisons to Other Open Source Libraries"><span class="index-entry-level-1">Comparisons to Other Open Source Libraries</span></a></p></li>
@@ -6018,6 +6042,13 @@
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/result_type.html" title="Calculation of the Type of the Result"><span class="index-entry-level-1">Calculation of the Type of the Result</span></a></p></li></ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">Point types</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/point_type.html" title="Point types"><span class="index-entry-level-1">size</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/point_type.html" title="Point types"><span class="index-entry-level-1">value_type</span></a></p></li>
</ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">poisson</span></p>
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/dist_ref/dists/poisson_dist.html" title="Poisson Distribution"><span class="index-entry-level-1">Poisson Distribution</span></a></p></li></ul></div>
</li>
@@ -6133,7 +6164,10 @@
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">bool</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">data</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">integrate</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">operator</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">performance</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">prime</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">set_zero</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">size</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">value_type</span></a></p></li>
@@ -6159,9 +6193,11 @@
<p><span class="index-entry-level-0">prime</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/barycentric.html" title="Barycentric Rational Interpolation"><span class="index-entry-level-1">Barycentric Rational Interpolation</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_poly/chebyshev.html" title="Chebyshev Polynomials"><span class="index-entry-level-1">Chebyshev Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/cubic_b.html" title="Cubic B-spline interpolation"><span class="index-entry-level-1">Cubic B-spline interpolation</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_poly/legendre_stieltjes.html" title="Legendre-Stieltjes Polynomials"><span class="index-entry-level-1">Legendre-Stieltjes Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/number_series/primes.html" title="Prime Numbers"><span class="index-entry-level-1">Prime Numbers</span></a></p></li>
</ul></div>
</li>
@@ -6796,7 +6832,9 @@
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/sf_implementation.html" title="Additional Implementation Notes"><span class="index-entry-level-1">Additional Implementation Notes</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/stat_tut/weg/st_eg/tut_mean_intervals.html" title="Calculating confidence intervals on the mean with the Students-t distribution"><span class="index-entry-level-1">Calculating confidence intervals on the mean with the Students-t distribution</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/catmull_rom.html" title="Catmull-Rom Splines"><span class="index-entry-level-1">Catmull-Rom Splines</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">Graphing, Profiling, and Generating Test Data for Special Functions</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/point_type.html" title="Point types"><span class="index-entry-level-1">Point types</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">Polynomials</span></a></p></li>
</ul></div>
</li>
@@ -7683,6 +7721,7 @@
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/oct_typedefs.html" title="Octonion Member Typedefs"><span class="index-entry-level-1">Octonion Member Typedefs</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/oct_specialization.html" title="Octonion Specializations"><span class="index-entry-level-1">Octonion Specializations</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/dist_ref/dists/pareto.html" title="Pareto Distribution"><span class="index-entry-level-1">Pareto Distribution</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/point_type.html" title="Point types"><span class="index-entry-level-1">Point types</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/dist_ref/dists/poisson_dist.html" title="Poisson Distribution"><span class="index-entry-level-1">Poisson Distribution</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/polynomials.html" title="Polynomials"><span class="index-entry-level-1">Polynomials</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/mem_typedef.html" title="Quaternion Member Typedefs"><span class="index-entry-level-1">Quaternion Member Typedefs</span></a></p></li>

View File

@@ -30,6 +30,9 @@
<dl class="toc">
<dt><span class="section"><a href="math_toolkit/cubic_b.html">Cubic B-spline interpolation</a></span></dt>
<dt><span class="section"><a href="math_toolkit/barycentric.html">Barycentric Rational Interpolation</a></span></dt>
<dt><span class="section"><a href="math_toolkit/catmull_rom.html">Catmull-Rom Splines</a></span></dt>
<dt><span class="section"><a href="math_toolkit/point_type.html">Point types</a></span></dt>
<dt><span class="section"><a href="math_toolkit/catmull_rom_refs.html">References</a></span></dt>
</dl>
</div>
</div>

View File

@@ -7,7 +7,7 @@
<link rel="home" href="../index.html" title="Math Toolkit 2.8.0">
<link rel="up" href="../interpolation.html" title="Chapter&#160;10.&#160;Interpolation">
<link rel="prev" href="cubic_b.html" title="Cubic B-spline interpolation">
<link rel="next" href="../quadrature.html" title="Chapter&#160;11.&#160;Quadrature and Differentiation">
<link rel="next" href="catmull_rom.html" title="Catmull-Rom Splines">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="cubic_b.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interpolation.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../quadrature.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="cubic_b.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interpolation.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="catmull_rom.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
@@ -243,7 +243,7 @@ Root was found in 10 iterations.
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="cubic_b.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interpolation.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../quadrature.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="cubic_b.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interpolation.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="catmull_rom.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,233 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Catmull-Rom Splines</title>
<link rel="stylesheet" href="../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Math Toolkit 2.8.0">
<link rel="up" href="../interpolation.html" title="Chapter&#160;10.&#160;Interpolation">
<link rel="prev" href="barycentric.html" title="Barycentric Rational Interpolation">
<link rel="next" href="point_type.html" title="Point types">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="barycentric.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interpolation.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="point_type.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="math_toolkit.catmull_rom"></a><a class="link" href="catmull_rom.html" title="Catmull-Rom Splines">Catmull-Rom Splines</a>
</h2></div></div></div>
<h4>
<a name="math_toolkit.catmull_rom.h0"></a>
<span class="phrase"><a name="math_toolkit.catmull_rom.synopsis"></a></span><a class="link" href="catmull_rom.html#math_toolkit.catmull_rom.synopsis">Synopsis</a>
</h4>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">interpolators</span><span class="special">/</span><span class="identifier">catmull_rom</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Point</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">catmull_rom</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
<span class="identifier">catmull_rom</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Point</span><span class="special">*</span> <span class="keyword">const</span> <span class="identifier">points</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">num_points</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">closed</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">alpha</span> <span class="special">=</span> <span class="special">(</span><span class="identifier">Real</span><span class="special">)</span> <span class="number">1</span><span class="special">/</span> <span class="special">(</span><span class="identifier">Real</span><span class="special">)</span> <span class="number">2</span><span class="special">)</span>
<span class="identifier">catmull_rom</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">Point</span><span class="special">&gt;&amp;&amp;</span> <span class="identifier">points</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">closed</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">alpha</span> <span class="special">=</span> <span class="special">(</span><span class="identifier">Real</span><span class="special">)</span> <span class="number">1</span><span class="special">/</span> <span class="special">(</span><span class="identifier">Real</span><span class="special">)</span> <span class="number">2</span><span class="special">)</span>
<span class="identifier">Real</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Real</span> <span class="identifier">s</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="identifier">Real</span> <span class="identifier">max_parameter</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
<span class="identifier">Real</span> <span class="identifier">parameter_at_point</span><span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="identifier">Point</span> <span class="identifier">prime</span><span class="special">(</span><span class="identifier">Real</span> <span class="identifier">s</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">};</span>
<span class="special">}}</span>
</pre>
<h4>
<a name="math_toolkit.catmull_rom.h1"></a>
<span class="phrase"><a name="math_toolkit.catmull_rom.description"></a></span><a class="link" href="catmull_rom.html#math_toolkit.catmull_rom.description">Description</a>
</h4>
<p>
Catmull-Rom splines are a family of interpolating curves which are commonly
used in computer graphics and animation. Catmull-Rom splines enjoy the following
properties:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Affine invariance: The interpolant commutes with affine transformations.
</li>
<li class="listitem">
Local support of the basis functions: This gives stability and fast evaluation.
</li>
<li class="listitem">
Smoothness
</li>
<li class="listitem">
Interpolation of control points: Many curves (such as Bezier) are <span class="bold"><strong>approximating</strong></span>, they do not pass through their control
points. This makes them more difficult to use than interpolating splines.
</li>
</ul></div>
<p>
The <code class="computeroutput"><span class="identifier">catmull_rom</span></code> class provided
by boost creates a cubic Catmull-Rom spline from an array of points in any
dimension. Since there are numerous ways to represent a point in <span class="emphasis"><em>n</em></span>-dimensional
space, the class attempts to be flexible by templating on the point type. The
requirements on the point type are discussing in more detail below, but roughly,
it must have a dereference operator defined (i.e., <code class="computeroutput"><span class="identifier">p</span><span class="special">[</span><span class="number">0</span><span class="special">]</span></code>
is not a syntax error), it must be able to be dereferenced up to <code class="computeroutput"><span class="identifier">dimension</span> <span class="special">-</span><span class="number">1</span></code>, and <code class="computeroutput"><span class="identifier">p</span><span class="special">[</span><span class="identifier">i</span><span class="special">]</span></code>
is of type <code class="computeroutput"><span class="identifier">Real</span></code>, define <code class="computeroutput"><span class="identifier">value_type</span></code>, and the free function <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code>. These
requirements are met by <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span></code>
and <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span></code>. The basic usage is shown here:
</p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">,</span> <span class="number">3</span><span class="special">&gt;&gt;</span> <span class="identifier">points</span><span class="special">(</span><span class="number">4</span><span class="special">);</span>
<span class="identifier">points</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">=</span> <span class="special">{</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">};</span>
<span class="identifier">points</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">=</span> <span class="special">{</span><span class="number">1</span><span class="special">,</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">};</span>
<span class="identifier">points</span><span class="special">[</span><span class="number">2</span><span class="special">]</span> <span class="special">=</span> <span class="special">{</span><span class="number">0</span><span class="special">,</span><span class="number">1</span><span class="special">,</span><span class="number">0</span><span class="special">};</span>
<span class="identifier">points</span><span class="special">[</span><span class="number">3</span><span class="special">]</span> <span class="special">=</span> <span class="special">{</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">,</span><span class="number">1</span><span class="special">};</span>
<span class="identifier">catmull_rom</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">,</span> <span class="number">3</span><span class="special">&gt;&gt;</span> <span class="identifier">cr</span><span class="special">(</span><span class="identifier">points</span><span class="special">.</span><span class="identifier">data</span><span class="special">(),</span> <span class="identifier">points</span><span class="special">.</span><span class="identifier">size</span><span class="special">());</span>
<span class="comment">// Interpolate at s = 0.1:</span>
<span class="keyword">auto</span> <span class="identifier">point</span> <span class="special">=</span> <span class="identifier">cr</span><span class="special">(</span><span class="number">0.1</span><span class="special">);</span>
</pre>
<p>
Memory conscious programmers may enjoy using the move constructor instead:
</p>
<pre class="programlisting"><span class="identifier">catmull_rom</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">,</span> <span class="number">3</span><span class="special">&gt;&gt;</span> <span class="identifier">cr</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">points</span><span class="special">));</span>
</pre>
<p>
The spline can be either open or <span class="bold"><strong>closed</strong></span>, closed
meaning that there is some <span class="emphasis"><em>t</em></span> such that <span class="emphasis"><em>P(t)
= P(0)</em></span>. The default is open, but this can be easily changed:
</p>
<pre class="programlisting"><span class="comment">// closed = true</span>
<span class="identifier">catmull_rom</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">,</span> <span class="number">3</span><span class="special">&gt;&gt;</span> <span class="identifier">cr</span><span class="special">(</span><span class="identifier">points</span><span class="special">.</span><span class="identifier">data</span><span class="special">(),</span> <span class="identifier">points</span><span class="special">.</span><span class="identifier">size</span><span class="special">(),</span> <span class="keyword">true</span><span class="special">);</span>
</pre>
<p>
Inside <code class="computeroutput"><span class="identifier">catmull_rom</span></code>, the Catmull-Rom
curve is represented as closed. This is because an open Catmull-Rom curve is
<span class="bold"><strong>implicitly closed</strong></span>, but the closing point is
the zero vector. There is no reason to suppose that the zero vector is a better
closing point than the endpoint (or any other point, for that matter), so traditionally
Catmull-Rom splines leave the segment between the first and second point undefined,
as well as the segment between the second-to-last and last point. We find this
property of the traditional implementation of Catmull-Rom splines annoying
and confusing to the user. Hence internally, we close the curve so that the
first and last segments are defined. Of course, this causes the <span class="bold"><strong>tangent</strong></span>
vectors to the first and last points to be bizarre. This is a "pick your
poison" design decision-either the curve cannot interpolate in its first
and last segments, or the tangents along the first and last segments are meaningless.
</p>
<p>
Since the routine internally represents the curve as closed, a question arises:
Why does the user have to specify if the curve is open or closed? The answer
is that the parameterization is chosen by the routine, so it is of interest
to the user to understand the values where a meaningful result is returned.
</p>
<pre class="programlisting"><span class="identifier">Real</span> <span class="identifier">max_s</span> <span class="special">=</span> <span class="identifier">cr</span><span class="special">.</span><span class="identifier">max_parameter</span><span class="special">();</span>
</pre>
<p>
If you attempt to interpolate for <code class="computeroutput"><span class="identifier">s</span>
<span class="special">&gt;</span> <span class="identifier">max_s</span></code>,
an exception is thrown. If the curve is closed, then <code class="computeroutput"><span class="identifier">cr</span><span class="special">(</span><span class="identifier">max_s</span><span class="special">)</span>
<span class="special">=</span> <span class="identifier">p0</span></code>,
where <code class="computeroutput"><span class="identifier">p0</span></code> is the first point
on the curve. If the curve is open, then <code class="computeroutput"><span class="identifier">cr</span><span class="special">(</span><span class="identifier">max_s</span><span class="special">)</span>
<span class="special">=</span> <span class="identifier">pf</span></code>,
where <code class="computeroutput"><span class="identifier">pf</span></code> is the final point
on the curve.
</p>
<p>
The Catmull-Rom curve admits an infinite number of parameterizations. The default
parameterization of the <code class="computeroutput"><span class="identifier">catmull_rom</span></code>
class is the so-called <span class="bold"><strong>centripedal</strong></span> parameterization.
This parameterization has been shown to be the only parameterization that does
not form cusps or self-intersections within segments. However, for advanced
users, other parameterizations can be chosen using the <span class="emphasis"><em>alpha</em></span>
parameter:
</p>
<pre class="programlisting"><span class="comment">// alpha = 1 is the "chordal" parameterization.</span>
<span class="identifier">catmull_rom</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="number">3</span><span class="special">&gt;&gt;</span> <span class="identifier">cr</span><span class="special">(</span><span class="identifier">points</span><span class="special">.</span><span class="identifier">data</span><span class="special">(),</span> <span class="identifier">points</span><span class="special">.</span><span class="identifier">size</span><span class="special">(),</span> <span class="keyword">false</span><span class="special">,</span> <span class="number">1.0</span><span class="special">);</span>
</pre>
<p>
Finally, the tangent vector to any point of the curve can be computed via
</p>
<pre class="programlisting"><span class="keyword">double</span> <span class="identifier">s</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">;</span>
<span class="identifier">Point</span> <span class="identifier">tangent</span> <span class="special">=</span> <span class="identifier">cr</span><span class="special">.</span><span class="identifier">prime</span><span class="special">(</span><span class="identifier">s</span><span class="special">);</span>
</pre>
<p>
Since the magnitude of the tangent vector is dependent on the parameterization,
it is not as meaningful as (say) arc-length parameterization. However, its
direction is meaningful, so the user may wish to normalize this result.
</p>
<h4>
<a name="math_toolkit.catmull_rom.h2"></a>
<span class="phrase"><a name="math_toolkit.catmull_rom.examples"></a></span><a class="link" href="catmull_rom.html#math_toolkit.catmull_rom.examples">Examples</a>
</h4>
<h4>
<a name="math_toolkit.catmull_rom.h3"></a>
<span class="phrase"><a name="math_toolkit.catmull_rom.performance"></a></span><a class="link" href="catmull_rom.html#math_toolkit.catmull_rom.performance">Performance</a>
</h4>
<p>
The following performance numbers were generated for a call to the Catmull-Rom
interpolation method. The number that follows the slash is the number of points
passed to the interpolant.
</p>
<pre class="programlisting"><span class="identifier">Run</span> <span class="identifier">on</span> <span class="number">2700</span> <span class="identifier">MHz</span> <span class="identifier">CPU</span>
<span class="identifier">CPU</span> <span class="identifier">Caches</span><span class="special">:</span>
<span class="identifier">L1</span> <span class="identifier">Data</span> <span class="number">32</span><span class="identifier">K</span> <span class="special">(</span><span class="identifier">x2</span><span class="special">)</span>
<span class="identifier">L1</span> <span class="identifier">Instruction</span> <span class="number">32</span><span class="identifier">K</span> <span class="special">(</span><span class="identifier">x2</span><span class="special">)</span>
<span class="identifier">L2</span> <span class="identifier">Unified</span> <span class="number">262</span><span class="identifier">K</span> <span class="special">(</span><span class="identifier">x2</span><span class="special">)</span>
<span class="identifier">L3</span> <span class="identifier">Unified</span> <span class="number">3145</span><span class="identifier">K</span> <span class="special">(</span><span class="identifier">x1</span><span class="special">)</span>
<span class="special">---------------------------------------------------------</span>
<span class="identifier">Benchmark</span> <span class="identifier">Time</span> <span class="identifier">CPU</span>
<span class="special">---------------------------------------------------------</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">4</span> <span class="number">20</span> <span class="identifier">ns</span> <span class="number">20</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">8</span> <span class="number">21</span> <span class="identifier">ns</span> <span class="number">21</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">16</span> <span class="number">23</span> <span class="identifier">ns</span> <span class="number">23</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">32</span> <span class="number">24</span> <span class="identifier">ns</span> <span class="number">24</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">64</span> <span class="number">27</span> <span class="identifier">ns</span> <span class="number">27</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">128</span> <span class="number">27</span> <span class="identifier">ns</span> <span class="number">27</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">256</span> <span class="number">30</span> <span class="identifier">ns</span> <span class="number">30</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">512</span> <span class="number">32</span> <span class="identifier">ns</span> <span class="number">31</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">1024</span> <span class="number">33</span> <span class="identifier">ns</span> <span class="number">33</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">2048</span> <span class="number">34</span> <span class="identifier">ns</span> <span class="number">34</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">4096</span> <span class="number">36</span> <span class="identifier">ns</span> <span class="number">36</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">8192</span> <span class="number">38</span> <span class="identifier">ns</span> <span class="number">38</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">16384</span> <span class="number">39</span> <span class="identifier">ns</span> <span class="number">39</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">32768</span> <span class="number">40</span> <span class="identifier">ns</span> <span class="number">40</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">65536</span> <span class="number">45</span> <span class="identifier">ns</span> <span class="number">44</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">131072</span> <span class="number">46</span> <span class="identifier">ns</span> <span class="number">46</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">262144</span> <span class="number">50</span> <span class="identifier">ns</span> <span class="number">50</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">524288</span> <span class="number">53</span> <span class="identifier">ns</span> <span class="number">52</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">1048576</span> <span class="number">58</span> <span class="identifier">ns</span> <span class="number">57</span> <span class="identifier">ns</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span><span class="identifier">_BigO</span> <span class="number">2.97</span> <span class="identifier">lgN</span> <span class="number">2.97</span> <span class="identifier">lgN</span>
<span class="identifier">BM_CatmullRom</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span><span class="identifier">_RMS</span> <span class="number">19</span> <span class="special">%</span> <span class="number">19</span> <span class="special">%</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle Walker
and Xiaogang Zhang<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="barycentric.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interpolation.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="point_type.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,59 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>References</title>
<link rel="stylesheet" href="../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Math Toolkit 2.8.0">
<link rel="up" href="../interpolation.html" title="Chapter&#160;10.&#160;Interpolation">
<link rel="prev" href="point_type.html" title="Point types">
<link rel="next" href="../quadrature.html" title="Chapter&#160;11.&#160;Quadrature and Differentiation">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="point_type.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interpolation.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../quadrature.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="math_toolkit.catmull_rom_refs"></a><a class="link" href="catmull_rom_refs.html" title="References">References</a>
</h2></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Cem Yuksel, Scott Schaefer, and John Keyser, <span class="emphasis"><em>Parameterization
and applications of Catmull&#8211;Rom curves</em></span>, Computer-Aided Design
43 (2011) 747&#8211;755.
</li>
<li class="listitem">
Phillip J. Barry and Ronald N. Goldman, <span class="emphasis"><em>A Recursive Evaluation
Algorithm for a Class of Catmull-Rom Splines</em></span>, Computer Graphics,
Volume 22, Number 4, August 1988
</li>
</ul></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle Walker
and Xiaogang Zhang<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="point_type.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interpolation.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../quadrature.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -55,11 +55,12 @@
science and mathematics.</a>
</li>
<li class="listitem">
No integer values (because so cheap to construct).<br> (You can easily
define your own if found convenient, for example: <code class="computeroutput"><span class="identifier">FPT</span>
<span class="identifier">one</span> <span class="special">=</span><span class="keyword">static_cast</span><span class="special">&lt;</span><span class="identifier">FPT</span><span class="special">&gt;(</span><span class="number">42</span><span class="special">);</span></code>).
No integer values (because so cheap to construct).
</li>
</ul></div>
<p>
(You can easily define your own if found convenient, for example: <code class="computeroutput"><span class="identifier">FPT</span> <span class="identifier">one</span> <span class="special">=</span><span class="keyword">static_cast</span><span class="special">&lt;</span><span class="identifier">FPT</span><span class="special">&gt;(</span><span class="number">42</span><span class="special">);</span></code>).
</p>
<h5>
<a name="math_toolkit.constants_faq.h1"></a>
<span class="phrase"><a name="math_toolkit.constants_faq.how_are_constants_named"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.how_are_constants_named">How

View File

@@ -83,6 +83,7 @@
at long double precision.
</li>
<li class="listitem">
<p class="simpara">
Faster - can avoid (re-)calculation at runtime.
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
@@ -92,9 +93,15 @@
</li>
<li class="listitem">
If the value is computed and cached (or constructed from a string
representation and cached), then it's returned by constant reference.<br>
This can be significant if:
representation and cached), then it's returned by constant reference.
</li>
</ul></div>
</p>
<p class="simpara">
This can be significant if:
</p>
<p class="simpara">
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
Functions pow, trig or log are used.
</li>
@@ -109,7 +116,8 @@
<code class="computeroutput"><span class="keyword">double</span></code>, are not available.
</li>
</ul></div>
</li>
</p>
</li>
</ul></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>

View File

@@ -27,7 +27,7 @@
<a name="math_toolkit.conventions"></a><a class="link" href="conventions.html" title="Document Conventions">Document Conventions</a>
</h2></div></div></div>
<p>
<a class="indexterm" name="id903892"></a>
<a class="indexterm" name="id887488"></a>
</p>
<p>
This documentation aims to use of the following naming and formatting conventions.

View File

@@ -202,7 +202,7 @@
</tr>
<tr><td align="left" valign="top"><p>
Older compilers can use this formula to calculate <code class="computeroutput"><span class="identifier">max_digits10</span></code>
from <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">FPT</span><span class="special">&gt;::</span><span class="identifier">digits10</span></code>:<br> &#8192;&#8192; <code class="computeroutput"><span class="keyword">int</span>
from <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">FPT</span><span class="special">&gt;::</span><span class="identifier">digits10</span></code>: &#8192;&#8192; <code class="computeroutput"><span class="keyword">int</span>
<span class="identifier">max_digits10</span> <span class="special">=</span>
<span class="number">2</span> <span class="special">+</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">FPT</span><span class="special">&gt;::</span><span class="identifier">digits10</span>
<span class="special">*</span> <span class="number">3010</span><span class="special">/</span><span class="number">10000</span><span class="special">;</span></code>

View File

@@ -28,9 +28,12 @@
</h2></div></div></div>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>I'm a FORTRAN/NAG/SPSS/SAS/Cephes/MathCad/R user and I don't
see where the functions like dnorm(mean, sd) are in Boost.Math?</em></span>
<br> Nearly all are provided, and many more like mean, skewness, quantiles,
</p>
<p class="simpara">
Nearly all are provided, and many more like mean, skewness, quantiles,
complements ... but Boost.Math makes full use of C++, and it looks a bit
different. But do not panic! See section on construction and the many examples.
Briefly, the distribution is constructed with the parameters (like location
@@ -38,43 +41,60 @@
in a common represention of pdf f(x; &#956;&#963;<sup>2</sup>). Functions like pdf, cdf are called
with the name of that distribution and the random variate often called
x or k. For example, <code class="computeroutput"><span class="identifier">normal</span> <span class="identifier">my_norm</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span> <span class="identifier">pdf</span><span class="special">(</span><span class="identifier">my_norm</span><span class="special">,</span> <span class="number">2.0</span><span class="special">);</span></code>
<br>
</li>
</p>
</li>
<li class="listitem">
<p class="simpara">
I'm a user of <a href="http://support.sas.com/rnd/app/da/new/probabilityfunctions.html" target="_top">New
SAS Functions for Computing Probabilities</a>. <br> You will find
the interface more familar, but to be able to select a distribution (perhaps
using a string) see the Extras/Future Directions section, and /boost/libs/math/dot_net_example/boost_math.cpp
for an example that is used to create a C# (C sharp) utility (that you
might also find useful): see <a href="http://sourceforge.net/projects/distexplorer/" target="_top">Statistical
Distribution Explorer</a>.<br>
</li>
SAS Functions for Computing Probabilities</a>.
</p>
<p class="simpara">
You will find the interface more familar, but to be able to select a distribution
(perhaps using a string) see the Extras/Future Directions section, and
/boost/libs/math/dot_net_example/boost_math.cpp for an example that is
used to create a C# (C sharp) utility (that you might also find useful):
see <a href="http://sourceforge.net/projects/distexplorer/" target="_top">Statistical
Distribution Explorer</a>.
</p>
</li>
<li class="listitem">
<span class="emphasis"><em>I'm allegic to reading manuals and prefer to learn from examples.</em></span><br>
<p class="simpara">
<span class="emphasis"><em>I'm allegic to reading manuals and prefer to learn from examples.</em></span>
</p>
<p class="simpara">
Fear not - you are not alone! Many examples are available for functions
and distributions. Some are referenced directly from the text. Others can
be found at \boost_latest_release\libs\math\example. If you are a Visual
Studio user, you should be able to create projects from each of these,
making sure that the Boost library is in the include directories list.
</li>
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>How do I make sure that the Boost library is in the Visual Studio
include directories list?</em></span><br> You can add an include path,
for example, your Boost place /boost-latest_release, for example <code class="computeroutput"><span class="identifier">X</span><span class="special">:/</span><span class="identifier">boost_1_45_0</span><span class="special">/</span></code> if you have a separate partition X for
Boost releases. Or you can use an environment variable BOOST_ROOT set to
your Boost place, and include that. Visual Studio before 2010 provided
Tools, Options, VC++ Directories to control directories: Visual Studio
2010 instead provides property sheets to assist. You may find it convenient
to create a new one adding \boost-latest_release; to the existing include
items in $(IncludePath).
</li>
include directories list?</em></span>
</p>
<p class="simpara">
You can add an include path, for example, your Boost place /boost-latest_release,
for example <code class="computeroutput"><span class="identifier">X</span><span class="special">:/</span><span class="identifier">boost_1_45_0</span><span class="special">/</span></code>
if you have a separate partition X for Boost releases. Or you can use an
environment variable BOOST_ROOT set to your Boost place, and include that.
Visual Studio before 2010 provided Tools, Options, VC++ Directories to
control directories: Visual Studio 2010 instead provides property sheets
to assist. You may find it convenient to create a new one adding \boost-latest_release;
to the existing include items in $(IncludePath).
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>I'm a FORTRAN/NAG/SPSS/SAS/Cephes/MathCad/R user and I don't
see where the properties like mean, median, mode, variance, skewness of
distributions are in Boost.Math?</em></span><br> They are all available
(if defined for the parameters with which you constructed the distribution)
via <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution
Function</a>, <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability
distributions are in Boost.Math?</em></span>
</p>
<p class="simpara">
They are all available (if defined for the parameters with which you constructed
the distribution) via <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative
Distribution Function</a>, <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability
Density Function</a>, <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>,
<a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function</a>,
<a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function</a>,
@@ -83,128 +103,195 @@
<a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
<a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness</a>, <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis</a>, <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>,
<a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.range">range</a> and <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.support">support</a>.
</li>
</p>
</li>
<li class="listitem">
<span class="emphasis"><em>I am a C programmer. Can I user Boost.Math with C?</em></span><br>
<p class="simpara">
<span class="emphasis"><em>I am a C programmer. Can I user Boost.Math with C?</em></span>
</p>
<p class="simpara">
Yes you can, including all the special functions, and TR1 functions like
isnan. They appear as C functions, by being declared as "extern C".
</li>
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>I am a C# (Basic? F# FORTRAN? Other CLI?) programmer. Can I use
Boost.Math with C#? (or ...)?</em></span> <br> Yes you can, including
all the special functions, and TR1 functions like isnan. But you <span class="bold"><strong>must build the Boost.Math as a dynamic library (.dll) and compile
with the /CLI option</strong></span>. See the boost/math/dot_net_example folder
which contains an example that builds a simple statistical distribution
Boost.Math with C#? (or ...)?</em></span>
</p>
<p class="simpara">
Yes you can, including all the special functions, and TR1 functions like
isnan. But you <span class="bold"><strong>must build the Boost.Math as a dynamic
library (.dll) and compile with the /CLI option</strong></span>. See the boost/math/dot_net_example
folder which contains an example that builds a simple statistical distribution
app with a GUI. See <a href="http://sourceforge.net/projects/distexplorer/" target="_top">Statistical
Distribution Explorer</a> <br>
</li>
Distribution Explorer</a>
</p>
</li>
<li class="listitem">
<span class="emphasis"><em>What these "policies" things for?</em></span> <br>
<p class="simpara">
<span class="emphasis"><em>What these "policies" things for?</em></span>
</p>
<p class="simpara">
Policies are a powerful (if necessarily complex) fine-grain mechanism that
allow you to customise the behaviour of the Boost.Math library according
to your precise needs. See <a class="link" href="../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policies</a>. But
if, very probably, the default behaviour suits you, you don't need to know
more.
</li>
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>I am a C user and expect to see global C-style<code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code> set for overflow/errors etc?</em></span>
<br> You can achieve what you want - see <a class="link" href="pol_ref/error_handling_policies.html" title="Error Handling Policies">error
</p>
<p class="simpara">
You can achieve what you want - see <a class="link" href="pol_ref/error_handling_policies.html" title="Error Handling Policies">error
handling policies</a> and <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">user
error handling</a> and many examples.
</li>
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>I am a C user and expect to silently return a max value for overflow?</em></span>
<br> You (and C++ users too) can return whatever you want on overflow
- see <a class="link" href="error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>
</p>
<p class="simpara">
You (and C++ users too) can return whatever you want on overflow - see
<a class="link" href="error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>
and <a class="link" href="pol_ref/error_handling_policies.html" title="Error Handling Policies">error
handling policies</a> and several examples.
</li>
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>I don't want any error message for overflow etc?</em></span>
<br> You can control exactly what happens for all the abnormal conditions,
including the values returned. See <a class="link" href="error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>,
</p>
<p class="simpara">
You can control exactly what happens for all the abnormal conditions, including
the values returned. See <a class="link" href="error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>,
<a class="link" href="error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>
<a class="link" href="pol_ref/error_handling_policies.html" title="Error Handling Policies">error handling
policies</a> <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">user
error handling</a> etc and examples.
</li>
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>My environment doesn't allow and/or I don't want exceptions.
Can I still user Boost.Math?</em></span> <br> Yes but you must customise
the error handling: see <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">user
Can I still user Boost.Math?</em></span>
</p>
<p class="simpara">
Yes but you must customise the error handling: see <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">user
error handling</a> and <a class="link" href="pol_ref/policy_defaults.html" title="Using Macros to Change the Policy Defaults">changing
policies defaults</a> .
</li>
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>The docs are several hundreds of pages long! Can I read the docs
off-line or on paper?</em></span> <br> Yes - you can download the Boost
current release of most documentation as a zip of pdfs (including Boost.Math)
from Sourceforge, for example <a href="https://sourceforge.net/projects/boost/files/boost-docs/1.45.0/boost_pdf_1_45_0.tar.gz/download" target="_top">https://sourceforge.net/projects/boost/files/boost-docs/1.45.0/boost_pdf_1_45_0.tar.gz/download</a>.
off-line or on paper?</em></span>
</p>
<p class="simpara">
Yes - you can download the Boost current release of most documentation
as a zip of pdfs (including Boost.Math) from Sourceforge, for example
<a href="https://sourceforge.net/projects/boost/files/boost-docs/1.45.0/boost_pdf_1_45_0.tar.gz/download" target="_top">https://sourceforge.net/projects/boost/files/boost-docs/1.45.0/boost_pdf_1_45_0.tar.gz/download</a>.
And you can print any pages you need (or even print all pages - but be
warned that there are several hundred!). Both html and pdf versions are
highly hyperlinked. The entire Boost.Math pdf can be searched with Adobe
Reader, Edit, Find ... This can often find what you seek, a partial substitute
for a full index.
</li>
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>I want a compact version for an embedded application. Can I use
float precision?</em></span> <br> Yes - by selecting RealType template
parameter as float: for example normal_distribution&lt;float&gt; your_normal(mean,
sd); (But double may still be used internally, so space saving may be less
that you hope for). You can also change the promotion policy, but accuracy
might be much reduced.
</li>
float precision?</em></span>
</p>
<p class="simpara">
Yes - by selecting RealType template parameter as float: for example normal_distribution&lt;float&gt;
your_normal(mean, sd); (But double may still be used internally, so space
saving may be less that you hope for). You can also change the promotion
policy, but accuracy might be much reduced.
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>I seem to get somewhat different results compared to other programs.
Why?</em></span> We hope Boost.Math to be more accurate: our priority is
accuracy (over speed). See the section on accuracy. But for evaluations
that require iterations there are parameters which can change the required
accuracy (see <a class="link" href="../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policies</a>). You might be able
to squeeze a little more (or less) accuracy at the cost of runtime.
</li>
Why?</em></span>
</p>
<p class="simpara">
We hope Boost.Math to be more accurate: our priority is accuracy (over
speed). See the section on accuracy. But for evaluations that require iterations
there are parameters which can change the required accuracy (see <a class="link" href="../policy.html" title="Chapter&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policies</a>). You might be able to squeeze a little
more (or less) accuracy at the cost of runtime.
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>Will my program run more slowly compared to other math functions
and statistical libraries?</em></span> Probably, thought not always, and
not by too much: our priority is accuracy. For most functions, making sure
you have the latest compiler version with all optimisations switched on
is the key to speed. For evaluations that require iteration, you may be
able to gain a little more speed at the expense of accuracy. See detailed
suggestions and results on <a class="link" href="../perf.html" title="Chapter&#160;19.&#160;Performance">performance</a>.
</li>
and statistical libraries?</em></span>
</p>
<p class="simpara">
Probably, thought not always, and not by too much: our priority is accuracy.
For most functions, making sure you have the latest compiler version with
all optimisations switched on is the key to speed. For evaluations that
require iteration, you may be able to gain a little more speed at the expense
of accuracy. See detailed suggestions and results on <a class="link" href="../perf.html" title="Chapter&#160;19.&#160;Performance">performance</a>.
</p>
</li>
<li class="listitem">
<span class="emphasis"><em>How do I handle infinity and NaNs portably?</em></span> <br>
<p class="simpara">
<span class="emphasis"><em>How do I handle infinity and NaNs portably?</em></span>
</p>
<p class="simpara">
See <a class="link" href="fp_facets.html" title="Facets for Floating-Point Infinities and NaNs">nonfinite fp_facets</a> for
Facets for Floating-Point Infinities and NaNs.
</li>
</p>
</li>
<li class="listitem">
<span class="emphasis"><em>Where are the pre-built libraries?</em></span> <br> Good news
- you probably don't need any! - just <code class="computeroutput"><span class="preprocessor">#include</span>
<p class="simpara">
<span class="emphasis"><em>Where are the pre-built libraries?</em></span>
</p>
<p class="simpara">
Good news - you probably don't need any! - just <code class="computeroutput"><span class="preprocessor">#include</span>
<span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span></code><span class="emphasis"><em>math/distribution_you_want&gt;</em></span>.
But in the unlikely event that you do, see <a class="link" href="building.html" title="If and How to Build a Boost.Math Library, and its Examples and Tests">building
libraries</a>.
</li>
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>I don't see the function or distribution that I want.</em></span>
<br> You could try an email to ask the authors - but no promises!
</li>
</p>
<p class="simpara">
You could try an email to ask the authors - but no promises!
</p>
</li>
<li class="listitem">
<p class="simpara">
<span class="emphasis"><em>I need more decimal digits for values/computations.</em></span>
<br> You can use Boost.Math with <a href="../../../../../libs/multiprecision/doc/html/index.html" target="_top">Boost.Multiprecision</a>:
</p>
<p class="simpara">
You can use Boost.Math with <a href="../../../../../libs/multiprecision/doc/html/index.html" target="_top">Boost.Multiprecision</a>:
typically <a href="../../../../../libs/multiprecision/doc/html/boost_multiprecision/tut/floats/cpp_dec_float.html" target="_top">cpp_dec_float</a>
is a useful user-defined type to provide a fixed number of decimal digits,
usually 50 or 100.
</li>
</p>
</li>
<li class="listitem">
<p class="simpara">
Why can't I write something really simple like <code class="computeroutput"><span class="identifier">cpp_int</span>
<span class="identifier">one</span><span class="special">(</span><span class="number">1</span><span class="special">);</span> <span class="identifier">cpp_dec_float_50</span>
<span class="identifier">two</span><span class="special">(</span><span class="number">2</span><span class="special">);</span> <span class="identifier">one</span>
<span class="special">*</span> <span class="identifier">two</span><span class="special">;</span></code> Because <code class="computeroutput"><span class="identifier">cpp_int</span></code>
might be bigger than <code class="computeroutput"><span class="identifier">cpp_dec_float</span>
<span class="identifier">can</span> <span class="identifier">hold</span></code>,
<span class="special">*</span> <span class="identifier">two</span><span class="special">;</span></code>
</p>
<p class="simpara">
Because <code class="computeroutput"><span class="identifier">cpp_int</span></code> might be
bigger than <code class="computeroutput"><span class="identifier">cpp_dec_float</span> <span class="identifier">can</span> <span class="identifier">hold</span></code>,
so you must make an <span class="bold"><strong>explicit</strong></span> conversion.
See <a href="http://svn.boost.org/svn/boost/trunk/libs/multiprecision/doc/html/boost_multiprecision/intro.html" target="_top">mixed
multiprecision arithmetic</a> and <a href="http://svn.boost.org/svn/boost/trunk/libs/multiprecision/doc/html/boost_multiprecision/tut/conversions.html" target="_top">conversion</a>.
</li>
</p>
</li>
</ol></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>

View File

@@ -27,7 +27,7 @@
<a name="math_toolkit.navigation"></a><a class="link" href="navigation.html" title="Navigation">Navigation</a>
</h2></div></div></div>
<p>
<a class="indexterm" name="id903751"></a>
<a class="indexterm" name="id887375"></a>
</p>
<p>
Boost.Math documentation is provided in both HTML and PDF formats.

View File

@@ -0,0 +1,95 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Point types</title>
<link rel="stylesheet" href="../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Math Toolkit 2.8.0">
<link rel="up" href="../interpolation.html" title="Chapter&#160;10.&#160;Interpolation">
<link rel="prev" href="catmull_rom.html" title="Catmull-Rom Splines">
<link rel="next" href="catmull_rom_refs.html" title="References">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="catmull_rom.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interpolation.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="catmull_rom_refs.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="math_toolkit.point_type"></a><a class="link" href="point_type.html" title="Point types">Point types</a>
</h2></div></div></div>
<p>
We have already discussed that certain conditions on the <code class="computeroutput"><span class="identifier">Point</span></code>
type template argument must be obeyed. The following shows a custom point type
in 3D which can be used as a template argument to Catmull-Rom:
</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Real</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">mypoint3d</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
<span class="comment">// Must define a value_type:</span>
<span class="keyword">typedef</span> <span class="identifier">Real</span> <span class="identifier">value_type</span><span class="special">;</span>
<span class="comment">// Regular constructor--need not be of this form.</span>
<span class="identifier">mypoint3d</span><span class="special">(</span><span class="identifier">Real</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">y</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">z</span><span class="special">)</span> <span class="special">{</span><span class="identifier">m_vec</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">x</span><span class="special">;</span> <span class="identifier">m_vec</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">y</span><span class="special">;</span> <span class="identifier">m_vec</span><span class="special">[</span><span class="number">2</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">z</span><span class="special">;</span> <span class="special">}</span>
<span class="comment">// Must define a default constructor:</span>
<span class="identifier">mypoint3d</span><span class="special">()</span> <span class="special">{}</span>
<span class="comment">// Must define array access:</span>
<span class="identifier">Real</span> <span class="keyword">operator</span><span class="special">[](</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">m_vec</span><span class="special">[</span><span class="identifier">i</span><span class="special">];</span>
<span class="special">}</span>
<span class="comment">// Must define array element assignment:</span>
<span class="identifier">Real</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">[](</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">m_vec</span><span class="special">[</span><span class="identifier">i</span><span class="special">];</span>
<span class="special">}</span>
<span class="keyword">private</span><span class="special">:</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">,</span> <span class="number">3</span><span class="special">&gt;</span> <span class="identifier">m_vec</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// Must define the free function "size()":</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Real</span><span class="special">&gt;</span>
<span class="keyword">constexpr</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">mypoint3d</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">&gt;&amp;</span> <span class="identifier">c</span><span class="special">)</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="number">3</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
These conditions are satisfied by both <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span></code> and
<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span></code>, but it may nonetheless be useful
to define your own point class so that (say) you can define geometric distance
between them.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle Walker
and Xiaogang Zhang<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="catmull_rom.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interpolation.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="catmull_rom_refs.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -50,9 +50,15 @@
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">I</span><span class="special">&gt;</span>
<span class="identifier">polynomial</span><span class="special">(</span><span class="identifier">I</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">I</span> <span class="identifier">last</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span>
<span class="keyword">explicit</span> <span class="identifier">polynomial</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">U</span><span class="special">&amp;</span> <span class="identifier">point</span><span class="special">);</span>
<span class="keyword">explicit</span> <span class="identifier">polynomial</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">U</span><span class="special">&amp;</span> <span class="identifier">point</span><span class="special">,</span>
<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">enable_if</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_convertible</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">,</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">type</span><span class="special">*</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Range</span><span class="special">&gt;</span>
<span class="keyword">explicit</span> <span class="identifier">polynomial</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Range</span><span class="special">&amp;</span> <span class="identifier">r</span><span class="special">,</span>
<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">enable_if</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">is_const_iterable</span><span class="special">&lt;</span><span class="identifier">Range</span><span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">type</span><span class="special">*</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span> <span class="comment">// C++14</span>
<span class="identifier">polynomial</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">initializer_list</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">l</span><span class="special">);</span> <span class="comment">// C++11</span>
<span class="identifier">polynomial</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&amp;&amp;</span> <span class="identifier">p</span><span class="special">);</span>
<span class="comment">// access:</span>
<span class="identifier">size_type</span> <span class="identifier">size</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
<span class="identifier">size_type</span> <span class="identifier">degree</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
@@ -62,6 +68,14 @@
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&amp;</span> <span class="identifier">data</span><span class="special">();</span>
<span class="keyword">explicit</span> <span class="keyword">operator</span> <span class="keyword">bool</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
<span class="identifier">polynomial</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">prime</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
<span class="identifier">polynomial</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">integrate</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
<span class="identifier">T</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="comment">// modify:</span>
<span class="keyword">void</span> <span class="identifier">set_zero</span><span class="special">();</span>

View File

@@ -108,7 +108,9 @@
and Wolfram MathWorld) by placing a semi-colon or vertical bar) <span class="emphasis"><em>after</em></span>
the <a href="http://en.wikipedia.org/wiki/Random_variable" target="_top">random
variable</a> (whose value you 'choose'), to separate the variate
from the parameter(s) that defines the shape of the distribution.<br>
from the parameter(s) that defines the shape of the distribution.
</p>
<p>
For example, the binomial distribution probability distribution function
(PDF) is written as <span class="emphasis"><em>f(k| n, p)</em></span> = Pr(K = k|n, p)
= probability of observing k successes out of n trials. K is the <a href="http://en.wikipedia.org/wiki/Random_variable" target="_top">random variable</a>,

View File

@@ -6,7 +6,7 @@
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="Math Toolkit 2.8.0">
<link rel="up" href="index.html" title="Math Toolkit 2.8.0">
<link rel="prev" href="math_toolkit/barycentric.html" title="Barycentric Rational Interpolation">
<link rel="prev" href="math_toolkit/catmull_rom_refs.html" title="References">
<link rel="next" href="math_toolkit/trapezoidal.html" title="Trapezoidal Quadrature">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="math_toolkit/barycentric.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="math_toolkit/trapezoidal.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="math_toolkit/catmull_rom_refs.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="math_toolkit/trapezoidal.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="chapter">
<div class="titlepage"><div><div><h1 class="title">
@@ -66,7 +66,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="math_toolkit/barycentric.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="math_toolkit/trapezoidal.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="math_toolkit/catmull_rom_refs.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="math_toolkit/trapezoidal.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -282,6 +282,9 @@ math_toolkit/rational.html
interpolation.html
math_toolkit/cubic_b.html
math_toolkit/barycentric.html
math_toolkit/catmull_rom.html
math_toolkit/point_type.html
math_toolkit/catmull_rom_refs.html
quadrature.html
math_toolkit/trapezoidal.html
math_toolkit/gauss.html

View File

@@ -0,0 +1,226 @@
[/
Copyright 2017 Nick Thompson
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
]
[section:catmull_rom Catmull-Rom Splines]
[heading Synopsis]
``
#include <boost/math/interpolators/catmull_rom.hpp>
namespace boost{ namespace math{
template<class Point>
class catmull_rom
{
public:
catmull_rom(std::vector<Point>&& points, bool closed = false, Real alpha = (Real) 1/ (Real) 2)
catmull_rom(std::initializer_list<Point> l, bool closed = false, typename Point::value_type alpha = (typename Point::value_type) 1/ (typename Point::value_type) 2);
Real operator()(Real s) const;
Real max_parameter() const;
Real parameter_at_point(size_t i) const;
Point prime(Real s) const;
};
}}
``
[heading Description]
Catmull-Rom splines are a family of interpolating curves which are commonly used in computer graphics and animation.
Catmull-Rom splines enjoy the following properties:
* Affine invariance: The interpolant commutes with affine transformations.
* Local support of the basis functions: This gives stability and fast evaluation.
* /C/[super 2]-smoothness
* Interpolation of control points-this means the curve passes through the control points.
Many curves (such as Bezier) are /approximating/-they do not pass through their control points.
This makes them more difficult to use than interpolating splines.
The `catmull_rom` class provided by Boost creates a cubic Catmull-Rom spline from an array of points in any dimension.
Since there are numerous ways to represent a point in /n/-dimensional space,
the class attempts to be flexible by templating on the point type.
The requirements on the point type are discussing in more detail below, but roughly, it must have a dereference operator defined (e.g., `p[0]` is not a syntax error),
it must be able to be dereferenced up to `dimension -1`, and `p[i]` is of type `Real`, define `value_type`, and the free function `size()`.
These requirements are met by `std::vector` and `std::array`.
The basic usage is shown here:
std::vector<std::array<Real, 3>> points(4);
points[0] = {0,0,0};
points[1] = {1,0,0};
points[2] = {0,1,0};
points[3] = {0,0,1};
catmull_rom<std::array<Real, 3>> cr(std::move(points));
// Interpolate at s = 0.1:
auto point = cr(0.1);
The spline can be either open or /closed/, closed meaning that there is some /s > 0/ such that /P(s) = P(0)/.
The default is open, but this can be easily changed:
// closed = true
catmull_rom<std::array<Real, 3>> cr(std::move(points), true);
In either case, evaluating the interpolator at /s=0/ returns the first point in the list.
If the curve is open, then the first and last segments may have strange behavior.
The traditional solution is to prepend a carefully selected control point to the data so that the first data segment (second interpolator segment) has reasonable tangent vectors, and simply ignore the first interpolator segment.
A control point is appended to the data using similar criteria.
However, we recommend not going through this effort until it proves to be necessary: For most use-cases, the curve is good enough without prepending and appending control points, and responsible selection of non-data control points is difficult.
Inside `catmull_rom`, the curve is represented as closed.
This is because an open Catmull-Rom curve is /implicitly closed/, but the closing point is the zero vector.
There is no reason to suppose that the zero vector is a better closing point than the endpoint (or any other point, for that matter),
so traditionally Catmull-Rom splines leave the segment between the first and second point undefined,
as well as the segment between the second-to-last and last point.
We find this property of the traditional implementation of Catmull-Rom splines annoying and confusing to the user.
Hence internally, we close the curve so that the first and last segments are defined.
Of course, this causes the /tangent/ vectors to the first and last points to be bizarre.
This is a "pick your poison" design decision-either the curve cannot interpolate in its first and last segments,
or the tangents along the first and last segments are meaningless.
In the vast majority of cases, this will be no problem to the user.
However, if it becomes a problem, then the user should add one extra point in a position they believe is reasonable and close the curve.
Since the routine internally represents the curve as closed,
a question arises: Why does the user have to specify if the curve is open or closed?
The answer is that the parameterization is chosen by the routine,
so it is of interest to the user to understand the values where a meaningful result is returned.
Real max_s = cr.max_parameter();
If you attempt to interpolate for `s > max_s`, an exception is thrown.
If the curve is closed, then `cr(max_s) = p0`, where `p0` is the first point on the curve.
If the curve is open, then `cr(max_s) = pf`, where `pf` is the final point on the curve.
The Catmull-Rom curve admits an infinite number of parameterizations.
The default parameterization of the `catmull_rom` class is the so-called /centripedal/ parameterization.
This parameterization has been shown to be the only parameterization that does not form cusps or self-intersections within segments.
However, for advanced users, other parameterizations can be chosen using the /alpha/ parameter:
// alpha = 1 is the "chordal" parameterization.
catmull_rom<std::array<double, 3>> cr(std::move(points), false, 1.0);
The alpha parameter must always be in the range `[0,1]`.
Finally, the tangent vector to any point of the curve can be computed via
double s = 0.1;
Point tangent = cr.prime(s);
Since the magnitude of the tangent vector is dependent on the parameterization,
it is not meaningful (unless the user chooses the chordal parameterization /alpha = 1/ which parameterizes by Euclidean distance between points.)
However, its direction is meaningful no matter the parameterization, so the user may wish to normalize this result.
[heading Examples]
[import ../../example/catmull_rom_example.cpp]
[heading Performance]
The following performance numbers were generated for a call to the Catmull-Rom interpolation method.
The number that follows the slash is the number of points passed to the interpolant.
We see that evaluation of the interpolant is [bigo](/log/(/N/)).
Run on 2700 MHz CPU
CPU Caches:
L1 Data 32K (x2)
L1 Instruction 32K (x2)
L2 Unified 262K (x2)
L3 Unified 3145K (x1)
---------------------------------------------------------
Benchmark Time CPU
---------------------------------------------------------
BM_CatmullRom<double>/4 20 ns 20 ns
BM_CatmullRom<double>/8 21 ns 21 ns
BM_CatmullRom<double>/16 23 ns 23 ns
BM_CatmullRom<double>/32 24 ns 24 ns
BM_CatmullRom<double>/64 27 ns 27 ns
BM_CatmullRom<double>/128 27 ns 27 ns
BM_CatmullRom<double>/256 30 ns 30 ns
BM_CatmullRom<double>/512 32 ns 31 ns
BM_CatmullRom<double>/1024 33 ns 33 ns
BM_CatmullRom<double>/2048 34 ns 34 ns
BM_CatmullRom<double>/4096 36 ns 36 ns
BM_CatmullRom<double>/8192 38 ns 38 ns
BM_CatmullRom<double>/16384 39 ns 39 ns
BM_CatmullRom<double>/32768 40 ns 40 ns
BM_CatmullRom<double>/65536 45 ns 44 ns
BM_CatmullRom<double>/131072 46 ns 46 ns
BM_CatmullRom<double>/262144 50 ns 50 ns
BM_CatmullRom<double>/524288 53 ns 52 ns
BM_CatmullRom<double>/1048576 58 ns 57 ns
BM_CatmullRom<double>_BigO 2.97 lgN 2.97 lgN
BM_CatmullRom<double>_RMS 19 % 19 %
[heading Point types]
We have already discussed that certain conditions on the `Point` type template argument must be obeyed.
The following shows a custom point type in 3D which can be used as a template argument to Catmull-Rom:
template<class Real>
class mypoint3d
{
public:
// Must define a value_type:
typedef Real value_type;
// Regular constructor--need not be of this form.
mypoint3d(Real x, Real y, Real z) {m_vec[0] = x; m_vec[1] = y; m_vec[2] = z; }
// Must define a default constructor:
mypoint3d() {}
// Must define array access:
Real operator[](size_t i) const
{
return m_vec[i];
}
// Must define array element assignment:
Real& operator[](size_t i)
{
return m_vec[i];
}
private:
std::array<Real, 3> m_vec;
};
// Must define the free function "size()":
template<class Real>
constexpr size_t size(const mypoint3d<Real>& c)
{
return 3;
}
These conditions are satisfied by both `std::array` and `std::vector`, but it may nonetheless be useful to define your own point class so that (say) you can define geometric distance between them.
[heading Caveats]
The Catmull-Rom interpolator requires memory for three more points than is provided by the user.
This causes the class to call a `resize()` on the input vector.
If `v.capacity() >= v.size() + 3`, then no problems arise; there are no reallocs, and in practice this condition is almost always satisfied.
However, if `v.capacity() < v.size() + 3`, the realloc causes a performance penalty of roughly 20%.
[heading References]
* Cem Yuksel, Scott Schaefer, and John Keyser, ['Parameterization and applications of CatmullRom curves], Computer-Aided Design 43 (2011) 747755.
* Phillip J. Barry and Ronald N. Goldman, ['A Recursive Evaluation Algorithm for a Class of Catmull-Rom Splines], Computer Graphics, Volume 22, Number 4, August 1988
[endsect]
[/section:catmull_rom Catmull-Rom Splines]

View File

@@ -651,6 +651,7 @@ and as a CD ISBN 0-9504833-2-X 978-0-9504833-2-0, Classification 519.2-dc22.
[mathpart interpolation Interpolation]
[include interpolators/cubic_b_spline.qbk]
[include interpolators/barycentric_rational_interpolation.qbk]
[include interpolators/catmull_rom.qbk]
[endmathpart]
[mathpart quadrature Quadrature and Differentiation]

View File

@@ -1,94 +1,135 @@
[section:main_faq Frequently Asked Questions FAQ]
# ['I'm a FORTRAN/NAG/SPSS/SAS/Cephes/MathCad/R user
and I don't see where the functions like dnorm(mean, sd) are in Boost.Math?] [br]
Nearly all are provided, and many more like mean, skewness, quantiles, complements ...
and I don't see where the functions like dnorm(mean, sd) are in Boost.Math?]
Nearly all are provided, and many more like mean, skewness, quantiles, complements ...
but Boost.Math makes full use of C++, and it looks a bit different.
But do not panic! See section on construction and the many examples.
Briefly, the distribution is constructed with the parameters (like location and scale)
(things after the | in representation like P(X=k|n, p) or ; in a common represention of pdf f(x; [mu][sigma][super 2]).
Functions like pdf, cdf are called with the name of that distribution and the random variate often called x or k.
For example, `normal my_norm(0, 1); pdf(my_norm, 2.0);` [br]
#I'm a user of [@http://support.sas.com/rnd/app/da/new/probabilityfunctions.html New SAS Functions for Computing Probabilities]. [br]
You will find the interface more familar, but to be able to select a distribution (perhaps using a string)
For example, `normal my_norm(0, 1); pdf(my_norm, 2.0);`
# I'm a user of [@http://support.sas.com/rnd/app/da/new/probabilityfunctions.html New SAS Functions for Computing Probabilities].
You will find the interface more familar, but to be able to select a distribution (perhaps using a string)
see the Extras/Future Directions section,
and /boost/libs/math/dot_net_example/boost_math.cpp for an example that is used to create a C# (C sharp) utility
(that you might also find useful):
see [@http://sourceforge.net/projects/distexplorer/ Statistical Distribution Explorer].[br]
# ['I'm allegic to reading manuals and prefer to learn from examples.][br]
Fear not - you are not alone! Many examples are available for functions and distributions.
see [@http://sourceforge.net/projects/distexplorer/ Statistical Distribution Explorer].
# ['I'm allegic to reading manuals and prefer to learn from examples.]
Fear not - you are not alone! Many examples are available for functions and distributions.
Some are referenced directly from the text. Others can be found at \boost_latest_release\libs\math\example.
If you are a Visual Studio user, you should be able to create projects from each of these,
making sure that the Boost library is in the include directories list.
# ['How do I make sure that the Boost library is in the Visual Studio include directories list?][br]
You can add an include path, for example, your Boost place /boost-latest_release,
# ['How do I make sure that the Boost library is in the Visual Studio include directories list?]
You can add an include path, for example, your Boost place /boost-latest_release,
for example `X:/boost_1_45_0/` if you have a separate partition X for Boost releases.
Or you can use an environment variable BOOST_ROOT set to your Boost place, and include that.
Visual Studio before 2010 provided Tools, Options, VC++ Directories to control directories:
Visual Studio 2010 instead provides property sheets to assist.
You may find it convenient to create a new one adding \boost-latest_release;
to the existing include items in $(IncludePath).
# ['I'm a FORTRAN/NAG/SPSS/SAS/Cephes/MathCad/R user and
I don't see where the properties like mean, median, mode, variance, skewness of distributions are in Boost.Math?][br]
They are all available (if defined for the parameters with which you constructed the distribution) via __usual_accessors.
# ['I am a C programmer. Can I user Boost.Math with C?][br]
Yes you can, including all the special functions, and TR1 functions like isnan.
I don't see where the properties like mean, median, mode, variance, skewness of distributions are in Boost.Math?]
They are all available (if defined for the parameters with which you constructed the distribution) via __usual_accessors.
# ['I am a C programmer. Can I user Boost.Math with C?]
Yes you can, including all the special functions, and TR1 functions like isnan.
They appear as C functions, by being declared as "extern C".
# ['I am a C# (Basic? F# FORTRAN? Other CLI?) programmer. Can I use Boost.Math with C#? (or ...)?] [br]
Yes you can, including all the special functions, and TR1 functions like isnan.
# ['I am a C# (Basic? F# FORTRAN? Other CLI?) programmer. Can I use Boost.Math with C#? (or ...)?]
Yes you can, including all the special functions, and TR1 functions like isnan.
But you [*must build the Boost.Math as a dynamic library (.dll) and compile with the /CLI option].
See the boost/math/dot_net_example folder which contains an example that
builds a simple statistical distribution app with a GUI.
See [@http://sourceforge.net/projects/distexplorer/ Statistical Distribution Explorer] [br]
# ['What these "policies" things for?] [br]
Policies are a powerful (if necessarily complex) fine-grain mechanism that
See [@http://sourceforge.net/projects/distexplorer/ Statistical Distribution Explorer]
# ['What these "policies" things for?]
Policies are a powerful (if necessarily complex) fine-grain mechanism that
allow you to customise the behaviour of the Boost.Math library according to your precise needs.
See __policy_section. But if, very probably, the default behaviour suits you, you don't need to know more.
# ['I am a C user and expect to see global C-style`::errno` set for overflow/errors etc?] [br]
You can achieve what you want - see __error_policy and __user_error_handling and many examples.
# ['I am a C user and expect to silently return a max value for overflow?] [br]
You (and C++ users too) can return whatever you want on overflow
# ['I am a C user and expect to see global C-style`::errno` set for overflow/errors etc?]
You can achieve what you want - see __error_policy and __user_error_handling and many examples.
# ['I am a C user and expect to silently return a max value for overflow?]
You (and C++ users too) can return whatever you want on overflow
- see __overflow_error and __error_policy and several examples.
# ['I don't want any error message for overflow etc?] [br]
You can control exactly what happens for all the abnormal conditions, including the values returned.
# ['I don't want any error message for overflow etc?]
You can control exactly what happens for all the abnormal conditions, including the values returned.
See __domain_error, __overflow_error __error_policy __user_error_handling etc and examples.
# ['My environment doesn't allow and/or I don't want exceptions. Can I still user Boost.Math?] [br]
Yes but you must customise the error handling: see __user_error_handling and __changing_policy_defaults .
# ['The docs are several hundreds of pages long! Can I read the docs off-line or on paper?] [br]
Yes - you can download the Boost current release of most documentation
# ['My environment doesn't allow and/or I don't want exceptions. Can I still user Boost.Math?]
Yes but you must customise the error handling: see __user_error_handling and __changing_policy_defaults .
# ['The docs are several hundreds of pages long! Can I read the docs off-line or on paper?]
Yes - you can download the Boost current release of most documentation
as a zip of pdfs (including Boost.Math) from Sourceforge, for example
[@https://sourceforge.net/projects/boost/files/boost-docs/1.45.0/boost_pdf_1_45_0.tar.gz/download].
And you can print any pages you need (or even print all pages - but be warned that there are several hundred!).
Both html and pdf versions are highly hyperlinked.
The entire Boost.Math pdf can be searched with Adobe Reader, Edit, Find ...
This can often find what you seek, a partial substitute for a full index.
# ['I want a compact version for an embedded application. Can I use float precision?] [br]
Yes - by selecting RealType template parameter as float:
# ['I want a compact version for an embedded application. Can I use float precision?]
Yes - by selecting RealType template parameter as float:
for example normal_distribution<float> your_normal(mean, sd);
(But double may still be used internally, so space saving may be less that you hope for).
You can also change the promotion policy, but accuracy might be much reduced.
# ['I seem to get somewhat different results compared to other programs. Why?]
We hope Boost.Math to be more accurate: our priority is accuracy (over speed).
We hope Boost.Math to be more accurate: our priority is accuracy (over speed).
See the section on accuracy. But for evaluations that require iterations
there are parameters which can change the required accuracy (see __policy_section).
You might be able to squeeze a little more (or less) accuracy at the cost of runtime.
# ['Will my program run more slowly compared to other math functions and statistical libraries?]
Probably, thought not always, and not by too much: our priority is accuracy.
Probably, thought not always, and not by too much: our priority is accuracy.
For most functions, making sure you have the latest compiler version with all optimisations switched on is the key to speed.
For evaluations that require iteration, you may be able to gain a little more speed at the expense of accuracy.
See detailed suggestions and results on __performance.
# ['How do I handle infinity and NaNs portably?] [br]
See __fp_facets for Facets for Floating-Point Infinities and NaNs.
# ['Where are the pre-built libraries?] [br]
Good news - you probably don't need any! - just `#include <boost/`['math/distribution_you_want>].
# ['How do I handle infinity and NaNs portably?]
See __fp_facets for Facets for Floating-Point Infinities and NaNs.
# ['Where are the pre-built libraries?]
Good news - you probably don't need any! - just `#include <boost/`['math/distribution_you_want>].
But in the unlikely event that you do, see __building.
# ['I don't see the function or distribution that I want.] [br]
You could try an email to ask the authors - but no promises!
# ['I need more decimal digits for values/computations.] [br]
You can use Boost.Math with __multiprecision: typically
# ['I don't see the function or distribution that I want.]
You could try an email to ask the authors - but no promises!
# ['I need more decimal digits for values/computations.]
You can use Boost.Math with __multiprecision: typically
__cpp_dec_float is a useful user-defined type to provide a fixed number of decimal digits, usually 50 or 100.
# Why can't I write something really simple like `cpp_int one(1); cpp_dec_float_50 two(2); one * two;`
Because `cpp_int` might be bigger than `cpp_dec_float can hold`, so you must make an [*explicit] conversion.
Because `cpp_int` might be bigger than `cpp_dec_float can hold`, so you must make an [*explicit] conversion.
See [@http://svn.boost.org/svn/boost/trunk/libs/multiprecision/doc/html/boost_multiprecision/intro.html mixed multiprecision arithmetic]
and [@http://svn.boost.org/svn/boost/trunk/libs/multiprecision/doc/html/boost_multiprecision/tut/conversions.html conversion].

View File

@@ -144,4 +144,5 @@ test-suite examples :
[ run barycentric_interpolation_example_2.cpp : : : [ requires cxx11_smart_ptr cxx11_function_template_default_args ] ]
[ run cubic_b_spline_example.cpp : : : [ requires cxx11_smart_ptr cxx11_hdr_random cxx11_defaulted_functions ] ]
[ compile naive_monte_carlo_example.cpp : [ requires cxx11_auto_declarations cxx11_lambdas cxx11_unified_initialization_syntax cxx11_hdr_thread cxx11_hdr_atomic cxx11_decltype cxx11_hdr_future cxx11_hdr_chrono cxx11_hdr_random cxx11_allocator ] ] # requires user input, can't run it, take a long time too!
[ run catmull_rom_example.cpp : : : [ requires cxx17_if_constexpr cxx11_auto_declarations ] ] # Actually the C++17 features used is std::size, not if constexpr; looks like there isn't yet a test for it.
;

View File

@@ -0,0 +1,44 @@
// Copyright Nick Thompson, 2017
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or
// copy at http://www.boost.org/LICENSE_1_0.txt).
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <boost/math/interpolators/catmull_rom.hpp>
using std::sin;
using std::cos;
using boost::math::catmull_rom;
int main()
{
std::cout << "This shows how to use Boost's Catmull-Rom spline to create an Archimedean spiral.\n";
// The Archimedean spiral is given by r = a*theta. We have set a = 1.
std::vector<std::array<double, 2>> spiral_points(500);
double theta_max = M_PI;
for (size_t i = 0; i < spiral_points.size(); ++i)
{
double theta = ((double) i/ (double) spiral_points.size())*theta_max;
spiral_points[i] = {theta*cos(theta), theta*sin(theta)};
}
auto archimedean = catmull_rom<std::array<double,2>>(std::move(spiral_points));
double max_s = archimedean.max_parameter();
std::cout << "Max s = " << max_s << std::endl;
for (double s = 0; s < max_s; s += 0.01)
{
auto p = archimedean(s);
double x = p[0];
double y = p[1];
double r = sqrt(x*x + y*y);
double theta = atan2(y/r, x/r);
std::cout << "r = " << r << ", theta = " << theta << ", r - theta = " << r - theta << std::endl;
}
return 0;
}

View File

@@ -45,7 +45,7 @@ for this purpose, and here we use `float` precision where `max_digits10` = 9
to avoid displaying a distracting number of decimal digits.
[note Older compilers can use this formula to calculate `max_digits10`
from `std::numeric_limits<FPT>::digits10`:[br]
from `std::numeric_limits<FPT>::digits10`:
__spaces `int max_digits10 = 2 + std::numeric_limits<FPT>::digits10 * 3010/10000;`
] [/note]

View File

@@ -0,0 +1,284 @@
// Copyright Nick Thompson, 2017
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
// This computes the Catmull-Rom spline from a list of points.
#ifndef BOOST_MATH_INTERPOLATORS_CATMULL_ROM
#define BOOST_MATH_INTERPOLATORS_CATMULL_ROM
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
namespace boost{ namespace math{
namespace detail
{
template<class Point>
typename Point::value_type alpha_distance(Point const & p1, Point const & p2, typename Point::value_type alpha)
{
using std::pow;
using std::size;
typename Point::value_type dsq = 0;
for (size_t i = 0; i < size(p1); ++i)
{
typename Point::value_type dx = p1[i] - p2[i];
dsq += dx*dx;
}
return pow(dsq, alpha/2);
}
}
template <class Point>
class catmull_rom
{
public:
catmull_rom(std::vector<Point>&& points, bool closed = false, typename Point::value_type alpha = (typename Point::value_type) 1/ (typename Point::value_type) 2);
catmull_rom(std::initializer_list<Point> l, bool closed = false, typename Point::value_type alpha = (typename Point::value_type) 1/ (typename Point::value_type) 2) : catmull_rom(std::vector<Point>(l), closed, alpha) {}
typename Point::value_type max_parameter() const
{
return m_max_s;
}
typename Point::value_type parameter_at_point(size_t i) const
{
return m_s[i+1];
}
Point operator()(const typename Point::value_type s) const;
Point prime(const typename Point::value_type s) const;
std::vector<Point>&& get_points()
{
return std::move(m_pnts);
}
private:
std::vector<Point> m_pnts;
std::vector<typename Point::value_type> m_s;
typename Point::value_type m_max_s;
};
template<class Point>
catmull_rom<Point>::catmull_rom(std::vector<Point>&& points, bool closed, typename Point::value_type alpha) : m_pnts(std::move(points))
{
size_t num_pnts = m_pnts.size();
//std::cout << "Number of points = " << num_pnts << "\n";
if (num_pnts < 4)
{
throw std::domain_error("The Catmull-Rom curve requires at least 4 points.");
}
if (alpha < 0 || alpha > 1)
{
throw std::domain_error("The parametrization alpha must be in the range [0,1].");
}
using std::abs;
m_s.resize(num_pnts+3);
m_pnts.resize(num_pnts+3);
//std::cout << "Number of points now = " << m_pnts.size() << "\n";
m_pnts[num_pnts+1] = m_pnts[0];
m_pnts[num_pnts+2] = m_pnts[1];
auto tmp = m_pnts[num_pnts-1];
for (int64_t i = num_pnts-1; i >= 0; --i)
{
m_pnts[i+1] = m_pnts[i];
}
m_pnts[0] = tmp;
m_s[0] = -detail::alpha_distance<Point>(m_pnts[0], m_pnts[1], alpha);
if (abs(m_s[0]) < std::numeric_limits<typename Point::value_type>::epsilon())
{
throw std::domain_error("The first and last point should not be the same.\n");
}
m_s[1] = 0;
for (size_t i = 2; i < m_s.size(); ++i)
{
typename Point::value_type d = detail::alpha_distance<Point>(m_pnts[i], m_pnts[i-1], alpha);
if (abs(d) < std::numeric_limits<typename Point::value_type>::epsilon())
{
throw std::domain_error("The control points of the Catmull-Rom curve are too close together; this will lead to ill-conditioning.\n");
}
m_s[i] = m_s[i-1] + d;
}
if(closed)
{
m_max_s = m_s[num_pnts+1];
}
else
{
m_max_s = m_s[num_pnts];
}
}
template<class Point>
Point catmull_rom<Point>::operator()(const typename Point::value_type s) const
{
using std::size;
if (s < 0 || s > m_max_s)
{
throw std::domain_error("Parameter outside bounds.");
}
auto it = std::upper_bound(m_s.begin(), m_s.end(), s);
//Now *it >= s. We want the index such that m_s[i] <= s < m_s[i+1]:
size_t i = std::distance(m_s.begin(), it - 1);
// Only denom21 is used twice:
typename Point::value_type denom21 = 1/(m_s[i+1] - m_s[i]);
typename Point::value_type s0s = m_s[i-1] - s;
typename Point::value_type s1s = m_s[i] - s;
typename Point::value_type s2s = m_s[i+1] - s;
typename Point::value_type s3s = m_s[i+2] - s;
Point A1_or_A3;
typename Point::value_type denom = 1/(m_s[i] - m_s[i-1]);
for(size_t j = 0; j < size(m_pnts[0]); ++j)
{
A1_or_A3[j] = denom*(s1s*m_pnts[i-1][j] - s0s*m_pnts[i][j]);
}
Point A2_or_B2;
for(size_t j = 0; j < size(m_pnts[0]); ++j)
{
A2_or_B2[j] = denom21*(s2s*m_pnts[i][j] - s1s*m_pnts[i+1][j]);
}
Point B1_or_C;
denom = 1/(m_s[i+1] - m_s[i-1]);
for(size_t j = 0; j < size(m_pnts[0]); ++j)
{
B1_or_C[j] = denom*(s2s*A1_or_A3[j] - s0s*A2_or_B2[j]);
}
denom = 1/(m_s[i+2] - m_s[i+1]);
for(size_t j = 0; j < size(m_pnts[0]); ++j)
{
A1_or_A3[j] = denom*(s3s*m_pnts[i+1][j] - s2s*m_pnts[i+2][j]);
}
Point B2;
denom = 1/(m_s[i+2] - m_s[i]);
for(size_t j = 0; j < size(m_pnts[0]); ++j)
{
B2[j] = denom*(s3s*A2_or_B2[j] - s1s*A1_or_A3[j]);
}
for(size_t j = 0; j < size(m_pnts[0]); ++j)
{
B1_or_C[j] = denom21*(s2s*B1_or_C[j] - s1s*B2[j]);
}
return B1_or_C;
}
template<class Point>
Point catmull_rom<Point>::prime(const typename Point::value_type s) const
{
using std::size;
// https://math.stackexchange.com/questions/843595/how-can-i-calculate-the-derivative-of-a-catmull-rom-spline-with-nonuniform-param
// http://denkovacs.com/2016/02/catmull-rom-spline-derivatives/
if (s < 0 || s > m_max_s)
{
throw std::domain_error("Parameter outside bounds.\n");
}
auto it = std::upper_bound(m_s.begin(), m_s.end(), s);
//Now *it >= s. We want the index such that m_s[i] <= s < m_s[i+1]:
size_t i = std::distance(m_s.begin(), it - 1);
Point A1;
typename Point::value_type denom = 1/(m_s[i] - m_s[i-1]);
typename Point::value_type k1 = (m_s[i]-s)*denom;
typename Point::value_type k2 = (s - m_s[i-1])*denom;
for (size_t j = 0; j < size(m_pnts[0]); ++j)
{
A1[j] = k1*m_pnts[i-1][j] + k2*m_pnts[i][j];
}
Point A1p;
for (size_t j = 0; j < size(m_pnts[0]); ++j)
{
A1p[j] = denom*(m_pnts[i][j] - m_pnts[i-1][j]);
}
Point A2;
denom = 1/(m_s[i+1] - m_s[i]);
k1 = (m_s[i+1]-s)*denom;
k2 = (s - m_s[i])*denom;
for (size_t j = 0; j < size(m_pnts[0]); ++j)
{
A2[j] = k1*m_pnts[i][j] + k2*m_pnts[i+1][j];
}
Point A2p;
for (size_t j = 0; j < size(m_pnts[0]); ++j)
{
A2p[j] = denom*(m_pnts[i+1][j] - m_pnts[i][j]);
}
Point B1;
for (size_t j = 0; j < size(m_pnts[0]); ++j)
{
B1[j] = k1*A1[j] + k2*A2[j];
}
Point A3;
denom = 1/(m_s[i+2] - m_s[i+1]);
k1 = (m_s[i+2]-s)*denom;
k2 = (s - m_s[i+1])*denom;
for (size_t j = 0; j < size(m_pnts[0]); ++j)
{
A3[j] = k1*m_pnts[i+1][j] + k2*m_pnts[i+2][j];
}
Point A3p;
for (size_t j = 0; j < size(m_pnts[0]); ++j)
{
A3p[j] = denom*(m_pnts[i+2][j] - m_pnts[i+1][j]);
}
Point B2;
denom = 1/(m_s[i+2] - m_s[i]);
k1 = (m_s[i+2]-s)*denom;
k2 = (s - m_s[i])*denom;
for (size_t j = 0; j < size(m_pnts[0]); ++j)
{
B2[j] = k1*A2[j] + k2*A3[j];
}
Point B1p;
denom = 1/(m_s[i+1] - m_s[i-1]);
for (size_t j = 0; j < size(m_pnts[0]); ++j)
{
B1p[j] = denom*(A2[j] - A1[j] + (m_s[i+1]- s)*A1p[j] + (s-m_s[i-1])*A2p[j]);
}
Point B2p;
denom = 1/(m_s[i+2] - m_s[i]);
for (size_t j = 0; j < size(m_pnts[0]); ++j)
{
B2p[j] = denom*(A3[j] - A2[j] + (m_s[i+2] - s)*A2p[j] + (s - m_s[i])*A3p[j]);
}
Point Cp;
denom = 1/(m_s[i+1] - m_s[i]);
for (size_t j = 0; j < size(m_pnts[0]); ++j)
{
Cp[j] = denom*(B2[j] - B1[j] + (m_s[i+1] - s)*B1p[j] + (s - m_s[i])*B2p[j]);
}
return Cp;
}
}}
#endif

View File

@@ -832,8 +832,8 @@ test-suite distribution_tests :
[ run test_rayleigh.cpp ../../test/build//boost_unit_test_framework ]
[ run test_students_t.cpp ../../test/build//boost_unit_test_framework ]
[ run test_skew_normal.cpp ../../test/build//boost_unit_test_framework ]
[ run test_trapezoidal.cpp ../../test/build//boost_unit_test_framework : : :
release [ requires cxx11_lambdas cxx11_auto_declarations cxx11_decltype cxx11_unified_initialization_syntax cxx11_variadic_templates ]
[ run test_trapezoidal.cpp ../../test/build//boost_unit_test_framework : : :
release [ requires cxx11_lambdas cxx11_auto_declarations cxx11_decltype cxx11_unified_initialization_syntax cxx11_variadic_templates ]
[ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : <linkflags>"-Bstatic -lquadmath -Bdynamic" ] ]
[ run test_triangular.cpp pch ../../test/build//boost_unit_test_framework ]
[ run test_uniform.cpp pch ../../test/build//boost_unit_test_framework ]
@@ -901,6 +901,7 @@ test-suite misc :
[ run test_barycentric_rational.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx11_smart_ptr ] [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : <linkflags>-lquadmath ] ]
[ run test_constant_generate.cpp : : : release <define>USE_CPP_FLOAT=1 <exception-handling>off:<build>no ]
[ run test_cubic_b_spline.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx11_smart_ptr cxx11_defaulted_functions ] <debug-symbols>off <toolset>msvc:<cxxflags>/bigobj release ]
[ run catmull_rom_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ] # does not in fact require C++17 constexpr; requires C++17 std::size.
[ run test_real_concept.cpp ../../test/build//boost_unit_test_framework ]
[ run test_remez.cpp pch ../../test/build//boost_unit_test_framework ]
[ run test_roots.cpp pch ../../test/build//boost_unit_test_framework ]

399
test/catmull_rom_test.cpp Normal file
View File

@@ -0,0 +1,399 @@
/*
* Copyright Nick Thompson, 2017
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#define BOOST_TEST_MODULE catmull_rom_test
#include <array>
#include <random>
#include <boost/cstdfloat.hpp>
#include <boost/type_index.hpp>
#include <boost/test/included/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
#include <boost/math/interpolators/catmull_rom.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using std::abs;
using boost::multiprecision::cpp_bin_float_50;
using boost::math::catmull_rom;
template<class Real>
void test_alpha_distance()
{
Real tol = std::numeric_limits<Real>::epsilon();
std::array<Real, 3> v1 = {0,0,0};
std::array<Real, 3> v2 = {1,0,0};
Real alpha = 0.5;
Real d = boost::math::detail::alpha_distance<std::array<Real, 3>>(v1, v2, alpha);
BOOST_CHECK_CLOSE_FRACTION(d, 1, tol);
d = boost::math::detail::alpha_distance<std::array<Real, 3>>(v1, v2, 0.0);
BOOST_CHECK_CLOSE_FRACTION(d, 1, tol);
d = boost::math::detail::alpha_distance<std::array<Real, 3>>(v1, v2, 1.0);
BOOST_CHECK_CLOSE_FRACTION(d, 1, tol);
v2[0] = 2;
d = boost::math::detail::alpha_distance<std::array<Real, 3>>(v1, v2, alpha);
BOOST_CHECK_CLOSE_FRACTION(d, pow(2, (Real)1/ (Real) 2), tol);
d = boost::math::detail::alpha_distance<std::array<Real, 3>>(v1, v2, 0.0);
BOOST_CHECK_CLOSE_FRACTION(d, 1, tol);
d = boost::math::detail::alpha_distance<std::array<Real, 3>>(v1, v2, 1.0);
BOOST_CHECK_CLOSE_FRACTION(d, 2, tol);
}
template<class Real>
void test_linear()
{
std::cout << "Testing that the Catmull-Rom spline interpolates linear functions correctly on type "
<< boost::typeindex::type_id<Real>().pretty_name() << "\n";
Real tol = 10*std::numeric_limits<Real>::epsilon();
std::vector<std::array<Real, 3>> v(4);
v[0] = {0,0,0};
v[1] = {1,0,0};
v[2] = {2,0,0};
v[3] = {3,0,0};
catmull_rom<std::array<Real, 3>> cr(std::move(v));
// Test that the interpolation condition is obeyed:
BOOST_CHECK_CLOSE_FRACTION(cr.max_parameter(), 3, tol);
auto p0 = cr(0.0);
BOOST_CHECK_SMALL(p0[0], tol);
BOOST_CHECK_SMALL(p0[1], tol);
BOOST_CHECK_SMALL(p0[2], tol);
auto p1 = cr(1.0);
BOOST_CHECK_CLOSE_FRACTION(p1[0], 1, tol);
BOOST_CHECK_SMALL(p1[1], tol);
BOOST_CHECK_SMALL(p1[2], tol);
auto p2 = cr(2.0);
BOOST_CHECK_CLOSE_FRACTION(p2[0], 2, tol);
BOOST_CHECK_SMALL(p2[1], tol);
BOOST_CHECK_SMALL(p2[2], tol);
auto p3 = cr(3.0);
BOOST_CHECK_CLOSE_FRACTION(p3[0], 3, tol);
BOOST_CHECK_SMALL(p3[1], tol);
BOOST_CHECK_SMALL(p3[2], tol);
Real s = cr.parameter_at_point(0);
BOOST_CHECK_SMALL(s, tol);
s = cr.parameter_at_point(1);
BOOST_CHECK_CLOSE_FRACTION(s, 1, tol);
s = cr.parameter_at_point(2);
BOOST_CHECK_CLOSE_FRACTION(s, 2, tol);
s = cr.parameter_at_point(3);
BOOST_CHECK_CLOSE_FRACTION(s, 3, tol);
// Test that the function is linear on the interval [1,2]:
for (double s = 1; s < 2; s += 0.01)
{
auto p = cr(s);
BOOST_CHECK_CLOSE_FRACTION(p[0], s, tol);
BOOST_CHECK_SMALL(p[1], tol);
BOOST_CHECK_SMALL(p[2], tol);
auto tangent = cr.prime(s);
BOOST_CHECK_CLOSE_FRACTION(tangent[0], 1, tol);
BOOST_CHECK_SMALL(tangent[1], tol);
BOOST_CHECK_SMALL(tangent[2], tol);
}
}
template<class Real>
void test_circle()
{
std::cout << "Testing that the Catmull-Rom spline interpolates circles correctly on type "
<< boost::typeindex::type_id<Real>().pretty_name() << "\n";
Real tol = 10*std::numeric_limits<Real>::epsilon();
std::vector<std::array<Real, 2>> v(20*sizeof(Real));
std::vector<std::array<Real, 2>> u(20*sizeof(Real));
for (size_t i = 0; i < v.size(); ++i)
{
Real theta = ((Real) i/ (Real) v.size())*2*M_PI;
v[i] = {cos(theta), sin(theta)};
u[i] = v[i];
}
catmull_rom<std::array<Real, 2>> circle(std::move(v), true);
// Interpolation condition:
for (size_t i = 0; i < v.size(); ++i)
{
Real s = circle.parameter_at_point(i);
auto p = circle(s);
Real x = p[0];
Real y = p[1];
if (abs(x) < std::numeric_limits<Real>::epsilon())
{
BOOST_CHECK_SMALL(u[i][0], tol);
}
if (abs(y) < std::numeric_limits<Real>::epsilon())
{
BOOST_CHECK_SMALL(u[i][1], tol);
}
else
{
BOOST_CHECK_CLOSE_FRACTION(x, u[i][0], tol);
BOOST_CHECK_CLOSE_FRACTION(y, u[i][1], tol);
}
}
Real max_s = circle.max_parameter();
for(Real s = 0; s < max_s; s += 0.01)
{
auto p = circle(s);
Real x = p[0];
Real y = p[1];
BOOST_CHECK_CLOSE_FRACTION(x*x+y*y, 1, 0.001);
}
}
template<class Real, size_t dimension>
void test_affine_invariance()
{
std::cout << "Testing that the Catmull-Rom spline is affine invariant in dimension "
<< dimension << " on type "
<< boost::typeindex::type_id<Real>().pretty_name() << "\n";
Real tol = 1000*std::numeric_limits<Real>::epsilon();
std::vector<std::array<Real, dimension>> v(100);
std::vector<std::array<Real, dimension>> u(100);
std::mt19937_64 gen(438232);
Real inv_denom = (Real) 100/( (Real) gen.max() + (Real) 2);
for(size_t j = 0; j < dimension; ++j)
{
v[0][j] = gen()*inv_denom;
u[0][j] = v[0][j];
}
for (size_t i = 1; i < v.size(); ++i)
{
for(size_t j = 0; j < dimension; ++j)
{
v[i][j] = v[i-1][j] + gen()*inv_denom;
u[i][j] = v[i][j];
}
}
std::array<Real, dimension> affine_shift;
for (size_t j = 0; j < dimension; ++j)
{
affine_shift[j] = gen()*inv_denom;
}
catmull_rom<std::array<Real, dimension>> cr1(std::move(v));
for(size_t i = 0; i< u.size(); ++i)
{
for(size_t j = 0; j < dimension; ++j)
{
u[i][j] += affine_shift[j];
}
}
catmull_rom<std::array<Real, dimension>> cr2(std::move(u));
BOOST_CHECK_CLOSE_FRACTION(cr1.max_parameter(), cr2.max_parameter(), tol);
Real ds = cr1.max_parameter()/1024;
for (Real s = 0; s < cr1.max_parameter(); s += ds)
{
auto p0 = cr1(s);
auto p1 = cr2(s);
auto tangent0 = cr1.prime(s);
auto tangent1 = cr2.prime(s);
for (size_t j = 0; j < dimension; ++j)
{
BOOST_CHECK_CLOSE_FRACTION(p0[j] + affine_shift[j], p1[j], tol);
if (abs(tangent0[j]) > 5000*tol)
{
BOOST_CHECK_CLOSE_FRACTION(tangent0[j], tangent1[j], 5000*tol);
}
}
}
}
template<class Real>
void test_helix()
{
std::cout << "Testing that the Catmull-Rom spline interpolates helices correctly on type "
<< boost::typeindex::type_id<Real>().pretty_name() << "\n";
Real tol = 0.001;
std::vector<std::array<Real, 3>> v(2000*sizeof(Real));
for (size_t i = 0; i < v.size(); ++i)
{
Real theta = ((Real) i/ (Real) v.size())*2*M_PI;
v[i] = {cos(theta), sin(theta), theta};
}
catmull_rom<std::array<Real, 3>> helix(std::move(v));
// Interpolation condition:
for (size_t i = 0; i < v.size(); ++i)
{
Real s = helix.parameter_at_point(i);
auto p = helix(s);
Real t = p[2];
Real x = p[0];
Real y = p[1];
if (abs(x) < tol)
{
BOOST_CHECK_SMALL(cos(t), tol);
}
if (abs(y) < tol)
{
BOOST_CHECK_SMALL(sin(t), tol);
}
else
{
BOOST_CHECK_CLOSE_FRACTION(x, cos(t), tol);
BOOST_CHECK_CLOSE_FRACTION(y, sin(t), tol);
}
}
Real max_s = helix.max_parameter();
for(Real s = helix.parameter_at_point(1); s < max_s; s += 0.01)
{
auto p = helix(s);
Real x = p[0];
Real y = p[1];
Real t = p[2];
BOOST_CHECK_CLOSE_FRACTION(x*x+y*y, (Real) 1, (Real) 0.01);
if (abs(x) < 0.01)
{
BOOST_CHECK_SMALL(cos(t), (Real) 0.05);
}
if (abs(y) < 0.01)
{
BOOST_CHECK_SMALL(sin(t), (Real) 0.05);
}
else
{
BOOST_CHECK_CLOSE_FRACTION(x, cos(t), (Real) 0.05);
BOOST_CHECK_CLOSE_FRACTION(y, sin(t), (Real) 0.05);
}
}
}
template<class Real>
class mypoint3d
{
public:
// Must define a value_type:
typedef Real value_type;
// Regular constructor:
mypoint3d(Real x, Real y, Real z)
{
m_vec[0] = x;
m_vec[1] = y;
m_vec[2] = z;
}
// Must define a default constructor:
mypoint3d() {}
// Must define array access:
Real operator[](size_t i) const
{
return m_vec[i];
}
// Array element assignment:
Real& operator[](size_t i)
{
return m_vec[i];
}
private:
std::array<Real, 3> m_vec;
};
// Must define the free function "size()":
template<class Real>
constexpr size_t size(const mypoint3d<Real>& c)
{
return 3;
}
template<class Real>
void test_data_representations()
{
std::cout << "Testing that the Catmull-Rom spline works with multiple data representations.\n";
mypoint3d<Real> p0(0.1, 0.2, 0.3);
mypoint3d<Real> p1(0.2, 0.3, 0.4);
mypoint3d<Real> p2(0.3, 0.4, 0.5);
mypoint3d<Real> p3(0.4, 0.5, 0.6);
mypoint3d<Real> p4(0.5, 0.6, 0.7);
mypoint3d<Real> p5(0.6, 0.7, 0.8);
// Tests initializer_list:
catmull_rom<mypoint3d<Real>> cat({p0, p1, p2, p3, p4, p5});
Real tol = 0.001;
auto p = cat(cat.parameter_at_point(0));
BOOST_CHECK_CLOSE_FRACTION(p[0], p0[0], tol);
BOOST_CHECK_CLOSE_FRACTION(p[1], p0[1], tol);
BOOST_CHECK_CLOSE_FRACTION(p[2], p0[2], tol);
p = cat(cat.parameter_at_point(1));
BOOST_CHECK_CLOSE_FRACTION(p[0], p1[0], tol);
BOOST_CHECK_CLOSE_FRACTION(p[1], p1[1], tol);
BOOST_CHECK_CLOSE_FRACTION(p[2], p1[2], tol);
}
BOOST_AUTO_TEST_CASE(catmull_rom_test)
{
test_data_representations<float>();
test_alpha_distance<float>();
test_alpha_distance<double>();
test_alpha_distance<long double>();
test_alpha_distance<cpp_bin_float_50>();
test_linear<float>();
test_linear<double>();
test_linear<long double>();
test_linear<cpp_bin_float_50>();
test_circle<float>();
test_circle<double>();
test_circle<long double>();
test_circle<cpp_bin_float_50>();
test_helix<float>();
test_helix<double>();
test_affine_invariance<float, 1>();
test_affine_invariance<float, 2>();
test_affine_invariance<float, 3>();
test_affine_invariance<float, 4>();
test_affine_invariance<double, 1>();
test_affine_invariance<double, 2>();
test_affine_invariance<double, 3>();
test_affine_invariance<double, 4>();
test_affine_invariance<long double, 1>();
test_affine_invariance<long double, 2>();
test_affine_invariance<long double, 3>();
test_affine_invariance<long double, 4>();
test_affine_invariance<cpp_bin_float_50, 1>();
test_affine_invariance<cpp_bin_float_50, 2>();
test_affine_invariance<cpp_bin_float_50, 3>();
test_affine_invariance<cpp_bin_float_50, 4>();
}

View File

@@ -0,0 +1,21 @@
// Copyright Nick Thompson 2018.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/math/concepts/std_real_concept.hpp>
#include <boost/math/interpolators/catmull_rom.hpp>
void compile_and_link_test()
{
std::vector<boost::math::concepts::std_real_concept> p0{0.1, 0.2, 0.3};
std::vector<boost::math::concepts::std_real_concept> p1{0.2, 0.3, 0.4};
std::vector<boost::math::concepts::std_real_concept> p2{0.3, 0.4, 0.5};
std::vector<boost::math::concepts::std_real_concept> p3{0.4, 0.5, 0.6};
std::vector<boost::math::concepts::std_real_concept> p4{0.5, 0.6, 0.7};
std::vector<boost::math::concepts::std_real_concept> p5{0.6, 0.7, 0.8};
std::vector<std::vector<boost::math::concepts::std_real_concept>> v{p0, p1, p2, p3, p4, p5};
boost::math::catmull_rom<std::vector<boost::math::concepts::std_real_concept>> cat(v.data(), v.size());
cat(0.0);
cat.prime(0.0);
}

View File

@@ -0,0 +1,28 @@
// Copyright Nick Thompson 2018.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Basic sanity check that header <boost/math/interpolators/catmull_rom.hpp>
// #includes all the files that it needs to.
//
#include <boost/math/interpolators/catmull_rom.hpp>
//
// Note this header includes no other headers, this is
// important if this test is to be meaningful:
//
#include "test_compile_result.hpp"
void compile_and_link_test()
{
std::vector<double> p0{0.1, 0.2, 0.3};
std::vector<double> p1{0.2, 0.3, 0.4};
std::vector<double> p2{0.3, 0.4, 0.5};
std::vector<double> p3{0.4, 0.5, 0.6};
std::vector<double> p4{0.5, 0.6, 0.7};
std::vector<double> p5{0.6, 0.7, 0.8};
std::vector<std::vector<double>> v{p0, p1, p2, p3, p4, p5};
boost::math::catmull_rom<std::vector<double>> cat(v.data(), v.size());
check_result<double>(cat(0.0));
check_result<double>(cat.prime(0.0));
}