1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Wavelet Transforms</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="../quadrature.html" title="Chapter 13. Quadrature and Differentiation"> 9<link rel="prev" href="naive_monte_carlo.html" title="Naive Monte Carlo Integration"> 10<link rel="next" href="diff.html" title="Numerical Differentiation"> 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="naive_monte_carlo.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../quadrature.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="diff.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.wavelet_transforms"></a><a class="link" href="wavelet_transforms.html" title="Wavelet Transforms">Wavelet Transforms</a> 28</h2></div></div></div> 29<h4> 30<a name="math_toolkit.wavelet_transforms.h0"></a> 31 <span class="phrase"><a name="math_toolkit.wavelet_transforms.synopsis"></a></span><a class="link" href="wavelet_transforms.html#math_toolkit.wavelet_transforms.synopsis">Synopsis</a> 32 </h4> 33<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">quadrature</span><span class="special">/</span><span class="identifier">wavelet_transforms</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 34 35<span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">quadrature</span> <span class="special">{</span> 36 37<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Real</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">p</span><span class="special">></span> 38<span class="keyword">class</span> <span class="identifier">daubechies_wavelet_transform</span> 39<span class="special">{</span> 40<span class="keyword">public</span><span class="special">:</span> 41 <span class="identifier">daubechies_wavelet_transform</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">grid_refinements</span> <span class="special">=</span> <span class="special">-</span><span class="number">1</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">tol</span> <span class="special">=</span> <span class="number">100</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">epsilon</span><span class="special">(),</span> 42 <span class="keyword">int</span> <span class="identifier">max_refinements</span> <span class="special">=</span> <span class="number">12</span><span class="special">)</span> <span class="special">{}</span> 43 44 <span class="identifier">daubechies_wavelet_transform</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</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">daubechies_wavelet</span><span class="special"><</span><span class="identifier">Real</span><span class="special">,</span> <span class="identifier">p</span><span class="special">></span> <span class="identifier">wavelet</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">tol</span> <span class="special">=</span> <span class="number">100</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">epsilon</span><span class="special">(),</span> 45 <span class="keyword">int</span> <span class="identifier">max_refinements</span> <span class="special">=</span> <span class="number">12</span><span class="special">);</span> 46 47 <span class="keyword">auto</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="identifier">Real</span> <span class="identifier">t</span><span class="special">)-></span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">F</span><span class="special">>()(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>()))</span> <span class="keyword">const</span><span class="special">;</span> 48 49<span class="special">};</span> 50<span class="special">}</span> 51</pre> 52<p> 53 The wavelet transform of a function <span class="emphasis"><em>f</em></span> with respect to 54 a wavelet ψ is 55 </p> 56<p> 57 <span class="inlinemediaobject"><object type="image/svg+xml" data="../../graphs/wavelet_transform_definition.svg" width="333" height="48"></object></span> 58 </p> 59<p> 60 For compactly supported Daubechies wavelets, the bounds can always be taken 61 as finite, and we have 62 </p> 63<p> 64 <span class="inlinemediaobject"><object type="image/svg+xml" data="../../graphs/daubechies_wavelet_transform_definition.svg" width="328" height="44"></object></span> 65 </p> 66<p> 67 which also defines the <span class="emphasis"><em>s</em></span>=0 case. 68 </p> 69<p> 70 The code provided by Boost merely forwards a lambda to the trapezoidal quadrature 71 routine, which converges quickly due to the Euler-Maclaurin summation formula. 72 However, the convergence is not as rapid as for infinitely differentiable functions, 73 so the default tolerances are modified. 74 </p> 75<p> 76 A basic usage is 77 </p> 78<pre class="programlisting"><span class="keyword">auto</span> <span class="identifier">psi</span> <span class="special">=</span> <span class="identifier">daubechies_wavelet</span><span class="special"><</span><span class="keyword">double</span><span class="special">,</span> <span class="number">8</span><span class="special">>();</span> 79<span class="keyword">auto</span> <span class="identifier">f</span> <span class="special">=</span> <span class="special">[](</span><span class="keyword">double</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> 80 <span class="keyword">return</span> <span class="identifier">sin</span><span class="special">(</span><span class="number">1</span><span class="special">/</span><span class="identifier">x</span><span class="special">);</span> 81<span class="special">};</span> 82<span class="keyword">auto</span> <span class="identifier">Wf</span> <span class="special">=</span> <span class="identifier">daubechies_wavelet_transform</span><span class="special">(</span><span class="identifier">f</span><span class="special">,</span> <span class="identifier">psi</span><span class="special">);</span> 83 84<span class="keyword">double</span> <span class="identifier">w</span> <span class="special">=</span> <span class="identifier">Wf</span><span class="special">(</span><span class="number">0.8</span><span class="special">,</span> <span class="number">7.2</span><span class="special">);</span> 85</pre> 86<p> 87 An image from this function is shown below. 88 </p> 89<p> 90 <span class="inlinemediaobject"><img src="../../graphs/scalogram_sin1t_light.png"></span> 91 </p> 92</div> 93<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 94<td align="left"></td> 95<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar 96 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, 97 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan 98 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, 99 Daryle Walker and Xiaogang Zhang<p> 100 Distributed under the Boost Software License, Version 1.0. (See accompanying 101 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>) 102 </p> 103</div></td> 104</tr></table> 105<hr> 106<div class="spirit-nav"> 107<a accesskey="p" href="naive_monte_carlo.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../quadrature.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="diff.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 108</div> 109</body> 110</html> 111