]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/doc/html/math_toolkit/powers/hypot.html
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / doc / html / math_toolkit / powers / hypot.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>hypot</title>
5 <link rel="stylesheet" href="../../math.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
7 <link rel="home" href="../../index.html" title="Math Toolkit 2.5.1">
8 <link rel="up" href="../powers.html" title="Basic Functions">
9 <link rel="prev" href="powm1.html" title="powm1">
10 <link rel="next" href="ct_pow.html" title="Compile Time Power of a Runtime Base">
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="powm1.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../powers.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="ct_pow.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h3 class="title">
27 <a name="math_toolkit.powers.hypot"></a><a class="link" href="hypot.html" title="hypot">hypot</a>
28 </h3></div></div></div>
29 <pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">&gt;</span>
30 <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">hypot</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">y</span><span class="special">);</span>
31
32 <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter&#160;15.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
33 <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">hypot</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">y</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter&#160;15.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
34 </pre>
35 <p>
36 <span class="bold"><strong>Effects: </strong></span> computes <span class="inlinemediaobject"><img src="../../../equations/hypot.svg"></span>
37 in such a way
38 as to avoid undue underflow and overflow.
39 </p>
40 <p>
41 The return type of this function is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result
42 type calculation rules</em></span></a> when T1 and T2 are of different
43 types.
44 </p>
45 <p>
46 The final <a class="link" href="../../policy.html" title="Chapter&#160;15.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
47 be used to control the behaviour of the function: how it handles errors,
48 what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;15.&#160;Policies: Controlling Precision, Error Handling etc">policy
49 documentation for more details</a>.
50 </p>
51 <p>
52 When calculating <span class="inlinemediaobject"><img src="../../../equations/hypot.svg"></span> it's quite easy for the intermediate terms to
53 either overflow or underflow, even though the result is in fact perfectly
54 representable.
55 </p>
56 <h5>
57 <a name="math_toolkit.powers.hypot.h0"></a>
58 <span class="phrase"><a name="math_toolkit.powers.hypot.implementation"></a></span><a class="link" href="hypot.html#math_toolkit.powers.hypot.implementation">Implementation</a>
59 </h5>
60 <p>
61 The function is even and symmetric in x and y, so first take assume <span class="emphasis"><em>x,y
62 &gt; 0</em></span> and <span class="emphasis"><em>x &gt; y</em></span> (we can permute the arguments
63 if this is not the case).
64 </p>
65 <p>
66 Then if <span class="emphasis"><em>x * &#949; &#160; &gt;= y</em></span> we can simply return <span class="emphasis"><em>x</em></span>.
67 </p>
68 <p>
69 Otherwise the result is given by:
70 </p>
71 <p>
72 <span class="inlinemediaobject"><img src="../../../equations/hypot2.svg"></span>
73 </p>
74 </div>
75 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
76 <td align="left"></td>
77 <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014 Nikhar Agrawal,
78 Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
79 Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam Sewani,
80 Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
81 Distributed under the Boost Software License, Version 1.0. (See accompanying
82 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>)
83 </p>
84 </div></td>
85 </tr></table>
86 <hr>
87 <div class="spirit-nav">
88 <a accesskey="p" href="powm1.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../powers.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="ct_pow.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
89 </div>
90 </body>
91 </html>