The C++ std::complex::proj() function is used to return the projection of a complex number onto the Riemann sphere. If the complex number has a finite values, it returns the number itself or if the number has infinite components, it returns a special value representing infinity on the Riemann sphere.
SyntaxFollowing is the syntax for std::complex::proj() function.
proj (const complex<T>& x); complex<double> conj (ArithmeticType x);Parameters
It returns the projection of the complex number x onto the Riemann sphere.
Exceptionsnone
Example 1In the following example, we are going to consider the basic usage of the proj() function.
#include <iostream> #include <complex> int main() { std::complex < double > x(1.2, 2.3); std::complex < double > y = std::proj(x); std::cout << "Result : " << y << "\n"; return 0; }Output
If we run the above code it will generate the following output −
Result : (1.2,2.3)Example 2
Consider the following example, where we are going to create a projection of the complex number with infinite part.
#include <iostream> #include <complex> int main() { std::complex < double > a(INFINITY, 1.3); std::complex < double > b = std::proj(a); std::cout << "Result : " << b << "\n"; return 0; }Output
Output of the above code is as follows −
Result : (inf,0)Example 3
Let's look at the following example, where we are going to create a projection of complex number with both infinite parts.
#include <iostream> #include <complex> int main() { std::complex < double > a(INFINITY, INFINITY); std::complex < double > b = std::proj(a); std::cout << "Result : " << b << "\n"; return 0; }Output
Following is the output of the above code −
Result : (inf,0)
complex.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4