Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
fabs.hpp
Go to the documentation of this file.
1 #ifndef __STAN__AGRAD__REV__FABS_HPP__
2 #define __STAN__AGRAD__REV__FABS_HPP__
3 
4 #include <stan/agrad/rev/var.hpp>
7 
8 namespace stan {
9  namespace agrad {
10 
27  inline var fabs(const var& a) {
28  // cut-and-paste from abs()
29  if (a.val() > 0.0)
30  return a;
31  if (a.val() < 0.0)
32  return var(new neg_vari(a.vi_));
33  // FIXME: is this right? breaks connection to a
34  return var(new vari(0.0));
35  }
36 
37  }
38 }
39 #endif

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