std::arg(std::complex) (3) - Linux Manuals
std::arg(std::complex): std::arg(std::complex)
Command to display std::arg(std::complex)
manual in Linux: $ man 3 std::arg(std::complex)
NAME
std::arg(std::complex) - std::arg(std::complex)
Synopsis
Defined in header <complex>
template< class T > (1)
T arg( const complex<T>& z );
long double arg( long double z ); (2) (since C++11)
template< class DoubleOrInteger > (3) (since C++11)
double arg( DoubleOrInteger z );
float arg( float z ); (4) (since C++11)
Calculates the phase angle (in radians) of the complex number z
(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.
Parameters
z - complex value
Return value
If no errors occur, returns the phase angle of z in the interval [−π; π].
Errors and special cases are handled as if the function is implemented as std::atan2(std::imag(z), std::real(z)).
Example
// Run this code
#include <iostream>
#include <complex>
int main()
{
std::complex<double> z1(1, 0);
std::cout << "phase angle of " << z1 << " is " << std::arg(z1) << '\n';
std::complex<double> z2(0, 1);
std::cout << "phase angle of " << z2 << " is " << std::arg(z2) << '\n';
std::complex<double> z3(-1, 0);
std::cout << "phase angle of " << z3 << " is " << std::arg(z3) << '\n';
std::complex<double> z4(-1, -0.0);
std::cout << "phase angle of " << z4 << " (the other side of the cut) is "
<< std::arg(z4) << '\n';
}
Output:
phase angle of (1,0) is 0
phase angle of (0,1) is 1.5708
phase angle of (-1,0) is 3.14159
phase angle of (-1,-0) (the other side of the cut) is -3.14159
See also
returns the magnitude of a complex number
abs(std::complex) (function template)
constructs a complex number from magnitude and phase angle
polar (function template)
atan2
atan2f
atan2l arc tangent, using signs to determine quadrants
(function)
(C++11)
(C++11)
applies the function std::atan2 to a valarray and a value
atan2(std::valarray) (function template)
Pages related to std::arg(std::complex)
- std::array (3) - std::array
- std::array<T,N>::at (3) - std::array<T,N>::at
- std::array<T,N>::back (3) - std::array<T,N>::back
- std::array<T,N>::begin,std::array<T,N>::cbegin (3) - std::array<T,N>::begin,std::array<T,N>::cbegin
- std::array<T,N>::data (3) - std::array<T,N>::data
- std::array<T,N>::empty (3) - std::array<T,N>::empty
- std::array<T,N>::end,std::array<T,N>::cend (3) - std::array<T,N>::end,std::array<T,N>::cend
- std::array<T,N>::fill (3) - std::array<T,N>::fill
- std::array<T,N>::front (3) - std::array<T,N>::front
- std::array<T,N>::max_size (3) - std::array<T,N>::max_size
- std::array<T,N>::operator[] (3) - std::array<T,N>::operator[]