A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/cpp_complex_proj.htm below:

C++ Complex::proj() function

C++ Complex::proj() function

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.

Syntax

Following is the syntax for std::complex::proj() function.

proj (const complex<T>& x);
complex<double> conj (ArithmeticType x);
Parameters Return Value

It returns the projection of the complex number x onto the Riemann sphere.

Exceptions

none

Example 1

In 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