| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

fabs.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_SCAL_FUN_FABS_HPP
2 #define STAN_MATH_REV_SCAL_FUN_FABS_HPP
3
4 #include <stan/math/rev/core.hpp>
5 #include <stan/math/prim/scal/fun/constants.hpp>
6
7 namespace stan {
8 namespace math {
9
49 inline var fabs(const var& a) {
50 if (a.val() > 0.0)
51 return a;
52 else if (a.val() < 0.0)
53 return var(new neg_vari(a.vi_));
54 else if (a.val() == 0)
55 return var(new vari(0));
56 else
57 return var(new precomp_v_vari(NOT_A_NUMBER, a.vi_, NOT_A_NUMBER));
58 }
59
60 }
61 }
62 #endif
core.hpp
stan::math::fabs
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
stan::math::NOT_A_NUMBER
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:55
stan
Definition: log_sum_exp.hpp:8
stan::math::vari
The variable implementation base class.
Definition: vari.hpp:30
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:30
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:42
constants.hpp
stan::math::precomp_v_vari
Definition: precomp_v_vari.hpp:11
stan::math::var::val
double val() const
Return the value of this variable.
Definition: var.hpp:229

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