Stan Math Library  2.14.0
reverse mode automatic differentiation
cbrt.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_CBRT_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_CBRT_HPP
3 
8 #include <boost/math/special_functions/cbrt.hpp>
9 
10 namespace stan {
11  namespace math {
12 
20  inline double cbrt(double x) {
21  if (is_nan(x))
22  return NOT_A_NUMBER;
23  if (is_inf(x))
24  return x < 0 ? NEGATIVE_INFTY : INFTY;
25  return boost::math::cbrt(x, boost_policy_t());
26  }
27 
35  inline double cbrt(int x) {
36  return cbrt(static_cast<double>(x));
37  }
38 
39  }
40 }
41 #endif
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:55
fvar< T > cbrt(const fvar< T > &x)
Return cube root of specified argument.
Definition: cbrt.hpp:18
int is_inf(const fvar< T > &x)
Returns 1 if the input&#39;s value is infinite and 0 otherwise.
Definition: is_inf.hpp:21
const double INFTY
Positive infinity.
Definition: constants.hpp:43
boost::math::policies::policy< boost::math::policies::overflow_error< boost::math::policies::errno_on_error >, boost::math::policies::pole_error< boost::math::policies::errno_on_error > > boost_policy_t
Boost policy that overrides the defaults to match the built-in C++ standard library functions...
int is_nan(const fvar< T > &x)
Returns 1 if the input&#39;s value is NaN and 0 otherwise.
Definition: is_nan.hpp:21
const double NEGATIVE_INFTY
Negative infinity.
Definition: constants.hpp:49
var cbrt(const var &a)
Returns the cube root of the specified variable (C99).
Definition: cbrt.hpp:49

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