Automatic Differentiation
 
Loading...
Searching...
No Matches
lmultiply.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_FWD_FUN_LMULTIPLY_HPP
2#define STAN_MATH_FWD_FUN_LMULTIPLY_HPP
3
8#include <cmath>
9
10namespace stan {
11namespace math {
12
13template <typename T>
14inline fvar<T> lmultiply(const fvar<T>& x1, const fvar<T>& x2) {
15 return fvar<T>(lmultiply(x1.val_, x2.val_),
16 x1.d_ * log(x2.val_) + x1.val_ * x2.d_ / x2.val_);
17}
18
19template <typename T>
20inline fvar<T> lmultiply(double x1, const fvar<T>& x2) {
21 return fvar<T>(lmultiply(x1, x2.val_), x1 * x2.d_ / x2.val_);
22}
23
24template <typename T>
25inline fvar<T> lmultiply(const fvar<T>& x1, double x2) {
26 return fvar<T>(lmultiply(x1.val_, x2), x1.d_ * log(x2));
27}
28} // namespace math
29} // namespace stan
30#endif
fvar< T > log(const fvar< T > &x)
Definition log.hpp:18
fvar< T > lmultiply(const fvar< T > &x1, const fvar< T > &x2)
Definition lmultiply.hpp:14
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
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