diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/numeric%2Fcomplex%2Fcpow.html | |
new repository
Diffstat (limited to 'devdocs/c/numeric%2Fcomplex%2Fcpow.html')
| -rw-r--r-- | devdocs/c/numeric%2Fcomplex%2Fcpow.html | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/devdocs/c/numeric%2Fcomplex%2Fcpow.html b/devdocs/c/numeric%2Fcomplex%2Fcpow.html new file mode 100644 index 00000000..6a1e6196 --- /dev/null +++ b/devdocs/c/numeric%2Fcomplex%2Fcpow.html @@ -0,0 +1,56 @@ + <h1 id="firstHeading" class="firstHeading">cpowf, cpow, cpowl</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 cpowf( float complex x, float complex y );</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 cpow( double complex x, double complex y );</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 cpowl( long double complex x, long double complex y );</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 pow( x, y )</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 complex power function x<sup class="t-su">y</sup>, with branch cut for the first parameter along the negative real axis.</div> <div class="t-li1"> +<span class="t-li">4)</span> Type-generic macro: If any argument 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>cpowl</code> is called. if any argument 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>cpow</code> is called, if any argument 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>cpowf</code> is called. If the arguments are real or integer, then the macro invokes the corresponding real function (<code>powf</code>, <code><a href="http://en.cppreference.com/w/c/numeric/math/pow"><span class="kw668">pow</span></a></code>, <code>powl</code>). If any argument is imaginary, the corresponding complex number version is called.</div> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> x, y </td> <td> - </td> <td> complex argument </td> +</tr> +</table> <h3 id="Return_value"> Return value</h3> <p>If no errors occur, the complex power x<sup class="t-su">y</sup>, is returned.</p> +<p>Errors and special cases are handled as if the operation is implemented by <code><a href="http://en.cppreference.com/w/c/numeric/complex/cexp"><span class="kw769">cexp</span></a><span class="br0">(</span>y<span class="sy2">*</span><a href="http://en.cppreference.com/w/c/numeric/complex/clog"><span class="kw772">clog</span></a><span class="br0">(</span>x<span class="br0">)</span><span class="br0">)</span></code>, except that the implementation is allowed to treat special cases more carefully.</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 = cpow(1.0+2.0*I, 2); + printf("(1+2i)^2 = %.1f%+.1fi\n", creal(z), cimag(z)); + + double complex z2 = cpow(-1, 0.5); + printf("(-1+0i)^0.5 = %.1f%+.1fi\n", creal(z2), cimag(z2)); + + double complex z3 = cpow(conj(-1), 0.5); // other side of the cut + printf("(-1-0i)^0.5 = %.1f%+.1fi\n", creal(z3), cimag(z3)); + + double complex z4 = cpow(I, I); // i^i = exp(-pi/2) + printf("i^i = %f%+fi\n", creal(z4), cimag(z4)); +}</pre></div> <p>Output:</p> +<div class="text source-text"><pre data-language="c">(1+2i)^2 = -3.0+4.0i +(-1+0i)^0.5 = 0.0+1.0i +(-1-0i)^0.5 = 0.0-1.0i +i^i = 0.207880+0.000000i</pre></div> </div> <h3 id="References"> References</h3> <ul> +<li> C11 standard (ISO/IEC 9899:2011): </li> +<ul> +<li> 7.3.8.2 The cpow functions (p: 195-196) </li> +<li> 7.25 Type-generic math <tgmath.h> (p: 373-375) </li> +<li> G.6.4.1 The cpow functions (p: 544) </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.8.2 The cpow functions (p: 177) </li> +<li> 7.22 Type-generic math <tgmath.h> (p: 335-337) </li> +<li> G.6.4.1 The cpow functions (p: 479) </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> <div><a href="csqrt" title="c/numeric/complex/csqrt"> <span class="t-lines"><span>csqrt</span><span>csqrtf</span><span>csqrtl</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes the complex square root <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><a href="../math/pow" title="c/numeric/math/pow"> <span class="t-lines"><span>pow</span><span>powf</span><span>powl</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes a number raised to the given power (\(\small{x^y}\)x<sup>y</sup>) <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/numeric/complex/pow" title="cpp/numeric/complex/pow">C++ documentation</a></span> for <code>pow</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/cpow" class="_attribution-link">https://en.cppreference.com/w/c/numeric/complex/cpow</a> + </p> +</div> |
