All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
operator_unary_negative.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_REV_CORE_OPERATOR_UNARY_NEGATIVE_HPP
#define STAN_MATH_REV_CORE_OPERATOR_UNARY_NEGATIVE_HPP
#include <stan/math/rev/core/var.hpp>
#include <stan/math/rev/core/v_vari.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <limits>
namespace stan {
namespace math {
namespace {
class neg_vari : public op_v_vari {
public:
explicit neg_vari(vari* avi) :
op_v_vari(-(avi->val_), avi) {
}
void chain() {
if (unlikely(boost::math::isnan(avi_->val_)))
avi_->adj_ = std::numeric_limits<double>::quiet_NaN();
else
avi_->adj_ -= adj_;
}
};
}
inline var operator-(const var& a) {
return var(new neg_vari(a.vi_));
}
}
}
#endif
stan::math::operator-
fvar< T > operator-(const fvar< T > &x1, const fvar< T > &x2)
Definition: operator_subtraction.hpp:14
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
boost::math::isnan
bool isnan(const stan::math::var &v)
Checks if the given number is NaN.
Definition: boost_isnan.hpp:22
unlikely
#define unlikely(x)
Definition: likely.hpp:9
v_vari.hpp
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:44
var.hpp

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