Automatic Differentiation
 
Loading...
Searching...
No Matches
multiply_log.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_FWD_FUN_MULTIPLY_LOG_HPP
2#define STAN_MATH_FWD_FUN_MULTIPLY_LOG_HPP
3
7#include <cmath>
8
9namespace stan {
10namespace math {
11
12template <typename T>
13inline fvar<T> multiply_log(const fvar<T>& x1, const fvar<T>& x2) {
14 using std::log;
15 return fvar<T>(multiply_log(x1.val_, x2.val_),
16 x1.d_ * log(x2.val_) + x1.val_ * x2.d_ / x2.val_);
17}
18
19template <typename T>
20inline fvar<T> multiply_log(double x1, const fvar<T>& x2) {
21 using std::log;
22 return fvar<T>(multiply_log(x1, x2.val_), x1 * x2.d_ / x2.val_);
23}
24
25template <typename T>
26inline fvar<T> multiply_log(const fvar<T>& x1, double x2) {
27 using std::log;
28 return fvar<T>(multiply_log(x1.val_, x2), x1.d_ * log(x2));
29}
30} // namespace math
31} // namespace stan
32#endif
fvar< T > multiply_log(const fvar< T > &x1, const fvar< T > &x2)
fvar< T > log(const fvar< T > &x)
Definition log.hpp:15
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9
Scalar val_
The value of this variable.
Definition fvar.hpp:49
Scalar d_
The tangent (derivative) of this variable.
Definition fvar.hpp:61
This template class represents scalars used in forward-mode automatic differentiation,...
Definition fvar.hpp:40