Stan Math Library: stan/math/rev/scal/fun/fabs.hpp Source File

| Stan Math Library 2.10.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
8 namespace stan {
9 namespace math {
10
50 inline var fabs(const var& a) {
51 using stan::math::NOT_A_NUMBER;
52 // cut-and-paste from abs()
53 if (a.val() > 0.0)
54 return a;
55 else if (a.val() < 0.0)
56 return var(new neg_vari(a.vi_));
57 else if (a.val() == 0)
58 return var(new vari(0));
59 else
60 return var(new precomp_v_vari(NOT_A_NUMBER, a.vi_, NOT_A_NUMBER));
61 }
62
63 }
64 }
65 #endif
core.hpp
stan::math::fabs
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:14
stan::math::NOT_A_NUMBER
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:56
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:31
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:43
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:233

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