All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
lgamma.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_REV_SCAL_FUN_LGAMMA_HPP
#define STAN_MATH_REV_SCAL_FUN_LGAMMA_HPP
#include <stan/math/rev/core.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <boost/math/special_functions/digamma.hpp>
#include <boost/math/special_functions/gamma.hpp>
#include <valarray>
namespace stan {
namespace math {
namespace {
class lgamma_vari : public op_v_vari {
public:
lgamma_vari(double value, vari* avi) :
op_v_vari(value, avi) {
}
void chain() {
avi_->adj_ += adj_ * boost::math::digamma(avi_->val_);
}
};
}
inline var lgamma(const stan::math::var& a) {
double lgamma_a = boost::math::lgamma(a.val());
return var(new lgamma_vari(lgamma_a, a.vi_));
}
}
}
#endif
core.hpp
stan::math::lgamma
fvar< T > lgamma(const fvar< T > &x)
Definition: lgamma.hpp:15
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
stan::math::lgamma
var lgamma(const stan::math::var &a)
The log gamma function for variables (C99).
Definition: lgamma.hpp:35
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:44
constants.hpp
stan::math::var::val
double val() const
Return the value of this variable.
Definition: var.hpp:234
stan::math::digamma
fvar< T > digamma(const fvar< T > &x)
Definition: digamma.hpp:16

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