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__FWD__FUNCTIONS__FABS_HPP
2 #define STAN__AGRAD__FWD__FUNCTIONS__FABS_HPP
3 
5 #include <stan/meta/traits.hpp>
8 #include <math.h>
9 #include <stan/meta/likely.hpp>
10 
11 namespace stan {
12 
13  namespace agrad {
14 
15  template<typename T>
16  inline
17  fvar<T>
18  fabs(const fvar<T>& x) {
22 
25  else if (x.val_ > 0.0)
26  return x;
27  else if (x.val_ < 0.0)
28  return fvar<T>(-x.val_, -x.d_);
29  else
30  return fvar<T>(0, 0);
31  }
32  }
33 }
34 #endif
bool isnan(const stan::agrad::var &v)
Checks if the given number is NaN.
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
var fabs(const var &a)
Return the absolute value of the variable (cmath).
Definition: fabs.hpp:53
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Definition: value_of.hpp:16
double value_of(const T x)
Return the value of the specified scalar argument converted to a double value.
Definition: value_of.hpp:24
#define unlikely(x)
Definition: likely.hpp:9

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