Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fabs.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__REV__FUNCTIONS__FABS_HPP
2 #define STAN__AGRAD__REV__FUNCTIONS__FABS_HPP
3 
4 #include <stan/agrad/rev/var.hpp>
9 
10 
11 namespace stan {
12  namespace agrad {
13 
53  inline var fabs(const var& a) {
55  // cut-and-paste from abs()
56  if (a.val() > 0.0)
57  return a;
58  else if (a.val() < 0.0)
59  return var(new neg_vari(a.vi_));
60  else if (a.val() == 0)
61  return var(new vari(0));
62  else
64  }
65 
66  }
67 }
68 #endif
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:18
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:53
double val() const
Return the value of this variable.
Definition: var.hpp:209
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:40
The variable implementation base class.
Definition: vari.hpp:28
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27

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