Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
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 
8 namespace stan {
9  namespace math {
10 
50  inline var fabs(const var& a) {
52  // cut-and-paste from abs()
53  if (a.val() > 0.0)
54  return a;
55  else if (a.val() < 0.0)
56  return var(new neg_vari(a.vi_));
57  else if (a.val() == 0)
58  return var(new vari(0));
59  else
61  }
62 
63  }
64 }
65 #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
The variable implementation base class.
Definition: vari.hpp:28
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:44
double val() const
Return the value of this variable.
Definition: var.hpp:234

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