1 #ifndef STAN_MATH_REV_SCAL_FUN_MULTIPLY_LOG_HPP
2 #define STAN_MATH_REV_SCAL_FUN_MULTIPLY_LOG_HPP
7 #include <boost/math/special_functions/fpclassify.hpp>
14 class multiply_log_vv_vari :
public op_vv_vari {
16 multiply_log_vv_vari(vari* avi, vari* bvi) :
17 op_vv_vari(stan::math::
multiply_log(avi->val_, bvi->val_), avi, bvi) {
23 avi_->adj_ = std::numeric_limits<double>::quiet_NaN();
24 bvi_->adj_ = std::numeric_limits<double>::quiet_NaN();
26 avi_->adj_ += adj_ *
log(bvi_->val_);
27 if (bvi_->val_ == 0.0 && avi_->val_ == 0)
28 bvi_->adj_ += adj_ * std::numeric_limits<double>::infinity();
30 bvi_->adj_ += adj_ * avi_->val_ / bvi_->val_;
34 class multiply_log_vd_vari :
public op_vd_vari {
36 multiply_log_vd_vari(vari* avi,
double b) :
37 op_vd_vari(stan::math::
multiply_log(avi->val_, b), avi, b) {
43 avi_->adj_ = std::numeric_limits<double>::quiet_NaN();
45 avi_->adj_ += adj_ *
log(bd_);
48 class multiply_log_dv_vari :
public op_dv_vari {
50 multiply_log_dv_vari(
double a, vari* bvi) :
51 op_dv_vari(stan::math::
multiply_log(a, bvi->val_), a, bvi) {
54 if (bvi_->val_ == 0.0 && ad_ == 0.0)
55 bvi_->adj_ += adj_ * std::numeric_limits<double>::infinity();
57 bvi_->adj_ += adj_ * ad_ / bvi_->val_;
75 return var(
new multiply_log_vv_vari(a.
vi_, b.
vi_));
88 return var(
new multiply_log_vd_vari(a.
vi_, b));
104 return var(
new multiply_log_dv_vari(a, b.
vi_));
fvar< T > log(const fvar< T > &x)
Independent (input) and dependent (output) variables for gradients.
bool isnan(const stan::math::var &v)
Checks if the given number is NaN.
vari * vi_
Pointer to the implementation of this variable.
fvar< T > multiply_log(const fvar< T > &x1, const fvar< T > &x2)