Namespaces
Variants
Views
Actions

std::proj(std::complex)

From cppreference.com
< cpp‎ | numeric‎ | complex
Revision as of 14:44, 18 April 2013 by Cubbi (Talk | contribs)

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <complex>
</td>

<td></td> <td></td> <tr class="t-dcl ">

<td >
template< class T >
complex<T> proj( const complex<T>& z );
</td>

<td > (1) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">

<td >
std::complex<long double> proj( long double z );
</td>

<td > (2) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">

<td >
template< class DoubleOrIngeter >
std::complex<double> proj( DoubleOrInteger z );
</td>

<td > (3) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">

<td >
std::complex<float> proj( float z );
</td>

<td > (4) </td> <td > (since C++11) </td> </tr> Template:ddcl list end

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).

(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.

Contents

Parameters

z - complex value

Return value

the projection of z onto the Riemann sphere

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)

See also

Template:cpp/numeric/complex/dcl list absTemplate:cpp/numeric/complex/dcl list normTemplate:cpp/numeric/complex/dcl list polar