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_conj.htm below:

C++ Complex::conj() function

C++ Complex::conj() function

The C++ std::complex::conj() function is used to return the complex conjugate of a given complex number. The complex number consists of real and imaginary part, and its conjugate is obtained by chnging the sign of the imaginary part. For example, the conjugate of the complex number x+yi, is x-yi.

Syntax

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

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

It returns the conjugate of the complex number x.

Exceptions

none

Example 1

In the following example, we are going to consider the basic usage of the conj() function.

#include <iostream>
#include <complex>
int main() {
   std::complex < double > x(1.1, 1.3);
   std::complex < double > x1 = std::conj(x);
   std::cout << "Original: " << x << std::endl;
   std::cout << "Conj: " << x1 << std::endl;
   return 0;
}
Output

Output of the above code is as follows −

Original: (1.1,1.3)
Conj: (1.1,-1.3)
Example 2

Consider the following example, where we are going to use the conj() with the zero imaginary part.

#include <iostream>
#include <complex>
int main() {
   std::complex < double > x(1.2, 0.0);
   std::complex < double > x1 = std::conj(x);
   std::cout << "Original: " << x << std::endl;
   std::cout << "Conj: " << x1 << std::endl;
   return 0;
}
Output

Following is the output of the above code −

Original: (1.2,0)
Conj: (1.2,-0)
Example 3

Let's look at the following example, where we are going to use the conj() with the negative values.

#include <iostream>
#include <complex>
int main() {
   std::complex < double > x(-1.2, -2.2);
   std::complex < double > x1 = std::conj(x);
   std::cout << "Original: " << x << std::endl;
   std::cout << "Conj: " << x1 << std::endl;
   return 0;
}
Output

If we run the above code it will generate the following output −

Original: (-1.2,-2.2)
Conj: (-1.2,2.2)

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