Automatic Differentiation
 
Loading...
Searching...
No Matches
log.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_FWD_FUN_LOG_HPP
2#define STAN_MATH_FWD_FUN_LOG_HPP
3
8#include <cmath>
9#include <complex>
10
11namespace stan {
12namespace math {
13
14template <typename T>
15inline fvar<T> log(const fvar<T>& x) {
16 using std::log;
17 if (x.val_ < 0.0) {
19 } else {
20 return fvar<T>(log(x.val_), x.d_ / x.val_);
21 }
22}
23
31template <typename T>
32inline std::complex<fvar<T>> log(const std::complex<fvar<T>>& z) {
33 return internal::complex_log(z);
34}
35
36} // namespace math
37} // namespace stan
38#endif
std::complex< V > complex_log(const std::complex< V > &z)
Return the natural logarithm of the complex argument.
Definition log.hpp:79
static constexpr double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition constants.hpp:56
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