1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<h1 id="firstHeading" class="firstHeading">conjf, conj, conjl</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><complex.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">float complex conjf( float complex z );</pre>
</td> <td> (1) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">double complex conj( double complex z );</pre>
</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">long double complex conjl( long double complex z );</pre>
</td> <td> (3) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dsc-header"> <th> Defined in header <code><tgmath.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">#define conj( z )</pre>
</td> <td> (4) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> </table> <div class="t-li1">
<span class="t-li">1-3)</span> Computes the <a href="https://en.wikipedia.org/wiki/Complex_conjugate" class="extiw" title="enwiki:Complex conjugate">complex conjugate</a> of <code>z</code> by reversing the sign of the imaginary part.</div> <div class="t-li1">
<span class="t-li">4)</span> Type-generic macro: if <code>z</code> has type <code><span class="kw4">long</span> <span class="kw4">double</span> <a href="http://en.cppreference.com/w/c/numeric/complex/complex"><span class="kw743">complex</span></a></code>, <code><span class="kw4">long</span> <span class="kw4">double</span> <a href="http://en.cppreference.com/w/c/numeric/complex/imaginary"><span class="kw745">imaginary</span></a></code>, or <code>long double</code>, <code>conjl</code> is called. If <code>z</code> has type <code><span class="kw4">float</span> <a href="http://en.cppreference.com/w/c/numeric/complex/complex"><span class="kw743">complex</span></a></code>, <code><span class="kw4">float</span> <a href="http://en.cppreference.com/w/c/numeric/complex/imaginary"><span class="kw745">imaginary</span></a></code>, or <code>float</code>, <code>conjf</code> is called. If <code>z</code> has type <code><span class="kw4">double</span> <a href="http://en.cppreference.com/w/c/numeric/complex/complex"><span class="kw743">complex</span></a></code>, <code><span class="kw4">double</span> <a href="http://en.cppreference.com/w/c/numeric/complex/imaginary"><span class="kw745">imaginary</span></a></code>, <code>double</code>, or any integer type, <code>conj</code> is called.</div> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> z </td> <td> - </td> <td> complex argument </td>
</tr>
</table> <h3 id="Return_value"> Return value</h3> <p>The complex conjugate of <code>z</code>.</p>
<h3 id="Notes"> Notes</h3> <p>On C99 implementations that do not implement <code>I</code> as <code><a href="imaginary_i" title="c/numeric/complex/Imaginary I">_Imaginary_I</a></code>, <code>conj</code> may be used to obtain complex numbers with negative zero imaginary part. In C11, the macro <code><a href="cmplx" title="c/numeric/complex/CMPLX">CMPLX</a></code> is used for that purpose.</p>
<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#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));
}</pre></div> <p>Output:</p>
<div class="text source-text"><pre data-language="c">The conjugate of 1.0+2.0i is 1.0-2.0i
Their product is 5.0+0.0i</pre></div> </div> <h3 id="References"> References</h3> <ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul>
<li> 7.3.9.4 The conj functions (p: 198) </li>
<li> 7.25 Type-generic math <tgmath.h> (p: 373-375) </li>
<li> G.7 Type-generic math <tgmath.h> (p: 545) </li>
</ul>
<li> C99 standard (ISO/IEC 9899:1999): </li>
<ul>
<li> 7.3.9.3 The conj functions (p: 179) </li>
<li> 7.22 Type-generic math <tgmath.h> (p: 335-337) </li>
<li> G.7 Type-generic math <tgmath.h> (p: 480) </li>
</ul>
</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/numeric/complex/conj" title="cpp/numeric/complex/conj">C++ documentation</a></span> for <code>conj</code> </td>
</tr> </table> <div class="_attribution">
<p class="_attribution-p">
© cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
<a href="https://en.cppreference.com/w/c/numeric/complex/conj" class="_attribution-link">https://en.cppreference.com/w/c/numeric/complex/conj</a>
</p>
</div>
|