Standard library header - cppreference.com (original) (raw)

This header is part of the numeric library.

Contents

[edit] Classes

| | a complex number type (class template) | | ----------------------------------------- |

[edit] Functions

Operations
operator+operator- applies unary operators to complex numbers (function template) [edit]
operator+operator-operator*operator/ performs complex number arithmetic on two complex values or a complex and a scalar (function template) [edit]
operator==operator!=(removed in C++20) compares two complex numbers or a complex and a scalar (function template) [edit]
operator<> serializes and deserializes a complex number (function template) [edit]
real returns the real part (function template) [edit]
imag returns the imaginary part (function template) [edit]
abs(std::complex) returns the magnitude of a complex number (function template) [edit]
arg returns the phase angle (function template) [edit]
norm returns the squared magnitude (function template) [edit]
conj returns the complex conjugate (function template) [edit]
proj(C++11) returns the projection onto the Riemann sphere (function template) [edit]
polar constructs a complex number from magnitude and phase angle (function template) [edit]
Exponential functions
exp(std::complex) complex base e exponential (function template) [edit]
log(std::complex) complex natural logarithm with the branch cuts along the negative real axis (function template) [edit]
log10(std::complex) complex common logarithm with the branch cuts along the negative real axis (function template) [edit]
Power functions
pow(std::complex) complex power, one or both arguments may be a complex number (function template) [edit]
sqrt(std::complex) complex square root in the range of the right half-plane (function template) [edit]
Trigonometric functions
sin(std::complex) computes sine of a complex number (\({\small\sin{z}}\)sin(z)) (function template) [edit]
cos(std::complex) computes cosine of a complex number (\({\small\cos{z}}\)cos(z)) (function template) [edit]
tan(std::complex) computes tangent of a complex number (\({\small\tan{z}}\)tan(z)) (function template) [edit]
asin(std::complex)(C++11) computes arc sine of a complex number (\({\small\arcsin{z}}\)arcsin(z)) (function template) [edit]
acos(std::complex)(C++11) computes arc cosine of a complex number (\({\small\arccos{z}}\)arccos(z)) (function template) [edit]
atan(std::complex)(C++11) computes arc tangent of a complex number (\({\small\arctan{z}}\)arctan(z)) (function template) [edit]
Hyperbolic functions
sinh(std::complex) computes hyperbolic sine of a complex number (\({\small\sinh{z}}\)sinh(z)) (function template) [edit]
cosh(std::complex) computes hyperbolic cosine of a complex number (\({\small\cosh{z}}\)cosh(z)) (function template) [edit]
tanh(std::complex) computes hyperbolic tangent of a complex number (\({\small\tanh{z}}\)tanh(z)) (function template) [edit]
asinh(std::complex)(C++11) computes area hyperbolic sine of a complex number (\({\small\operatorname{arsinh}{z}}\)arsinh(z)) (function template) [edit]
acosh(std::complex)(C++11) computes area hyperbolic cosine of a complex number (\({\small\operatorname{arcosh}{z}}\)arcosh(z)) (function template) [edit]
atanh(std::complex)(C++11) computes area hyperbolic tangent of a complex number (\({\small\operatorname{artanh}{z}}\)artanh(z)) (function template) [edit]
Literals
[ operator""ifoperator""ioperator""il](../numeric/complex/operator%2522%2522i.html "cpp/numeric/complex/operator""i")(C++14) a std::complex literal representing purely imaginary number (function) [edit]

[edit] Synopsis

namespace std { template class complex;   template<> class complex; template<> class complex; template<> class complex;   // operators: template constexpr complex operator+( const complex&, const complex&); template constexpr complex operator+(const complex&, const T&); template constexpr complex operator+(const T&, const complex&);   template constexpr complex operator-( const complex&, const complex&); template constexpr complex operator-(const complex&, const T&); template constexpr complex operator-(const T&, const complex&);   template constexpr complex operator*( const complex&, const complex&); template constexpr complex operator*(const complex&, const T&); template constexpr complex operator*(const T&, const complex&);   template constexpr complex operator/( const complex&, const complex&); template constexpr complex operator/(const complex&, const T&); template constexpr complex operator/(const T&, const complex&);   template constexpr complex operator+(const complex&); template constexpr complex operator-(const complex&);   template constexpr bool operator==(const complex&, const complex&); template constexpr bool operator==(const complex&, const T&); template constexpr bool operator==(const T&, const complex&);   template constexpr bool operator!=(const complex&, const complex&); template constexpr bool operator!=(const complex&, const T&); template constexpr bool operator!=(const T&, const complex&);   template<class T, class CharT, class Traits> basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>&, complex&);   template<class T, class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>&, const complex&);   // values: template constexpr T real(const complex&); template constexpr T imag(const complex&);   template T abs(const complex&); template T arg(const complex&); template constexpr T norm(const complex&);   template constexpr complex conj(const complex&); template complex proj(const complex&); template complex polar(const T&, const T& = 0);   // transcendentals: template complex acos(const complex&); template complex asin(const complex&); template complex atan(const complex&);   template complex acosh(const complex&); template complex asinh(const complex&); template complex atanh(const complex&);   template complex cos (const complex&); template complex cosh (const complex&); template complex exp (const complex&); template complex log (const complex&); template complex log10(const complex&);   template complex pow(const complex&, const T&); template complex pow(const complex&, const complex&); template complex pow(const T&, const complex&);   template complex sin (const complex&); template complex sinh(const complex&); template complex sqrt(const complex&); template complex tan (const complex&); template complex tanh(const complex&);   // tuple interface: template struct tuple_size; template<size_t I, class T> struct tuple_element; template struct tuple_size<complex>; template<size_t I, class T> struct tuple_element<I, complex>; template<size_t I, class T> constexpr T& get(complex&) noexcept; template<size_t I, class T> constexpr T&& get(complex&&) noexcept; template<size_t I, class T> constexpr const T& get(const complex&) noexcept; template<size_t I, class T> constexpr const T&& get(const complex&&) noexcept;   // complex literals: inline namespace literals { inline namespace complex_literals { constexpr complex operator""il(long double); constexpr complex operator""il(unsigned long long); constexpr complex operator""i(long double); constexpr complex operator""i(unsigned long long); constexpr complex operator""if(long double); constexpr complex operator""if(unsigned long long); } } }

[edit] Class std::complex

template class complex { public: typedef T value_type; constexpr complex(const T& re = T(), const T& im = T()); constexpr complex(const complex&) = default; template constexpr explicit(/* see constructor page /) complex(const complex&);   constexpr T real() const; constexpr void real(T); constexpr T imag() const; constexpr void imag(T);   constexpr complex& operator= (const T&); constexpr complex& operator+=(const T&); constexpr complex& operator-=(const T&); constexpr complex& operator=(const T&); constexpr complex& operator/=(const T&);   constexpr complex& operator=(const complex&); template constexpr complex& operator= (const complex&); template constexpr complex& operator+=(const complex&); template constexpr complex& operator-=(const complex&); template constexpr complex& operator*=(const complex&); template constexpr complex& operator/=(const complex&); };

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
LWG 79 C++98 the default argument of the second parameterof polar was missing in the synopsis added