Stan Math Library  2.15.0
reverse mode automatic differentiation
fabs.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_SCAL_FUN_FABS_HPP
2 #define STAN_MATH_REV_SCAL_FUN_FABS_HPP
3 
4 #include <stan/math/rev/core.hpp>
6 
7 namespace stan {
8  namespace math {
9 
49  inline var fabs(const var& a) {
50  if (a.val() > 0.0)
51  return a;
52  else if (a.val() < 0.0)
53  return var(new neg_vari(a.vi_));
54  else if (a.val() == 0)
55  return var(new vari(0));
56  else
58  }
59 
60  }
61 }
62 #endif
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:55
The variable implementation base class.
Definition: vari.hpp:30
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:30
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:42
double val() const
Return the value of this variable.
Definition: var.hpp:230

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