Name
cproj
Synopsis
Calculates the projection of a complex number on the Riemann sphere
#include <complex.h> double complexcproj
( double complexz
); float complexcprojf
( float complexz
); long double complexcprojl
( long double complexz
);
The Riemann sphere is a surface that represents the entire
complex plane and one point for infinity. The cproj()
function yields the representation
of a complex number on the Riemann sphere. The value of cproj(
z
)
is equal to
z
, except in cases where the real or
complex part of z
is infinite. In all
such cases, the real part of the result is infinity, and the
imaginary part is zero with the sign of the imaginary part of the
argument z
.
Example
double complex z = -INFINITY − 2.7 * I;
double complex c =cproj
(z);
printf("%.2f %+.2f * I is projected to %.2f %+.2f * I.\n",
creal(z), cimag(z), creal(c), cimag(c));
This code produces the following output:
-inf -2.70 * I is projected to inf -0.00 * I.
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.