Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
multiply_log.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__FWD__FUNCTIONS__MULTIPLY_LOG_HPP
2 #define STAN__AGRAD__FWD__FUNCTIONS__MULTIPLY_LOG_HPP
3 
5 #include <stan/meta/traits.hpp>
7 
8 namespace stan {
9 
10  namespace agrad {
11 
12  template <typename T>
13  inline
14  fvar<T>
15  multiply_log(const fvar<T>& x1, const fvar<T>& x2) {
17  using std::log;
18  return fvar<T>(multiply_log(x1.val_, x2.val_),
19  x1.d_ * log(x2.val_) + x1.val_ * x2.d_ / x2.val_);
20  }
21 
22  template <typename T>
23  inline
24  fvar<T>
25  multiply_log(const double x1, const fvar<T>& x2) {
27  using std::log;
28  return fvar<T>(multiply_log(x1, x2.val_),
29  x1 * x2.d_ / x2.val_);
30  }
31 
32  template <typename T>
33  inline
34  fvar<T>
35  multiply_log(const fvar<T>& x1, const double x2) {
37  using std::log;
38  return fvar<T>(multiply_log(x1.val_, x2),
39  x1.d_ * log(x2));
40  }
41  }
42 }
43 #endif
boost::math::tools::promote_args< T_a, T_b >::type multiply_log(const T_a a, const T_b b)
Calculated the value of the first argument times log of the second argument while behaving properly w...
fvar< T > multiply_log(const fvar< T > &x1, const fvar< T > &x2)
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15

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