Automatic Differentiation
 
Loading...
Searching...
No Matches
constants.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_CONSTANTS_HPP
2#define STAN_MATH_PRIM_FUN_CONSTANTS_HPP
3
6#include <boost/math/constants/constants.hpp>
7#include <cmath>
8#include <limits>
9
10namespace stan {
11namespace math {
12
13// TODO(anyone) Use constexpr when moving to C++17
14
20static constexpr double e() { return boost::math::constants::e<double>(); }
21
27static constexpr double egamma() {
28 return boost::math::constants::euler<double>();
29}
30
36static constexpr double pi() { return boost::math::constants::pi<double>(); }
37
41static constexpr double EPSILON = std::numeric_limits<double>::epsilon();
42
46static constexpr double INFTY = std::numeric_limits<double>::infinity();
47
51static constexpr double NEGATIVE_INFTY = -INFTY;
52
56static constexpr double NOT_A_NUMBER = std::numeric_limits<double>::quiet_NaN();
57
62static constexpr double TWO_PI = boost::math::constants::two_pi<double>();
63
68static constexpr double LOG_ZERO = -INFTY;
69
74const double LOG_EPSILON = std::log(EPSILON);
75
80static constexpr double LOG_TWO = boost::math::constants::ln_two<double>();
81
86static constexpr double LOG_PI = 1.14472988584940017414342735135;
87
92static constexpr double LOG_HALF = -LOG_TWO;
93
98static constexpr double LOG_TWO_PI = LOG_TWO + LOG_PI;
99
104static constexpr double LOG_PI_OVER_FOUR = 0.25 * LOG_PI;
105
110static constexpr double LOG_SQRT_PI = LOG_PI / 2;
111
116static constexpr double LOG_TEN = boost::math::constants::ln_ten<double>();
117
122static constexpr double SQRT_TWO = boost::math::constants::root_two<double>();
123
128static constexpr double SQRT_PI = boost::math::constants::root_pi<double>();
129
134static constexpr double SQRT_TWO_PI
135 = boost::math::constants::root_two_pi<double>();
136
141static constexpr double SQRT_TWO_OVER_SQRT_PI = SQRT_TWO / SQRT_PI;
142
147static constexpr double INV_SQRT_TWO
148 = boost::math::constants::one_div_root_two<double>();
149
154static constexpr double INV_SQRT_PI
155 = boost::math::constants::one_div_root_pi<double>();
156
161static constexpr double INV_SQRT_TWO_PI
162 = boost::math::constants::one_div_root_two_pi<double>();
163
168static constexpr double TWO_OVER_SQRT_PI
169 = boost::math::constants::two_div_root_pi<double>();
170
175static constexpr double HALF_LOG_TWO = 0.5 * LOG_TWO;
176
181static constexpr double HALF_LOG_TWO_PI = 0.5 * LOG_TWO_PI;
182
187const double NEG_LOG_SQRT_TWO_PI = -std::log(SQRT_TWO_PI);
188
192const double POISSON_MAX_RATE = std::pow(2.0, 30);
193
199static constexpr inline double positive_infinity() { return INFTY; }
200
206static constexpr inline double negative_infinity() { return NEGATIVE_INFTY; }
207
213static constexpr inline double not_a_number() { return NOT_A_NUMBER; }
214
221static constexpr inline double machine_precision() { return EPSILON; }
222
228static constexpr inline double log10() { return LOG_TEN; }
229
235static constexpr inline double sqrt2() { return SQRT_TWO; }
236
237} // namespace math
238} // namespace stan
239
240#endif
static constexpr double LOG_ZERO
The natural logarithm of 0, .
Definition constants.hpp:68
static constexpr double HALF_LOG_TWO
The value of half the natural logarithm 2, .
static constexpr double negative_infinity()
Return negative infinity.
static constexpr double LOG_HALF
The natural logarithm of 0.5, .
Definition constants.hpp:92
static constexpr double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition constants.hpp:56
static constexpr double positive_infinity()
Return positive infinity.
static constexpr double SQRT_TWO_OVER_SQRT_PI
The square root of 2 divided by the square root of , .
static constexpr double EPSILON
Smallest positive value.
Definition constants.hpp:41
static constexpr double e()
Return the base of the natural logarithm.
Definition constants.hpp:20
static constexpr double LOG_TWO_PI
The natural logarithm of 2 plus the natural logarithm of , .
Definition constants.hpp:98
static constexpr double LOG_PI_OVER_FOUR
The value of one quarter the natural logarithm of , .
static constexpr double not_a_number()
Return (quiet) not-a-number.
const double POISSON_MAX_RATE
Largest rate parameter allowed in Poisson RNG.
static constexpr double LOG_TEN
The natural logarithm of 10, .
const double NEG_LOG_SQRT_TWO_PI
The value of minus the natural logarithm of the square root of , .
static constexpr double INV_SQRT_TWO
The value of 1 over the square root of 2, .
static constexpr double sqrt2()
Returns the square root of two.
static constexpr double INV_SQRT_TWO_PI
The value of 1 over the square root of , .
static constexpr double machine_precision()
Returns the difference between 1.0 and the next value representable.
static constexpr double NEGATIVE_INFTY
Negative infinity.
Definition constants.hpp:51
static constexpr double SQRT_TWO
The value of the square root of 2, .
static constexpr double SQRT_PI
The value of the square root of , .
static constexpr double LOG_TWO
The natural logarithm of 2, .
Definition constants.hpp:80
static constexpr double LOG_SQRT_PI
The natural logarithm of the square root of , .
static constexpr double LOG_PI
The natural logarithm of , .
Definition constants.hpp:86
static constexpr double SQRT_TWO_PI
The value of the square root of , .
static constexpr double log10()
Returns the natural logarithm of ten.
static constexpr double INV_SQRT_PI
The value of 1 over the square root of , .
static constexpr double TWO_PI
Twice the value of , .
Definition constants.hpp:62
static constexpr double TWO_OVER_SQRT_PI
The value of 2 over the square root of , .
static constexpr double pi()
Return the value of pi.
Definition constants.hpp:36
static constexpr double egamma()
Return the Euler's gamma constant.
Definition constants.hpp:27
static constexpr double HALF_LOG_TWO_PI
The value of half the natural logarithm , .
const double LOG_EPSILON
The natural logarithm of machine precision , .
Definition constants.hpp:74
static constexpr double INFTY
Positive infinity.
Definition constants.hpp:46
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...