std::proj(std::complex)
From cppreference.com
Defined in header <complex>
|
||
template< class T > complex<T> proj( const complex<T>& z ); |
(since C++11) | |
Returns the projection of the complex number z onto the Riemann sphere.
For most z, std::proj(z)==z, but all complex infinities, even the numbers where one component is infinite and the other is NaN, become positive real infinity, (INFINITY, 0) or (INFINITY, -0). The sign of the imaginary (zero) component is the sign of std::imag(z).
Contents |
[edit] Parameters
z | - | complex value |
[edit] Return value
the projection of z onto the Riemann sphere
[edit] Example
#include <iostream> #include <complex> int main() { std::complex<double> c1(1, 2); std::cout << "proj" << c1 << " = " << std::proj(c1) << '\n'; std::complex<double> c2(INFINITY, -1); std::cout << "proj" << c2 << " = " << std::proj(c2) << '\n'; std::complex<double> c3(0, -INFINITY); std::cout << "proj" << c3 << " = " << std::proj(c3) << '\n'; }
Output:
proj(1,2) = (1,2) proj(inf,-1) = (inf,-0) proj(0,-inf) = (inf,-0)
[edit] See also
returns the magnitude of a complex number (function template) | |
returns the squared magnitude (function template) | |
constructs a complex number from magnitude and phase angle (function template) |