Stan Math Library: stan/math/fwd/scal/fun/lmgamma.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

lmgamma.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_SCAL_FUN_LMGAMMA_HPP
2 #define STAN_MATH_FWD_SCAL_FUN_LMGAMMA_HPP
3
4 #include <stan/math/fwd/core.hpp>
5 #include <stan/math/prim/scal/meta/return_type.hpp>
6 #include <stan/math/prim/scal/fun/digamma.hpp>
7 #include <stan/math/prim/scal/fun/lmgamma.hpp>
8
9 namespace stan {
10
11 namespace math {
12
13 template <typename T>
14 inline
15 fvar<typename stan::return_type<T, int>::type>
16 lmgamma(int x1, const fvar<T>& x2) {
17 using stan::math::lmgamma;
18 using stan::math::digamma;
19 using std::log;
20 T deriv = 0;
21 for (int count = 1; count < x1 + 1; count++)
22 deriv += x2.d_ * digamma(x2.val_ + (1.0 - count) / 2.0);
23 return fvar<typename
24 stan::return_type<T, int>::type>(lmgamma(x1, x2.val_), deriv);
25 }
26 }
27 }
28 #endif
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:15
stan
Definition: log_sum_exp.hpp:8
digamma.hpp
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
return_type.hpp
stan::return_type::type
boost::math::tools::promote_args< typename scalar_type< T1 >::type, typename scalar_type< T2 >::type, typename scalar_type< T3 >::type, typename scalar_type< T4 >::type, typename scalar_type< T5 >::type, typename scalar_type< T6 >::type >::type type
Definition: return_type.hpp:27
stan::math::fvar::val_
T val_
Definition: fvar.hpp:14
lmgamma.hpp
stan::math::lmgamma
fvar< typename stan::return_type< T, int >::type > lmgamma(int x1, const fvar< T > &x2)
Definition: lmgamma.hpp:16
stan::math::fvar
Definition: fvar.hpp:13
stan::math::digamma
fvar< T > digamma(const fvar< T > &x)
Definition: digamma.hpp:16

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