Stan Math Library  2.9.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 
9  namespace math {
10 
15  const double E = boost::math::constants::e<double>();
16 
21  const double SQRT_2 = std::sqrt(2.0);
22 
27  const double INV_SQRT_2 = 1.0 / SQRT_2;
28 
33  const double LOG_2 = std::log(2.0);
34 
39  const double LOG_10 = std::log(10.0);
40 
44  const double INFTY = std::numeric_limits<double>::infinity();
45 
49  const double NEGATIVE_INFTY
50  = - std::numeric_limits<double>::infinity();
51 
55  const double NOT_A_NUMBER
56  = std::numeric_limits<double>::quiet_NaN();
57 
61  const double EPSILON = std::numeric_limits<double>::epsilon();
62 
66  const double NEGATIVE_EPSILON
67  = - std::numeric_limits<double>::epsilon();
68 
72  const double POISSON_MAX_RATE = std::pow(2.0, 30);
73 
78  const double LOG_PI_OVER_FOUR
79  = std::log(boost::math::constants::pi<double>()) / 4.0;
80 
86  inline double pi() {
87  return boost::math::constants::pi<double>();
88  }
89 
95  inline double e() {
96  return E;
97  }
98 
104  inline double sqrt2() {
105  return SQRT_2;
106  }
107 
108 
114  inline double log10() {
115  return LOG_10;
116  }
117 
123  inline double positive_infinity() {
124  return INFTY;
125  }
126 
132  inline double negative_infinity() {
133  return NEGATIVE_INFTY;
134  }
135 
141  inline double not_a_number() {
142  return NOT_A_NUMBER;
143  }
144 
151  inline double machine_precision() {
152  return EPSILON;
153  }
154 
155  const double SQRT_PI
156  = std::sqrt(boost::math::constants::pi<double>());
157 
158  const double SQRT_2_TIMES_SQRT_PI = SQRT_2 * SQRT_PI;
159 
160  const double TWO_OVER_SQRT_PI
161  = 2.0 / SQRT_PI;
162 
164 
165  const double INV_SQRT_TWO_PI
166  = 1.0 / std::sqrt(2.0 * boost::math::constants::pi<double>());
167 
168 
169  const double LOG_PI
170  = std::log(boost::math::constants::pi<double>());
171 
172  const double LOG_SQRT_PI
173  = std::log(SQRT_PI);
174 
175  const double LOG_ZERO = std::log(0.0);
176 
177  const double LOG_TWO = std::log(2.0);
178 
179  const double LOG_HALF = std::log(0.5);
180 
181  const double NEG_LOG_TWO = - LOG_TWO;
182 
183  const double NEG_LOG_SQRT_TWO_PI
184  = - std::log(std::sqrt(2.0 * boost::math::constants::pi<double>()));
185 
186  const double NEG_LOG_PI = - LOG_PI;
187 
188  const double NEG_LOG_SQRT_PI
189  = -std::log(std::sqrt(boost::math::constants::pi<double>()));
190 
191  const double NEG_LOG_TWO_OVER_TWO = - LOG_TWO / 2.0;
192 
193  const double LOG_TWO_PI = LOG_TWO + LOG_PI;
194 
195  const double NEG_LOG_TWO_PI = - LOG_TWO_PI;
196 
197  }
198 }
199 
200 #endif
const double LOG_2
The natural logarithm of 2, .
Definition: constants.hpp:33
const double NEG_LOG_PI
Definition: constants.hpp:186
const double LOG_HALF
Definition: constants.hpp:179
const double INV_SQRT_TWO_PI
Definition: constants.hpp:166
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:15
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:56
const double LOG_PI
Definition: constants.hpp:170
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
const double NEG_LOG_SQRT_PI
Definition: constants.hpp:189
const double LOG_SQRT_PI
Definition: constants.hpp:173
const double LOG_10
The natural logarithm of 10, .
Definition: constants.hpp:39
fvar< T > log10(const fvar< T > &x)
Definition: log10.hpp:15
const double LOG_ZERO
Definition: constants.hpp:175
const double LOG_TWO
Definition: constants.hpp:177
const double LOG_TWO_PI
Definition: constants.hpp:193
double sqrt2()
Return the square root of two.
Definition: constants.hpp:104
const double TWO_OVER_SQRT_PI
Definition: constants.hpp:161
const double SQRT_2_TIMES_SQRT_PI
Definition: constants.hpp:158
const double SQRT_2
The value of the square root of 2, .
Definition: constants.hpp:21
const double INV_SQRT_2
The value of 1 over the square root of 2, .
Definition: constants.hpp:27
const double EPSILON
Smallest positive value.
Definition: constants.hpp:61
const double LOG_PI_OVER_FOUR
Log pi divided by 4 .
Definition: constants.hpp:79
double machine_precision()
Returns the difference between 1.0 and the next value representable.
Definition: constants.hpp:151
const double NEG_TWO_OVER_SQRT_PI
Definition: constants.hpp:163
const double POISSON_MAX_RATE
Largest rate parameter allowed in Poisson RNG.
Definition: constants.hpp:72
const double NEG_LOG_SQRT_TWO_PI
Definition: constants.hpp:184
double positive_infinity()
Return positive infinity.
Definition: constants.hpp:123
double e()
Return the base of the natural logarithm.
Definition: constants.hpp:95
const double E
The base of the natural logarithm, .
Definition: constants.hpp:15
const double NEG_LOG_TWO
Definition: constants.hpp:181
const double NEG_LOG_TWO_PI
Definition: constants.hpp:195
const double NEG_LOG_TWO_OVER_TWO
Definition: constants.hpp:191
const double INFTY
Positive infinity.
Definition: constants.hpp:44
double pi()
Return the value of pi.
Definition: constants.hpp:86
fvar< T > pow(const fvar< T > &x1, const fvar< T > &x2)
Definition: pow.hpp:18
double not_a_number()
Return (quiet) not-a-number.
Definition: constants.hpp:141
const double NEGATIVE_INFTY
Negative infinity.
Definition: constants.hpp:50
const double NEGATIVE_EPSILON
Largest negative value (i.e., smallest absolute value).
Definition: constants.hpp:67
const double SQRT_PI
Definition: constants.hpp:156
double negative_infinity()
Return negative infinity.
Definition: constants.hpp:132

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