Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
abs.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__FWD__FUNCTIONS__ABS_HPP
2 #define STAN__AGRAD__FWD__FUNCTIONS__ABS_HPP
3 
6 #include <stan/meta/traits.hpp>
10 #include <stan/meta/likely.hpp>
11 
12 namespace stan {
13 
14  namespace agrad {
15 
16  template<typename T>
17  inline
18  fvar<T>
19  abs(const fvar<T>& x) {
20  using stan::math::abs;
22  if (x.val_ > 0.0)
23  return x;
24  else if (x.val_ < 0.0)
25  return fvar<T>(-x.val_, -x.d_);
26  else if (x.val_ == 0.0)
27  return fvar<T>(0, 0);
28  else // if (unlikely(boost::math::isnan(value_of(x.val_))))
30  }
31  }
32 }
33 #endif
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:53
double value_of(const T x)
Return the value of the specified scalar argument converted to a double value.
Definition: value_of.hpp:24
fvar< T > abs(const fvar< T > &x)
Definition: abs.hpp:19
double abs(double x)
Return floating-point absolute value.
Definition: abs.hpp:19

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