A RetroSearch Logo

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

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../algorithm/../../c/header/../numeric/complex/conj.html below:

conjf, conj, conjl - cppreference.com

(1) (since C99) (2) (since C99) (3) (since C99)

#define conj( z )

(4) (since C99) 1-3)

Computes the

complex conjugate

of

z

by reversing the sign of the imaginary part.

4)

Type-generic macro: if

z

has type

long double complex

,

long double imaginary

, or

long double

,

conjl

is called. If

z

has type

float complex

,

float imaginary

, or

float

,

conjf

is called. If

z

has type

double complex

,

double imaginary

,

double

, or any integer type,

conj

is called.

[edit] Parameters [edit] Return value

The complex conjugate of z.

[edit] Notes

On C99 implementations that do not implement I as _Imaginary_I, conj may be used to obtain complex numbers with negative zero imaginary part. In C11, the macro CMPLX is used for that purpose.

[edit] Example
#include <stdio.h>
#include <complex.h>
 
int main(void)
{
    double complex z = 1.0 + 2.0*I;
    double complex z2 = conj(z);
    printf("The conjugate of %.1f%+.1fi is %.1f%+.1fi\n",
            creal(z), cimag(z), creal(z2), cimag(z2));
 
    printf("Their product is %.1f%+.1fi\n", creal(z*z2), cimag(z*z2));
}

Output:

The conjugate of 1.0+2.0i is 1.0-2.0i
Their product is 5.0+0.0i
[edit] References
[edit] See also

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