Stan Math Library  2.20.0
reverse mode automatic differentiation
constants.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_CONSTANTS_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_CONSTANTS_HPP
3 
6 #include <boost/math/constants/constants.hpp>
7 #include <limits>
8 
9 namespace stan {
10 namespace math {
11 
12 using std::log;
13 using std::sqrt;
14 
19 const double E = boost::math::constants::e<double>();
20 
25 const double SQRT_2 = sqrt(2.0);
26 
31 const double INV_SQRT_2 = inv(SQRT_2);
32 
37 const double LOG_2 = log(2.0);
38 
43 const double LOG_10 = log(10.0);
44 
48 const double INFTY = std::numeric_limits<double>::infinity();
49 
53 const double NEGATIVE_INFTY = -INFTY;
54 
58 const double NOT_A_NUMBER = std::numeric_limits<double>::quiet_NaN();
59 
63 const double EPSILON = std::numeric_limits<double>::epsilon();
64 
68 const double NEGATIVE_EPSILON = -EPSILON;
69 
73 const double POISSON_MAX_RATE = pow(2.0, 30);
74 
80 inline double pi() { return boost::math::constants::pi<double>(); }
81 
87 inline double e() { return E; }
88 
94 inline double sqrt2() { return SQRT_2; }
95 
101 inline double log10() { return LOG_10; }
102 
108 inline double positive_infinity() { return INFTY; }
109 
115 inline double negative_infinity() { return NEGATIVE_INFTY; }
116 
122 inline double not_a_number() { return NOT_A_NUMBER; }
123 
130 inline double machine_precision() { return EPSILON; }
131 
132 const double SQRT_PI = sqrt(pi());
133 
134 const double SQRT_2_TIMES_SQRT_PI = SQRT_2 * SQRT_PI;
135 
136 const double TWO_OVER_SQRT_PI = 2.0 / SQRT_PI;
137 
139 
140 const double SQRT_TWO_PI = sqrt(2.0 * pi());
141 
142 const double INV_SQRT_TWO_PI = inv(SQRT_TWO_PI);
143 
144 const double LOG_PI = log(pi());
145 
146 const double LOG_PI_OVER_FOUR = LOG_PI / 4.0;
147 
148 const double LOG_SQRT_PI = log(SQRT_PI);
149 
150 const double LOG_ZERO = log(0.0);
151 
152 const double LOG_HALF = log(0.5);
153 
154 const double NEG_LOG_TWO = -LOG_2;
155 
156 const double NEG_LOG_SQRT_TWO_PI = -log(SQRT_TWO_PI);
157 
158 const double NEG_LOG_PI = -LOG_PI;
159 
160 const double NEG_LOG_SQRT_PI = -LOG_SQRT_PI;
161 
162 const double NEG_LOG_TWO_OVER_TWO = -LOG_2 / 2.0;
163 
164 const double LOG_TWO_PI = LOG_2 + LOG_PI;
165 
166 const double NEG_LOG_TWO_PI = -LOG_TWO_PI;
167 
168 const double LOG_EPSILON = log(EPSILON);
169 } // namespace math
170 } // namespace stan
171 
172 #endif
const double LOG_2
The natural logarithm of 2, .
Definition: constants.hpp:37
const double NEG_LOG_PI
Definition: constants.hpp:158
const double LOG_HALF
Definition: constants.hpp:152
const double INV_SQRT_TWO_PI
Definition: constants.hpp:142
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:13
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:58
const double LOG_PI
Definition: constants.hpp:144
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:12
const double NEG_LOG_SQRT_PI
Definition: constants.hpp:160
const double LOG_SQRT_PI
Definition: constants.hpp:148
const double LOG_10
The natural logarithm of 10, .
Definition: constants.hpp:43
fvar< T > log10(const fvar< T > &x)
Definition: log10.hpp:12
const double LOG_EPSILON
Definition: constants.hpp:168
const double LOG_ZERO
Definition: constants.hpp:150
const double LOG_TWO_PI
Definition: constants.hpp:164
const double SQRT_TWO_PI
Definition: constants.hpp:140
double sqrt2()
Return the square root of two.
Definition: constants.hpp:94
const double TWO_OVER_SQRT_PI
Definition: constants.hpp:136
const double SQRT_2_TIMES_SQRT_PI
Definition: constants.hpp:134
const double SQRT_2
The value of the square root of 2, .
Definition: constants.hpp:25
const double INV_SQRT_2
The value of 1 over the square root of 2, .
Definition: constants.hpp:31
const double EPSILON
Smallest positive value.
Definition: constants.hpp:63
const double LOG_PI_OVER_FOUR
Definition: constants.hpp:146
double machine_precision()
Returns the difference between 1.0 and the next value representable.
Definition: constants.hpp:130
const double NEG_TWO_OVER_SQRT_PI
Definition: constants.hpp:138
const double POISSON_MAX_RATE
Largest rate parameter allowed in Poisson RNG.
Definition: constants.hpp:73
const double NEG_LOG_SQRT_TWO_PI
Definition: constants.hpp:156
double positive_infinity()
Return positive infinity.
Definition: constants.hpp:108
double e()
Return the base of the natural logarithm.
Definition: constants.hpp:87
const double E
The base of the natural logarithm, .
Definition: constants.hpp:19
const double NEG_LOG_TWO
Definition: constants.hpp:154
const double NEG_LOG_TWO_PI
Definition: constants.hpp:166
const double NEG_LOG_TWO_OVER_TWO
Definition: constants.hpp:162
const double INFTY
Positive infinity.
Definition: constants.hpp:48
double pi()
Return the value of pi.
Definition: constants.hpp:80
fvar< T > pow(const fvar< T > &x1, const fvar< T > &x2)
Definition: pow.hpp:16
double not_a_number()
Return (quiet) not-a-number.
Definition: constants.hpp:122
const double NEGATIVE_INFTY
Negative infinity.
Definition: constants.hpp:53
const double NEGATIVE_EPSILON
Largest negative value (i.e., smallest absolute value).
Definition: constants.hpp:68
const double SQRT_PI
Definition: constants.hpp:132
double negative_infinity()
Return negative infinity.
Definition: constants.hpp:115
fvar< T > inv(const fvar< T > &x)
Definition: inv.hpp:12

     [ Stan Home Page ] © 2011–2018, Stan Development Team.