Stan Math Library  2.20.0
reverse mode automatic differentiation
finite_diff_stepsize.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_FINITE_DIFF_STEPSIZE_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_FINITE_DIFF_STEPSIZE_HPP
3 
4 #include <cmath>
5 #include <limits>
6 
7 namespace stan {
8 namespace math {
9 
20 inline double finite_diff_stepsize(double u) {
21  static const double cbrt_epsilon
22  = std::cbrt(std::numeric_limits<double>::epsilon());
23  return cbrt_epsilon * std::fmax(1, fabs(u));
24 }
25 } // namespace math
26 } // namespace stan
27 #endif
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
fvar< T > cbrt(const fvar< T > &x)
Return cube root of specified argument.
Definition: cbrt.hpp:19
double finite_diff_stepsize(double u)
Return the stepsize for finite difference evaluations at the specified scalar.
fvar< T > fmax(const fvar< T > &x1, const fvar< T > &x2)
Return the greater of the two specified arguments.
Definition: fmax.hpp:22

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