1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Cardinal Quadratic B-spline interpolation</title> 5<link rel="stylesheet" href="../math.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../index.html" title="Math Toolkit 2.12.0"> 8<link rel="up" href="../interpolation.html" title="Chapter 12. Interpolation"> 9<link rel="prev" href="cardinal_cubic_b.html" title="Cardinal Cubic B-spline interpolation"> 10<link rel="next" href="cardinal_quintic_b.html" title="Cardinal Quintic B-spline interpolation"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="cardinal_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="cardinal_quintic_b.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 27<a name="math_toolkit.cardinal_quadratic_b"></a><a class="link" href="cardinal_quadratic_b.html" title="Cardinal Quadratic B-spline interpolation">Cardinal Quadratic B-spline 28 interpolation</a> 29</h2></div></div></div> 30<h4> 31<a name="math_toolkit.cardinal_quadratic_b.h0"></a> 32 <span class="phrase"><a name="math_toolkit.cardinal_quadratic_b.synopsis"></a></span><a class="link" href="cardinal_quadratic_b.html#math_toolkit.cardinal_quadratic_b.synopsis">Synopsis</a> 33 </h4> 34<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">cardinal_quadratic_b_spline</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 35</pre> 36<pre class="programlisting"><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">namespace</span> <span class="identifier">interpolators</span> <span class="special">{</span> 37 38<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Real</span><span class="special">></span> 39<span class="keyword">class</span> <span class="identifier">cardinal_quadratic_b_spline</span> 40<span class="special">{</span> 41<span class="keyword">public</span><span class="special">:</span> 42 <span class="comment">// If you don't know the value of the derivative at the endpoints, leave them as NaNs and the routine will estimate them.</span> 43 <span class="comment">// y[0] = y(a), y[n - 1] = y(b), step_size = (b - a)/(n -1).</span> 44 <span class="identifier">cardinal_quadratic_b_spline</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Real</span><span class="special">*</span> <span class="keyword">const</span> <span class="identifier">y</span><span class="special">,</span> 45 <span class="identifier">size_t</span> <span class="identifier">n</span><span class="special">,</span> 46 <span class="identifier">Real</span> <span class="identifier">t0</span> <span class="comment">/* initial time, left endpoint */</span><span class="special">,</span> 47 <span class="identifier">Real</span> <span class="identifier">h</span> <span class="comment">/*spacing, stepsize*/</span><span class="special">,</span> 48 <span class="identifier">Real</span> <span class="identifier">left_endpoint_derivative</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>::</span><span class="identifier">quiet_NaN</span><span class="special">(),</span> 49 <span class="identifier">Real</span> <span class="identifier">right_endpoint_derivative</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>::</span><span class="identifier">quiet_NaN</span><span class="special">())</span> 50 51 <span class="identifier">cardinal_quadratic_b_spline</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">Real</span><span class="special">></span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">y</span><span class="special">,</span> 52 <span class="identifier">Real</span> <span class="identifier">t0</span> <span class="comment">/* initial time, left endpoint */</span><span class="special">,</span> 53 <span class="identifier">Real</span> <span class="identifier">h</span> <span class="comment">/*spacing, stepsize*/</span><span class="special">,</span> 54 <span class="identifier">Real</span> <span class="identifier">left_endpoint_derivative</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>::</span><span class="identifier">quiet_NaN</span><span class="special">(),</span> 55 <span class="identifier">Real</span> <span class="identifier">right_endpoint_derivative</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>::</span><span class="identifier">quiet_NaN</span><span class="special">())</span> 56 57 <span class="identifier">Real</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Real</span> <span class="identifier">t</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 58 59 <span class="identifier">Real</span> <span class="identifier">prime</span><span class="special">(</span><span class="identifier">Real</span> <span class="identifier">t</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 60<span class="special">};</span> 61<span class="special">}}}</span> 62</pre> 63<h4> 64<a name="math_toolkit.cardinal_quadratic_b.h1"></a> 65 <span class="phrase"><a name="math_toolkit.cardinal_quadratic_b.cardinal_quadratic_b_spline_inte"></a></span><a class="link" href="cardinal_quadratic_b.html#math_toolkit.cardinal_quadratic_b.cardinal_quadratic_b_spline_inte">Cardinal 66 Quadratic B-Spline Interpolation</a> 67 </h4> 68<p> 69 The cardinal quadratic B-spline interpolator is very nearly the same as the 70 cubic B-spline interpolator, with the modification that the basis functions 71 are constructed by convolving a box function with itself twice, rather than 72 three times as is done with the cubic B-spline. 73 </p> 74<p> 75 Since the basis functions are less smooth than the cubic B-spline, you will 76 nearly always wish to use the cubic B-spline interpolator rather than this. 77 However, this interpolator is occasionally useful for approximating functions 78 of reduced smoothness, as hence finds use internally in the Boost.Math library. 79 </p> 80<p> 81 It is reasonable to test this interpolator against the cubic b-spline interpolator 82 when you are approximating functions which are two or three times continuously 83 differentiable, but not three or four times differentiable. 84 </p> 85</div> 86<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 87<td align="left"></td> 88<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar 89 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, 90 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan 91 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, 92 Daryle Walker and Xiaogang Zhang<p> 93 Distributed under the Boost Software License, Version 1.0. (See accompanying 94 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>) 95 </p> 96</div></td> 97</tr></table> 98<hr> 99<div class="spirit-nav"> 100<a accesskey="p" href="cardinal_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="cardinal_quintic_b.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 101</div> 102</body> 103</html> 104