The cprojl
function is a variation of the cproj
function, which computes the projection of a complex number on the
The l
in cprojl
indicates that this function’s argument and return datatype is a long double
.
long double complex cprojl(long double complex z);
The cprojl
function is accessible via the math.h
library. To access complex numbers, we must include the complex.h
header file.
The cprojl
function takes a single parameter: a complex number of datatype long double
, the projection of which is also required.
The function returns the projection of the argument on the Reimann sphere as a complex number.
The
cprojl
function maps all infinities (e.g. +3i, -7) to one infinity (i.e., ).
The following code shows some examples of the use of cprojl
function.
The cproj
function returns a complex number, while the creal
function returns the real part of the complex number and cimag
returns the imaginary of the complex number.
#include <stdio.h> #include <math.h> #include <complex.h> int main() { double complex num1 = cprojl(3 + 4*I); printf("cproj(3 + 4i) = %.1f% + .1fi\n", creal(num1), cimag(num1)); // %.1f specifies precision of the given float number to 1 decimal place double complex num2 = cprojl(INFINITY + 2.0*I); printf("cproj(inf + 2i) = %.1f% + .1fi\n", creal(num2), cimag(num2)); }
RELATED TAGS
CONTRIBUTOR
View all Courses