1#ifndef STAN_MATH_PRIM_CORE_COMPLEX_BASE_HPP
2#define STAN_MATH_PRIM_CORE_COMPLEX_BASE_HPP
17template <
typename ValueType>
54 template <
typename U,
typename V>
93 template <
typename U,
typename = require_stan_scalar_t<U>>
107 template <
typename U>
120 template <
typename U>
134 template <
typename U>
147 template <
typename U>
161 template <
typename U>
175 template <
typename U>
178 im_ =
re_ * other.imag() + other.real() *
im_;
190 template <
typename U>
204 template <
typename U>
208 = (other.real() * other.real()) + (other.imag() * other.imag());
210 im_ = (
im_ * other.real() -
re_ * other.imag()) / sum_sq_im;
complex_type & operator=(U &&re)
Assign the specified value to the real part of this complex number and set imaginary part to zero.
value_type imag() const
Return the imaginary part.
complex_type & operator-=(const std::complex< U > &other)
Subtracts specified complex number from this.
complex_type & operator+=(const std::complex< U > &other)
Adds specified complex number to this.
complex_type & operator+=(const U &x)
Add specified real value to real part.
value_type real() const
Return the real part.
complex_base()=default
Construct a complex base with zero real and imaginary parts.
complex_type & operator-=(const U &x)
Subtracts specified real number from real part.
complex_type & operator/=(const U &x)
Divides this by the specified real number.
complex_base(const U &re, const V &im)
Construct a complex base with the specified real and imaginary parts.
complex_type & operator*=(const std::complex< U > &other)
Multiplies this by specified complex number.
complex_type & derived()
Return this complex base cast to the complex type.
complex_type & operator*=(const U &x)
Multiplies this by the specified real number.
value_type im_
Imaginary part.
complex_base(const U &re)
Construct a complex base with the specified real part and a zero imaginary part.
std::complex< value_type > complex_type
Derived complex type used for function return types.
complex_type & operator/=(const std::complex< U > &other)
Divides this by the specified complex number.
void real(const value_type &re)
Set the real part to the specified value.
void imag(const value_type &im)
Set the imaginary part to the specified value.
ValueType value_type
Type of real and imaginary parts.
Base class for complex numbers.
fvar< T > square(const fvar< T > &x)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...