stdconjstdcomplex(3)
std::conj(std::complex) - std::conj(std::complex)
Synopsis
Defined in header<complex>
template <class T>
(until C++ 20)
std::complex<T> conj(const std::complex<T> &z);
template <class T>
(since C++ 20)
constexpr std::complex<T> conj(const std::complex<T> &z);
std::complex<float> conj(float z);
template <class DoubleOrInteger>
(1)(since C++ 11)
std::complex<double> conj(DoubleOrInteger z);
(until C++ 20)
std::complex<long double> conj(long double z);
(2)
constexpr std::complex<float> conj(float z);
template <class DoubleOrInteger>
(since C++ 20)
constexpr std::complex<double> conj(DoubleOrInteger z);
constexpr std::complex<long double> conj(long double z);- Computes the complex_conjugate of z by reversing the sign of the imaginary part.
- 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)
Parameters
z - complex value
Return value
The complex conjugate of z
Example
// Run this code
#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:
See also