All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
abs.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_FWD_SCAL_FUN_ABS_HPP
#define STAN_MATH_FWD_SCAL_FUN_ABS_HPP
#include <stan/math/fwd/scal/fun/value_of.hpp>
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/abs.hpp>
#include <stan/math/prim/scal/fun/value_of.hpp>
#include <stan/math/prim/scal/meta/likely.hpp>
namespace stan {
namespace math {
template<typename T>
inline fvar<T> abs(const fvar<T>& x) {
using stan::math::abs;
using stan::math::value_of;
if (x.val_ > 0.0)
return x;
else if (x.val_ < 0.0)
return fvar<T>(-x.val_, -x.d_);
else if (x.val_ == 0.0)
return fvar<T>(0, 0);
else
return fvar<T>(abs(x.val_), stan::math::NOT_A_NUMBER);
}
}
}
#endif
stan::math::abs
fvar< T > abs(const fvar< T > &x)
Definition: abs.hpp:15
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:15
stan::math::NOT_A_NUMBER
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:56
stan::math::value_of
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Definition: value_of.hpp:16
value_of.hpp
abs.hpp
stan::math::fvar::val_
T val_
Definition: fvar.hpp:14
likely.hpp
constants.hpp
value_of.hpp
stan::math::fvar
Definition: fvar.hpp:13

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