cproj(), cprojf(), cprojl() — Calculate the projection
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C99 |
both | z/OS V1R7 |
Format
#include <complex.h>
double complex cproj(double complex z);
float complex cprojf(float complex z);
long double complex cprojl(long double complex z);
General description
The cproj() family of functions compute a projection of z onto the Riemann sphere: z projects to z except that all complex infinities (even those with one infinite part and one NaN part) project to positive infinity on the real axis. If z has an infinite part, then cproj(z) is equivalent to:
INFINITY +I * copysign(0.0, cimag(z))
Note: The
following table shows the viable formats for these functions. See IEEE binary floating-point for more information about IEEE
Binary Floating-Point.
Function | Hex | IEEE |
---|---|---|
cproj | X | X |
cprojf | X | X |
cprojl | X | X |
Returned value
The cproj() family of functions return the value of the projection onto the Riemann sphere.
For a variable z of complex type, z == creal(z) + cimag(z)*I.
Special behavior for hex: On hexadecimal floating point mode, cproj(z) family of functions always returns z .
Example
#include <complex.h>
#include <stdio.h>
/*
* Illustrates complex function cproj().
*
* NOTE: When compiled in HEX(FLOAT), cproj(z) should
* always return z
*/
#define INFINITEL 1.0L/0.0L /* An infinite number */
void InitReal ( long double complex *z, long double RealPart)
{
union LongDoubleComplexMap {
long double complex w;
long double ldarray[2];
}z1;
z1.w = *z;
z1.ldarray[0] = RealPart;
*z = z1.w;
}
main() {
long double complex z,w;
z = 2.5 + I*(-3.999);
printf("Ilustrates function cproj() ");
#ifdef _BFP_
printf ("(IEEE mode)");
#else
printf ("(HFP mode)");
#endif
printf("\n\n z = %Lf + I*%Lf\n\n",creall(z), cimagl(z));
w = cprojl(z);
printf(" cproj(z) = %Lf + I*%Lf\n",creall(w), cimagl(w));
printf(" Initializing z(real) with infinity ...\n");
InitReal(z,INFINITEL);
printf(" z = %Lf + %Lf*I\n",creall(z),cimagl(z));
w = cprojl(z);
printf(" cproj(z) = %Lf + %Lf*I\n",creall(w),cimagl(w));
}
Output
Ilustrates function cproj() (IEEE mode)
z = 2.500000 + I*-3.999000
cproj(z) = 2.500000 + I*-3.999000
Initializing z(real) with infinity ...
z = INF + -3.999000*I
cproj(z) = INF + -0.000000*I