Stan Math Library  2.15.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 
4 #include <boost/math/constants/constants.hpp>
5 #include <limits>
6 
7 namespace stan {
8  namespace math {
9 
14  const double E = boost::math::constants::e<double>();
15 
20  const double SQRT_2 = std::sqrt(2.0);
21 
26  const double INV_SQRT_2 = 1.0 / SQRT_2;
27 
32  const double LOG_2 = std::log(2.0);
33 
38  const double LOG_10 = std::log(10.0);
39 
43  const double INFTY = std::numeric_limits<double>::infinity();
44 
48  const double NEGATIVE_INFTY
49  = - std::numeric_limits<double>::infinity();
50 
54  const double NOT_A_NUMBER
55  = std::numeric_limits<double>::quiet_NaN();
56 
60  const double EPSILON = std::numeric_limits<double>::epsilon();
61 
65  const double NEGATIVE_EPSILON
66  = - std::numeric_limits<double>::epsilon();
67 
71  const double POISSON_MAX_RATE = std::pow(2.0, 30);
72 
77  const double LOG_PI_OVER_FOUR
78  = std::log(boost::math::constants::pi<double>()) / 4.0;
79 
85  inline double pi() {
86  return boost::math::constants::pi<double>();
87  }
88 
94  inline double e() {
95  return E;
96  }
97 
103  inline double sqrt2() {
104  return SQRT_2;
105  }
106 
112  inline double log10() {
113  return LOG_10;
114  }
115 
121  inline double positive_infinity() {
122  return INFTY;
123  }
124 
130  inline double negative_infinity() {
131  return NEGATIVE_INFTY;
132  }
133 
139  inline double not_a_number() {
140  return NOT_A_NUMBER;
141  }
142 
149  inline double machine_precision() {
150  return EPSILON;
151  }
152 
153  const double SQRT_PI
154  = std::sqrt(boost::math::constants::pi<double>());
155 
156  const double SQRT_2_TIMES_SQRT_PI = SQRT_2 * SQRT_PI;
157 
158  const double TWO_OVER_SQRT_PI
159  = 2.0 / SQRT_PI;
160 
162 
163  const double INV_SQRT_TWO_PI
164  = 1.0 / std::sqrt(2.0 * boost::math::constants::pi<double>());
165 
166  const double LOG_PI
167  = std::log(boost::math::constants::pi<double>());
168 
169  const double LOG_SQRT_PI
170  = std::log(SQRT_PI);
171 
172  const double LOG_ZERO = std::log(0.0);
173 
174  const double LOG_TWO = std::log(2.0);
175 
176  const double LOG_HALF = std::log(0.5);
177 
178  const double NEG_LOG_TWO = - LOG_TWO;
179 
180  const double NEG_LOG_SQRT_TWO_PI
181  = - std::log(std::sqrt(2.0 * boost::math::constants::pi<double>()));
182 
183  const double NEG_LOG_PI = - LOG_PI;
184 
185  const double NEG_LOG_SQRT_PI
186  = -std::log(std::sqrt(boost::math::constants::pi<double>()));
187 
188  const double NEG_LOG_TWO_OVER_TWO = - LOG_TWO / 2.0;
189 
190  const double LOG_TWO_PI = LOG_TWO + LOG_PI;
191 
192  const double NEG_LOG_TWO_PI = - LOG_TWO_PI;
193 
194  }
195 }
196 
197 #endif
const double LOG_2
The natural logarithm of 2, .
Definition: constants.hpp:32
const double NEG_LOG_PI
Definition: constants.hpp:183
const double LOG_HALF
Definition: constants.hpp:176
const double INV_SQRT_TWO_PI
Definition: constants.hpp:164
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:14
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:55
const double LOG_PI
Definition: constants.hpp:167
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:14
const double NEG_LOG_SQRT_PI
Definition: constants.hpp:186
const double LOG_SQRT_PI
Definition: constants.hpp:170
const double LOG_10
The natural logarithm of 10, .
Definition: constants.hpp:38
fvar< T > log10(const fvar< T > &x)
Definition: log10.hpp:13
const double LOG_ZERO
Definition: constants.hpp:172
const double LOG_TWO
Definition: constants.hpp:174
const double LOG_TWO_PI
Definition: constants.hpp:190
double sqrt2()
Return the square root of two.
Definition: constants.hpp:103
const double TWO_OVER_SQRT_PI
Definition: constants.hpp:159
const double SQRT_2_TIMES_SQRT_PI
Definition: constants.hpp:156
const double SQRT_2
The value of the square root of 2, .
Definition: constants.hpp:20
const double INV_SQRT_2
The value of 1 over the square root of 2, .
Definition: constants.hpp:26
const double EPSILON
Smallest positive value.
Definition: constants.hpp:60
const double LOG_PI_OVER_FOUR
Log pi divided by 4 .
Definition: constants.hpp:78
double machine_precision()
Returns the difference between 1.0 and the next value representable.
Definition: constants.hpp:149
const double NEG_TWO_OVER_SQRT_PI
Definition: constants.hpp:161
const double POISSON_MAX_RATE
Largest rate parameter allowed in Poisson RNG.
Definition: constants.hpp:71
const double NEG_LOG_SQRT_TWO_PI
Definition: constants.hpp:181
double positive_infinity()
Return positive infinity.
Definition: constants.hpp:121
double e()
Return the base of the natural logarithm.
Definition: constants.hpp:94
const double E
The base of the natural logarithm, .
Definition: constants.hpp:14
const double NEG_LOG_TWO
Definition: constants.hpp:178
const double NEG_LOG_TWO_PI
Definition: constants.hpp:192
const double NEG_LOG_TWO_OVER_TWO
Definition: constants.hpp:188
const double INFTY
Positive infinity.
Definition: constants.hpp:43
double pi()
Return the value of pi.
Definition: constants.hpp:85
fvar< T > pow(const fvar< T > &x1, const fvar< T > &x2)
Definition: pow.hpp:17
double not_a_number()
Return (quiet) not-a-number.
Definition: constants.hpp:139
const double NEGATIVE_INFTY
Negative infinity.
Definition: constants.hpp:49
const double NEGATIVE_EPSILON
Largest negative value (i.e., smallest absolute value).
Definition: constants.hpp:66
const double SQRT_PI
Definition: constants.hpp:154
double negative_infinity()
Return negative infinity.
Definition: constants.hpp:130

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