Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/numeric/complex/conj"

From cppreference.com
< cpp‎ | numeric‎ | complex
(+example, wikilink)
Line 11: Line 11:
 
}}
 
}}
 
{{dcl | num=3 | since=c++11 | 1=
 
{{dcl | num=3 | since=c++11 | 1=
template< class DoubleOrIngeter >
+
template< class DoubleOrInteger >
 
std::complex<double> conj( DoubleOrInteger z );
 
std::complex<double> conj( DoubleOrInteger z );
 
}}
 
}}

Revision as of 00:55, 7 March 2016

 
 
 
 
Defined in header <complex>
template< class T >
complex<T> conj( const complex<T>& z );
(1)
std::complex<long double> conj( long double z );
(2) (since C++11)
template< class DoubleOrInteger >
std::complex<double> conj( DoubleOrInteger z );
(3) (since C++11)
std::complex<float> conj( float z );
(4) (since C++11)

Computes the complex conjugate of z by reversing the sign of the imaginary part.

(since C++11)Additional overloads are provided for float, double, long double, and all integer types, which are treated as complex numbers with zero imaginary component.

Contents

Parameters

z - complex value

Return value

The complex conjugate of z

Example

#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)

See also

returns the magnitude of a complex number
(function template) [edit]
returns the squared magnitude
(function template) [edit]
constructs a complex number from magnitude and phase angle
(function template) [edit]