Automatic Differentiation
 
Loading...
Searching...
No Matches
std_complex.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_CORE_STD_COMPLEX_HPP
2#define STAN_MATH_REV_CORE_STD_COMPLEX_HPP
3
7#include <cmath>
8#include <complex>
9
10namespace std {
11
16template <>
17class complex<stan::math::var>
18 : public stan::math::complex_base<stan::math::var> {
19 public:
21
25 complex() = default;
26
35 template <typename U, typename V>
36 complex(const U& re, const V& im) : base_t(re, im) {}
37
45 template <typename U, typename = stan::require_stan_scalar_t<U>>
46 complex(const U& re) : base_t(re) {} // NOLINT(runtime/explicit)
47
48 template <typename U>
49 complex(const std::complex<U>& z) // NOLINT(runtime/explicit)
50 : base_t(z.real(), z.imag()) {}
51
60 template <typename U, typename = stan::require_arithmetic_t<U>>
61 auto& operator=(const std::complex<U>& x) {
62 re_ = x.real();
63 im_ = x.imag();
64 return *this;
65 }
66};
67
68} // namespace std
69
70#endif
Base class for complex numbers.
complex(const U &re, const V &im)
Construct a complex number from real and imaginary parts.
auto & operator=(const std::complex< U > &x)
Set the real and imaginary components of this complex number to those of the specified complex number...
complex(const U &re)
Construct a complex number with specified real part and zero imaginary part.
complex(const std::complex< U > &z)
complex()=default
Construct a complex number with zero real and imaginary parts.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
STL namespace.