| complex (1) | template<class T> T arg (const complex<T>& x); |
|---|
| complex (1) | template<class T> T arg (const complex<T>& x); |
|---|---|
| arithmetic type (2) | double arg (ArithmeticType x); // additional overloads |
(real,imag) forms with the real axis (i.e., its arc tangent). It returns the same as:1
atan2(x.imag(),x.real());
double, except if the argument is float or long double (in which case, the return type is of the same type as the argument).1
2
3
4
5
6
7
8
9
10
11
12
13
// arg complex example
#include <iostream> // std::cout
#include <complex> // std::complex, std::abs, std::arg
int main ()
{
std::complex<double> mycomplex (3.0,4.0);
std::cout << "The polar form of " << mycomplex;
std::cout << " is " << std::abs(mycomplex) << "*e^i*" << std::arg(mycomplex) << "rad\n";
return 0;
}
The polar form of (3,4) is 5*e^i*0.927295rad