Release 1.39.0
[boost.git] / Boost_1_39_0 / libs / math / doc / sf_and_dist / html / math_toolkit / policy / pol_tutorial / policy_tut_defaults.html
blobbcd58c84d411df3f5589e65eccd6b655e0fc0a6e
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4 <title>Policies Have Sensible Defaults</title>
5 <link rel="stylesheet" href="../../../../../../../../doc/html/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot_8125">
7 <link rel="home" href="../../../index.html" title="Math Toolkit">
8 <link rel="up" href="../pol_tutorial.html" title="Policy Tutorial">
9 <link rel="prev" href="what_is_a_policy.html" title="So Just What is a Policy Anyway?">
10 <link rel="next" href="policy_usage.html" title="So How are Policies Used Anyway?">
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="what_is_a_policy.html"><img src="../../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../pol_tutorial.html"><img src="../../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="policy_usage.html"><img src="../../../../../../../../doc/html/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section" lang="en">
26 <div class="titlepage"><div><div><h4 class="title">
27 <a name="math_toolkit.policy.pol_tutorial.policy_tut_defaults"></a><a class="link" href="policy_tut_defaults.html" title="Policies Have Sensible Defaults">
28 Policies Have Sensible Defaults</a>
29 </h4></div></div></div>
30 <p>
31 Most of the time you can just ignore the policy framework, the defaults
32 for the various policies are as follows, if these work OK for you then
33 you can stop reading now!
34 </p>
35 <div class="variablelist">
36 <p class="title"><b></b></p>
37 <dl>
38 <dt><span class="term">Domain Error</span></dt>
39 <dd><p>
40 Throws a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">domain_error</span></code> exception.
41 </p></dd>
42 <dt><span class="term">Pole Error</span></dt>
43 <dd><p>
44 Occurs when a function is evaluated at a pole: throws a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">domain_error</span></code> exception.
45 </p></dd>
46 <dt><span class="term">Overflow Error</span></dt>
47 <dd><p>
48 Throws a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">overflow_error</span></code> exception.
49 </p></dd>
50 <dt><span class="term">Underflow</span></dt>
51 <dd><p>
52 Ignores the underflow, and returns zero.
53 </p></dd>
54 <dt><span class="term">Denormalised Result</span></dt>
55 <dd><p>
56 Ignores the fact that the result is denormalised, and returns it.
57 </p></dd>
58 <dt><span class="term">Rounding Error</span></dt>
59 <dd><p>
60 Throws a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">rounding_error</span></code> exception.
61 </p></dd>
62 <dt><span class="term">Internal Evaluation Error</span></dt>
63 <dd><p>
64 Throws a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">evaluation_error</span></code> exception.
65 </p></dd>
66 <dt><span class="term">Indeterminate Result Error</span></dt>
67 <dd><p>
68 Returns a result that depends on the function where the error occurred.
69 </p></dd>
70 <dt><span class="term">Promotion of float to double</span></dt>
71 <dd><p>
72 Does occur by default - gives full float precision results.
73 </p></dd>
74 <dt><span class="term">Promotion of double to long double</span></dt>
75 <dd><p>
76 Does occur by default if long double offers more precision than double.
77 </p></dd>
78 <dt><span class="term">Precision of Approximation Used</span></dt>
79 <dd><p>
80 By default uses an approximation that will result in the lowest level
81 of error for the type of the result.
82 </p></dd>
83 <dt><span class="term">Behaviour of Discrete Quantiles</span></dt>
84 <dd>
85 <p>
86 The quantile function will by default return an integer result that
87 has been <span class="emphasis"><em>rounded outwards</em></span>. That is to say lower
88 quantiles (where the probability is less than 0.5) are rounded downward,
89 and upper quantiles (where the probability is greater than 0.5) are
90 rounded upwards. This behaviour ensures that if an X% quantile is requested,
91 then <span class="emphasis"><em>at least</em></span> the requested coverage will be present
92 in the central region, and <span class="emphasis"><em>no more than</em></span> the requested
93 coverage will be present in the tails.
94 </p>
95 <p>
96 This behaviour can be changed so that the quantile functions are rounded
97 differently, or even return a real-valued result using <a class="link" href="../pol_overview.html" title="Policy Overview">Policies</a>.
98 It is strongly recommended that you read the tutorial <a class="link" href="understand_dis_quant.html" title="Understanding Quantiles of Discrete Distributions">Understanding
99 Quantiles of Discrete Distributions</a> before using the quantile
100 function on a discrete distribution. The <a class="link" href="../pol_ref/discrete_quant_ref.html" title="Discrete Quantile Policies">reference
101 docs</a> describe how to change the rounding policy for these distributions.
102 </p>
103 </dd>
104 </dl>
105 </div>
107 What's more, if you define your own policy type, then it automatically
108 inherits the defaults for any policies not explicitly set, so given:
109 </p>
110 <pre class="programlisting"><span class="keyword">using</span> <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">policies</span><span class="special">;</span>
111 <span class="comment">//
112 </span><span class="comment">// Define a policy that sets ::errno on overflow, and does
113 </span><span class="comment">// not promote double to long double internally:
114 </span><span class="comment">//
115 </span><span class="keyword">typedef</span> <span class="identifier">policy</span><span class="special">&lt;</span><span class="identifier">domain_error</span><span class="special">&lt;</span><span class="identifier">errno_on_error</span><span class="special">&gt;,</span> <span class="identifier">promote_double</span><span class="special">&lt;</span><span class="keyword">false</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">mypolicy</span><span class="special">;</span>
116 </pre>
118 then <code class="computeroutput"><span class="identifier">mypolicy</span></code> defines a
119 policy where only the overflow error handling and <code class="computeroutput"><span class="keyword">double</span></code>-promotion
120 policies differ from the defaults.
121 </p>
122 </div>
123 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
124 <td align="left"></td>
125 <td align="right"><div class="copyright-footer">Copyright © 2006 , 2007, 2008 John Maddock, Paul A. Bristow, Hubert
126 Holin, Xiaogang Zhang, Bruno Lalande and Johan Råde<p>
127 Distributed under the Boost Software License, Version 1.0. (See accompanying
128 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>)
129 </p>
130 </div></td>
131 </tr></table>
132 <hr>
133 <div class="spirit-nav">
134 <a accesskey="p" href="what_is_a_policy.html"><img src="../../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../pol_tutorial.html"><img src="../../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="policy_usage.html"><img src="../../../../../../../../doc/html/images/next.png" alt="Next"></a>
135 </div>
136 </body>
137 </html>