lmgamma.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_REV_SCAL_FUN_LMGAMMA_HPP
#define STAN_MATH_REV_SCAL_FUN_LMGAMMA_HPP
#include <stan/math/rev/core.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/lmgamma.hpp>
#include <stan/math/prim/scal/fun/digamma.hpp>
#include <valarray>
namespace stan {
namespace math {
namespace {
class lmgamma_dv_vari : public op_dv_vari {
public:
lmgamma_dv_vari(int a, vari* bvi) :
op_dv_vari(lmgamma(a, bvi->val_), a, bvi) {
}
void chain() {
double deriv = 0;
for (int i = 1; i < ad_ + 1; i++)
deriv += digamma(bvi_->val_ + (1.0 - i) / 2.0);
bvi_->adj_ += adj_ * deriv;
}
};
}
inline var lmgamma(int a, const var& b) {
return var(new lmgamma_dv_vari(a, b.vi_));
}
}
}
#endif
core.hpp
stan
Definition: log_sum_exp.hpp:8
digamma.hpp
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:30
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:42
constants.hpp
lmgamma.hpp
stan::math::lmgamma
fvar< typename stan::return_type< T, int >::type > lmgamma(int x1, const fvar< T > &x2)
Definition: lmgamma.hpp:15
stan::math::digamma
fvar< T > digamma(const fvar< T > &x)
Return the derivative of the log gamma function at the specified argument.
Definition: digamma.hpp:22

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