namespaces.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Namespaces</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.11.0">
  8. <link rel="up" href="../overview.html" title="Chapter&#160;1.&#160;Overview">
  9. <link rel="prev" href="directories.html" title="Directory and File Structure">
  10. <link rel="next" href="result_type.html" title="Calculation of the Type of the Result">
  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="directories.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="result_type.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.namespaces"></a><a class="link" href="namespaces.html" title="Namespaces">Namespaces</a>
  28. </h2></div></div></div>
  29. <p>
  30. All math functions and distributions are in <code class="computeroutput"><span class="keyword">namespace</span>
  31. <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span></code>.
  32. </p>
  33. <p>
  34. So, for example, the Students-t distribution template in <code class="computeroutput"><span class="keyword">namespace</span>
  35. <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span></code> is
  36. </p>
  37. <pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">&gt;</span> <span class="keyword">class</span> <span class="identifier">students_t_distribution</span>
  38. </pre>
  39. <p>
  40. and can be instantiated with the help of the reserved name <code class="computeroutput"><span class="identifier">students_t</span></code>(for
  41. <code class="computeroutput"><span class="identifier">RealType</span> <span class="keyword">double</span></code>)
  42. </p>
  43. <pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">students_t_distribution</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">students_t</span><span class="special">;</span>
  44. <span class="identifier">student_t</span> <span class="identifier">mydist</span><span class="special">(</span><span class="number">10</span><span class="special">);</span>
  45. </pre>
  46. <div class="warning"><table border="0" summary="Warning">
  47. <tr>
  48. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
  49. <th align="left">Warning</th>
  50. </tr>
  51. <tr><td align="left" valign="top"><p>
  52. Some distribution names are also used in std random library, so to avoid
  53. the risk of ambiguity it is better to make explicit using declarations, for
  54. example: <code class="computeroutput"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">students_t_distribution</span></code>
  55. </p></td></tr>
  56. </table></div>
  57. <p>
  58. Functions not intended for use by applications are in <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">detail</span></code>.
  59. </p>
  60. <p>
  61. Functions that may have more general use, like <code class="computeroutput"><span class="identifier">digits</span></code>
  62. (significand), <code class="computeroutput"><span class="identifier">max_value</span></code>,
  63. <code class="computeroutput"><span class="identifier">min_value</span></code> and <code class="computeroutput"><span class="identifier">epsilon</span></code> are in <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span></code>.
  64. </p>
  65. <p>
  66. <a class="link" href="../policy.html" title="Chapter&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> and configuration information is in <code class="computeroutput"><span class="keyword">namespace</span></code> <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span></code>.
  67. </p>
  68. <div class="tip"><table border="0" summary="Tip">
  69. <tr>
  70. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../doc/src/images/tip.png"></td>
  71. <th align="left">Tip</th>
  72. </tr>
  73. <tr><td align="left" valign="top"><p>
  74. Many code snippets assume implicit namespace(s), for example, <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span></code> or
  75. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span></code>.
  76. </p></td></tr>
  77. </table></div>
  78. <div class="tip"><table border="0" summary="Tip">
  79. <tr>
  80. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../doc/src/images/tip.png"></td>
  81. <th align="left">Tip</th>
  82. </tr>
  83. <tr><td align="left" valign="top"><p>
  84. Start your work from a copy of the example source code; links usually provided.
  85. </p></td></tr>
  86. </table></div>
  87. </div>
  88. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  89. <td align="left"></td>
  90. <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
  91. Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
  92. Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
  93. R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
  94. Daryle Walker and Xiaogang Zhang<p>
  95. Distributed under the Boost Software License, Version 1.0. (See accompanying
  96. 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>)
  97. </p>
  98. </div></td>
  99. </tr></table>
  100. <hr>
  101. <div class="spirit-nav">
  102. <a accesskey="p" href="directories.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="result_type.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
  103. </div>
  104. </body>
  105. </html>