| Common mathematical functions | |||||||||||||||||||||||||||||||
| Mathematical special functions(C++17) | |||||||||||||||||||||||||||||||
| Mathematical constants(C++20) | |||||||||||||||||||||||||||||||
| Basic linear algebra algorithms(C++26) | |||||||||||||||||||||||||||||||
| Data-parallel types (SIMD)(C++26) | |||||||||||||||||||||||||||||||
| Floating-point environment(C++11) | |||||||||||||||||||||||||||||||
| Complex numbers | |||||||||||||||||||||||||||||||
Numeric array (valarray) | |||||||||||||||||||||||||||||||
| Pseudo-random number generation | |||||||||||||||||||||||||||||||
| Bit manipulation(C++20) | |||||||||||||||||||||||||||||||
| Saturation arithmetic(C++26) | |||||||||||||||||||||||||||||||
| Factor operations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
| Interpolations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
| Generic numeric operations | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
| C-style checked integer arithmetic | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
Defined in header <complex> | ||
template<class T> T arg(conststd::complex<T>& z); | (1) | |
Additional overloads(since C++11) | ||
Defined in header <complex> | ||
| (A) | ||
float arg(float f); double arg(double f); | (until C++23) | |
template<class FloatingPoint> FloatingPoint | (since C++23) | |
template<class Integer> double arg( Integer i); | (B) | |
A,B) Additional overloads are provided for all integer and floating-point types, which are treated as complex numbers with zero imaginary component. | (since C++11) |
Contents |
| z | - | complex value |
| f | - | floating-point value |
| i | - | integer value |
The additional overloads are not required to be provided exactly as(A,B). They only need to be sufficient to ensure that for their argumentnum:
T, thenstd::arg(num) has the same effect asstd::arg(std::complex<T>(num)).#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'; }
Output:
phase angle of (1,0) is 0phase angle of (0,0) is 0phase angle of (0,1) is 1.5708phase angle of (-1,0) is 3.14159phase angle of (-1,-0) is -3.14159 (the other side of the cut)phase angle of 1 is 0phase angle of -1 is 3.14159
| returns the magnitude of a complex number (function template)[edit] | |
| constructs a complex number from magnitude and phase angle (function template)[edit] | |
(C++11)(C++11) | arc tangent, using signs to determine quadrants (function)[edit] |
| applies the functionstd::atan2 to a valarray and a value (function template)[edit] | |
C documentation forcarg | |