cproj
Retrieve the projection of a complex number on the Reimann sphere.
Interface Definition
C interface:
float complex cprojf(float complex x);
double complex cproj(double complex x);
long double complex cprojl(long double complex x);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
Return Value
- The projection y of x on the Reimann sphere is returned.
- If the input x.real or x.imag is ±∞, the output y.real is +∞ and z.imag is 0. The sign of z.imag is the same as that of x.imag.
- If both the input x.real and x.imag are not ±∞, the output y = x.
Dependency
C: "kc.h"
Example
C interface:
// typical usage
double x1 = INFINITY, y1 = INFINITY;
double x2 = 2.0, y2 = 3.0;
double x3 = -2.5, y3 = -3.4;
double x4 = NAN, y4 = NAN;
double x5 = 0, y5 = 0;
double complex z1 = cproj(__builtin_complex(x1, y1));
double complex z2 = cproj(__builtin_complex(x2, y2));
double complex z3 = cproj(__builtin_complex(x3, y3));
double complex z4 = cproj(__builtin_complex(x4, y4));
double complex z5 = cproj(__builtin_complex(x5, y5));
// print result
printf("/*\n");
printf(" * cproj(%.2f + %.2f*I) = %.6f + %.6f*I\n", x1, y1, __real__(z1), __imag__(z1));
printf(" * cproj(%.2f + %.2f*I) = %.6f + %.6f*I\n", x2, y2, __real__(z2), __imag__(z2));
printf(" * cproj(%.2f + %.2f*I) = %.6f + %.6f*I\n", x3, y3, __real__(z3), __imag__(z3));
printf(" * cproj(%.2f + %.2f*I) = %.6f + %.6f*I\n", x4, y4, __real__(z4), __imag__(z4));
printf(" * cproj(%.2f + %.2f*I) = %.6f + %.6f*I\n", x5, y5, __real__(z5), __imag__(z5));
printf(" **/\n");
/*
* cproj(inf + inf*I) = inf + 0.000000*I
* cproj(2.00 + 3.00*I) = 2.000000 + 3.000000*I
* cproj(-2.50 + -3.40*I) = -2.500000 + -3.400000*I
* cproj(nan + nan*I) = nan + nan*I
* cproj(0.00 + 0.00*I) = 0.000000 + 0.000000*I
**/
Parent topic: Complex Functions