1#ifndef STAN_MATH_PRIM_FUN_EXP_HPP
2#define STAN_MATH_PRIM_FUN_EXP_HPP
23template <
typename T, require_arithmetic_t<T>* =
nullptr>
24inline auto exp(
const T x) {
38template <
typename T, require_complex_bt<std::is_arithmetic, T>* =
nullptr>
39inline auto exp(
const T x) {
56 static inline auto fun(
const T& x) {
70template <
typename Container, require_ad_container_t<Container>* =
nullptr>
71inline auto exp(
const Container& x) {
83template <
typename Container,
85inline auto exp(
const Container& x) {
86 return apply_vector_unary<Container>::apply(
87 x, [](
const auto& v) {
return v.array().
exp(); });
103 if (
is_inf(z.real()) && z.real() > 0) {
104 if (
is_nan(z.imag()) || z.imag() == 0) {
107 }
else if (
is_inf(z.imag()) && z.imag() > 0) {
109 return {z.real(), std::numeric_limits<double>::quiet_NaN()};
110 }
else if (
is_inf(z.imag()) && z.imag() < 0) {
112 return {std::numeric_limits<double>::quiet_NaN(),
113 std::numeric_limits<double>::quiet_NaN()};
116 if (
is_inf(z.real()) && z.real() < 0
121 if (
is_nan(z.real()) && z.imag() == -0.0) {
125 V exp_re =
exp(z.real());
126 return {exp_re *
cos(z.imag()), exp_re *
sin(z.imag())};
require_t< container_type_check_base< is_container, base_type_t, TypeCheck, Check... > > require_container_bt
Require type satisfies is_container.
std::complex< V > complex_exp(const std::complex< V > &z)
Return the natural (base e) complex exponentiation of the specified complex argument.
fvar< T > sin(const fvar< T > &x)
bool is_nan(T &&x)
Returns 1 if the input's value is NaN and 0 otherwise.
fvar< T > cos(const fvar< T > &x)
int is_inf(const fvar< T > &x)
Returns 1 if the input's value is infinite and 0 otherwise.
fvar< T > exp(const fvar< T > &x)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Base template class for vectorization of unary scalar functions defined by a template class F to a sc...
static auto fun(const T &x)
Return the exponential of the specified scalar argument.
Structure to wrap exp() so that it can be vectorized.