1 #ifndef STAN__AGRAD__REV__FUNCTIONS__MULTIPLY_LOG_HPP
2 #define STAN__AGRAD__REV__FUNCTIONS__MULTIPLY_LOG_HPP
11 #include <boost/math/special_functions/fpclassify.hpp>
17 class multiply_log_vv_vari :
public op_vv_vari {
19 multiply_log_vv_vari(vari* avi, vari* bvi) :
20 op_vv_vari(stan::math::
multiply_log(avi->val_,bvi->val_),avi,bvi) {
26 avi_->adj_ = std::numeric_limits<double>::quiet_NaN();
27 bvi_->adj_ = std::numeric_limits<double>::quiet_NaN();
29 avi_->adj_ += adj_ *
log(bvi_->val_);
30 if (bvi_->val_ == 0.0 && avi_->val_ == 0)
31 bvi_->adj_ += adj_ * std::numeric_limits<double>::infinity();
33 bvi_->adj_ += adj_ * avi_->val_ / bvi_->val_;
37 class multiply_log_vd_vari :
public op_vd_vari {
39 multiply_log_vd_vari(vari* avi,
double b) :
40 op_vd_vari(stan::math::
multiply_log(avi->val_,b),avi,b) {
46 avi_->adj_ = std::numeric_limits<double>::quiet_NaN();
48 avi_->adj_ += adj_ *
log(bd_);
51 class multiply_log_dv_vari :
public op_dv_vari {
53 multiply_log_dv_vari(
double a, vari* bvi) :
54 op_dv_vari(stan::math::
multiply_log(a,bvi->val_),a,bvi) {
57 if (bvi_->val_ == 0.0 && ad_ == 0.0)
58 bvi_->adj_ += adj_ * std::numeric_limits<double>::infinity();
60 bvi_->adj_ += adj_ * ad_ / bvi_->val_;
78 return var(
new multiply_log_vv_vari(a.
vi_,b.
vi_));
91 return var(
new multiply_log_vd_vari(a.
vi_,b));
107 return var(
new multiply_log_dv_vari(a,b.
vi_));
bool isnan(const stan::agrad::var &v)
Checks if the given number is NaN.
vari * vi_
Pointer to the implementation of this variable.
Independent (input) and dependent (output) variables for gradients.
fvar< T > multiply_log(const fvar< T > &x1, const fvar< T > &x2)
fvar< T > log(const fvar< T > &x)