Stan Math Library  2.20.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/meta.hpp>
5 #include <stan/math/rev/core.hpp>
7 
8 namespace stan {
9 namespace math {
10 
50 inline var fabs(const var& a) {
51  if (a.val() > 0.0)
52  return a;
53  else if (a.val() < 0.0)
54  return var(new internal::neg_vari(a.vi_));
55  else if (a.val() == 0)
56  return var(new vari(0));
57  else
59 }
60 
61 } // namespace math
62 } // namespace stan
63 #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:58
The variable implementation base class.
Definition: vari.hpp:30
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:33
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:45
double val() const
Return the value of this variable.
Definition: var.hpp:294

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