std::arg(std::complex)
Min standard notice:
Header: <complex>
- Calculates the phase angle (in radians) of the complex number z.
# Declarations
template< class T >
T arg( const std::complex<T>& z );
Additional overloads (since C++11)
float arg( float f );
double arg( double f );
long double arg( long double f );
(until C++23)
template< class FloatingPoint >
FloatingPoint
arg( FloatingPoint f );
(since C++23)
template< class Integer >
double arg( Integer i );
# Parameters
z: complex valuef: floating-point valuei: integer value
# Notes
The additional overloads are not required to be provided exactly as (A,B). They only need to be sufficient to ensure that for their argument num:
# Example
#include <complex>
#include <iostream>
int main()
{
std::complex<double> z1(1, 0);
std::complex<double> z2(0, 0);
std::complex<double> z3(0, 1);
std::complex<double> z4(-1, 0);
std::complex<double> z5(-1, -0.0);
double f = 1.;
int i = -1;
std::cout << "phase angle of " << z1 << " is " << std::arg(z1) << '\n'
<< "phase angle of " << z2 << " is " << std::arg(z2) << '\n'
<< "phase angle of " << z3 << " is " << std::arg(z3) << '\n'
<< "phase angle of " << z4 << " is " << std::arg(z4) << '\n'
<< "phase angle of " << z5 << " is " << std::arg(z5) << " "
"(the other side of the cut)\n"
<< "phase angle of " << f << " is " << std::arg(f) << '\n'
<< "phase angle of " << i << " is " << std::arg(i) << '\n';
}