1 #ifndef STAN_MATH_FWD_SCAL_FUN_LOG_HPP 2 #define STAN_MATH_FWD_SCAL_FUN_LOG_HPP 3 4 #include <stan/math/fwd/core.hpp> 5 6 #include <stan/math/prim/scal/fun/constants.hpp> 7 8 namespace stan { 9 namespace math { 10 11 template <typename T> log(const fvar<T> & x)12inline fvar<T> log(const fvar<T>& x) { 13 using std::log; 14 if (x.val_ < 0.0) 15 return fvar<T>(NOT_A_NUMBER, NOT_A_NUMBER); 16 else 17 return fvar<T>(log(x.val_), x.d_ / x.val_); 18 } 19 } // namespace math 20 } // namespace stan 21 #endif 22