Stan Math Library  2.11.0
reverse mode automatic differentiation
fabs.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_SCAL_FUN_FABS_HPP
2 #define STAN_MATH_FWD_SCAL_FUN_FABS_HPP
3 
4 #include <stan/math/fwd/core.hpp>
8 #include <cmath>
9 
10 namespace stan {
11  namespace math {
12 
13  template<typename T>
14  inline fvar<T> fabs(const fvar<T>& x) {
15  using std::fabs;
18 
21  else if (x.val_ > 0.0)
22  return x;
23  else if (x.val_ < 0.0)
24  return fvar<T>(-x.val_, -x.d_);
25  else
26  return fvar<T>(0, 0);
27  }
28 
29  }
30 }
31 #endif
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:14
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:56
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Definition: value_of.hpp:16
bool isnan(const stan::math::var &v)
Checks if the given number is NaN.
Definition: boost_isnan.hpp:22
#define unlikely(x)
Definition: likely.hpp:9
var fabs(const var &a)
Return the absolute value of the variable (cmath).
Definition: fabs.hpp:50

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