| Stan Math Library 2.12.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 namespace math {
11
12 template <typename T>
13 inline
14 fvar<typename stan::return_type<T, int>::type>
15 lmgamma(int x1, const fvar<T>& x2) {
16 using std::log;
17 T deriv = 0;
18 for (int count = 1; count < x1 + 1; count++)
19 deriv += x2.d_ * digamma(x2.val_ + (1.0 - count) / 2.0);
20 return fvar<typename
21 stan::return_type<T, int>::type>(lmgamma(x1, x2.val_), deriv);
22 }
23 }
24 }
25 #endif
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:14
stan
Definition: log_sum_exp.hpp:8
digamma.hpp
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:14
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:13
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::fvar
Definition: fvar.hpp:12
stan::math::digamma
fvar< T > digamma(const fvar< T > &x)
Definition: digamma.hpp:15

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