Defined in header <complex> | ||
---|---|---|
(1) | ||
template< class T > std::complex<T> conj( const std::complex<T>& z ); | (until C++20) | |
template< class T > constexpr std::complex<T> conj( const std::complex<T>& z ); | (since C++20) | |
(2) | ||
std::complex<float> conj( float z ); template< class DoubleOrInteger > std::complex<double> conj( DoubleOrInteger z ); std::complex<long double> conj( long double z ); | (since C++11) (until C++20) | |
constexpr std::complex<float> conj( float z ); template< class DoubleOrInteger > constexpr std::complex<double> conj( DoubleOrInteger z ); constexpr std::complex<long double> conj( long double z ); | (since C++20) |
2) Additional overloads are provided for float , double , long double , and all integer types, which are treated as complex numbers with zero imaginary component. | (since C++11) |
z | - | complex value |
The complex conjugate of z
.
#include <iostream> #include <complex> int main() { std::complex<double> z(1,2); std::cout << "The conjugate of " << z << " is " << std::conj(z) << '\n' << "Their product is " << z*std::conj(z) << '\n'; }
Output:
The conjugate of (1,2) is (1,-2) Their product is (5,0)
returns the magnitude of a complex number (function template) |
|
returns the squared magnitude (function template) |
|
constructs a complex number from magnitude and phase angle (function template) |
|
C documentation for conj |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/numeric/complex/conj