File: constants.qbk

package info (click to toggle)
boost1.49 1.49.0-3.2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 427,096 kB
  • sloc: cpp: 1,806,930; xml: 101,307; ansic: 43,491; python: 28,668; sh: 11,922; cs: 2,118; perl: 714; makefile: 671; yacc: 456; asm: 353; php: 116; lisp: 60; sql: 13; csh: 6
file content (75 lines) | stat: -rw-r--r-- 2,349 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
[section:constants Numeric Constants]

[h4 Synopsis]

``
#include <boost/math/constants/constants.hpp>
``

   namespace boost{ namespace math{ namespace constants{
   
   template <class T> T pi();
   template <class T> T root_pi();
   template <class T> T root_half_pi();
   template <class T> T root_two_pi();
   template <class T> T root_ln_four();
   template <class T> T e();
   template <class T> T half();
   template <class T> T euler();
   template <class T> T root_two();
   template <class T> T ln_two();
   template <class T> T ln_ln_two();
   template <class T> T third();
   template <class T> T twothirds();
   template <class T> T pi_minus_three();
   template <class T> T four_minus_pi();
   
   }}} // namespaces

[h4 Description]

The header `boost/math/constants/constants.hpp` contains some numeric constants
that we have found useful in the development of this library.  New constants are 
added on an ad-hoc basis based on need.

Usage is like this:
	
   template <class T>
   T circumference(T r)
   {
      return 2 * boost::math::constants::pi<T>() * r;
   }

All the constants are accurate to at least the 34 decimal digits required for 128-bit
long doubles, and most are accurate to 100 digits or more when used with 
a suitable arbitrary precision type.

The following table summarises the constants we have at present:

[table
[[Constant][Meaning][Value]]
[[pi][[pi]][3.1415926535897932384...]]
[[root_pi][[radic][pi]][1.772453850905516027...]]
[[root_half_pi][[radic]([pi]/2)][1.253314137315500251...]]
[[root_two_pi][[radic](2*[pi])][2.506628274631000502...]]
[[root_ln_four][[radic](ln(4))][1.17741002251547469...]]
[[e][['e]][2.71828182845904523536...]]
[[half][0.5][0.5]]
[[euler][Euler's constant][0.577215664901532860606]]
[[root_two][[radic]2][1.4142135623730950488...]]
[[ln_two][ln(2)][0.6931471805599453094...]]
[[ln_ln_two][ln(ln(2))][-0.3665129205816643...]]
[[third][1/3][0.333333333333333333...]]
[[twothirds][2/3][0.666666666666666666...]]
[[pi_minus_three][[pi]-3][0.14159265358979323846...]]
[[four_minus_pi][4-[pi]][0.85840734641020676153735...]]
]

[endsect][/section Numeric Constants]

[/ 
  Copyright 2008 John Maddock and Paul A. Bristow.
  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE_1_0.txt or copy at
  http://www.boost.org/LICENSE_1_0.txt).
]