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

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