| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
log_rising_factorial.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_SCAL_FUN_LOG_RISING_FACTORIAL_HPP
2 #define STAN_MATH_REV_SCAL_FUN_LOG_RISING_FACTORIAL_HPP
3
4 #include <stan/math/rev/core.hpp>
5 #include <stan/math/prim/scal/fun/log_rising_factorial.hpp>
6 #include <stan/math/prim/scal/fun/digamma.hpp>
7 #include <stan/math/rev/scal/fun/digamma.hpp>
8
9 namespace stan {
10 namespace math {
11
12 namespace {
13
14 class log_rising_factorial_vv_vari : public op_vv_vari {
15 public:
16 log_rising_factorial_vv_vari(vari* avi, vari* bvi) :
17 op_vv_vari(stan::math::log_rising_factorial(avi->val_, bvi->val_),
18 avi, bvi) {
19 }
20 void chain() {
21 avi_->adj_ += adj_ * (digamma(avi_->val_ + bvi_->val_)
22 - digamma(avi_->val_));
23 bvi_->adj_ += adj_ * digamma(avi_->val_ + bvi_->val_);
24 }
25 };
26
27 class log_rising_factorial_vd_vari : public op_vd_vari {
28 public:
29 log_rising_factorial_vd_vari(vari* avi, double b) :
30 op_vd_vari(stan::math::log_rising_factorial(avi->val_, b), avi, b) {
31 }
32 void chain() {
33 avi_->adj_ += adj_ * (digamma(avi_->val_ + bd_)
34 - digamma(avi_->val_));
35 }
36 };
37
38 class log_rising_factorial_dv_vari : public op_dv_vari {
39 public:
40 log_rising_factorial_dv_vari(double a, vari* bvi) :
41 op_dv_vari(stan::math::log_rising_factorial(a, bvi->val_), a, bvi) {
42 }
43 void chain() {
44 bvi_->adj_ += adj_ * digamma(bvi_->val_ + ad_);
45 }
46 };
47 }
48
49 inline var log_rising_factorial(const var& a,
50 const double& b) {
51 return var(new log_rising_factorial_vd_vari(a.vi_, b));
52 }
53
54 inline var log_rising_factorial(const var& a,
55 const var& b) {
56 return var(new log_rising_factorial_vv_vari(a.vi_, b.vi_));
57 }
58
59 inline var log_rising_factorial(const double& a,
60 const var& b) {
61 return var(new log_rising_factorial_dv_vari(a, b.vi_));
62 }
63 }
64 }
65 #endif
core.hpp
digamma.hpp
digamma.hpp
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
log_rising_factorial.hpp
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:44
stan::math::log_rising_factorial
fvar< T > log_rising_factorial(const fvar< T > &x, const fvar< T > &n)
Definition: log_rising_factorial.hpp:16
stan::math::digamma
fvar< T > digamma(const fvar< T > &x)
Definition: digamma.hpp:16

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