All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
fabs.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_REV_SCAL_FUN_FABS_HPP
#define STAN_MATH_REV_SCAL_FUN_FABS_HPP
#include <stan/math/rev/core.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
namespace stan {
namespace math {
inline var fabs(const var& a) {
using stan::math::NOT_A_NUMBER;
// cut-and-paste from abs()
if (a.val() > 0.0)
return a;
else if (a.val() < 0.0)
return var(new neg_vari(a.vi_));
else if (a.val() == 0)
return var(new vari(0));
else
return var(new precomp_v_vari(NOT_A_NUMBER, a.vi_, NOT_A_NUMBER));
}
}
}
#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::math::vari
The variable implementation base class.
Definition: vari.hpp:28
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:44
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:234

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