Complex.h: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
m Dating maintenance tags: {{Merge to}}
 
(4 intermediate revisions by the same user not shown)
Line 1:
#redirect [[C mathematical functions#complex.h]]
{{merge to|C mathematical operations|discuss=Talk:C_standard_library#Pages_for_each_function_and_WP:NOTMANUAL|date=October 2011}}
{{lowercase|title=complex.h}}
{{C Standard library}}
 
'''complex.h''' is a [[header file]] in the [[C standard library|standard library]] of the [[C programming language]] that defines functionality for [[complex arithmetic]].<ref name="SUS">{{man|bd|complex.h|SUS|complex arithmetic}}</ref> These functions use the built-in type <code>complex</code> which was introduced with the [[C99]] revision of C.
 
This header should not be confused with the [[C++ standard library]] header <code>&lt;complex&gt;</code>, which implements complex numbers in a completely different way (as a template class, <code>complex&lt;T&gt;</code>).
 
== Macro ==
Universal macro:
* complex - alias of _Complex
* _Complex_I - constant, which has type "const float _Complex" and value of imaginary unit I, I*I=-1
 
Defined only for `C99 Annex G`-compatible compiler modes - native support of imaginary types (it is very rare because Annex G is mathematically incorrect<ref>[http://books.google.com/books?id=PmNVAAAAMAAJ&q=C99+Annex+G& Dr. Dobb's journal: software tools for the professional programmer, Volume 27] "many results in Annex G are pure invention and mathematically incorrect"</ref>):
* imaginary - alias of _Imaginary
* _Imaginary_I Expands to a constant expression of type const float _Imaginary with the value of the imaginary unit.
 
Universal alias of I:
* I - alias of _Imaginary_I if it is defined else - alias of _Complex_I
 
Application may undefine complex, imaginary, and I macros if they interfere with internal values.
 
==Functions==
Each function declared in <code>complex.h</code> has three versions, each of which works with a different floating-point type (<code>double</code>, <code>float</code> and <code>long{{nbsp}}double</code>). Only the <code>double</code> version of each function is listed here; to use the <code>float</code> (or <code>long{{nbsp}}double</code>) version, append an <code>f</code> (or an <code>l<code>, respectively) to the function's name.
 
Note that all angles are in [[radian]]s.
 
{| class="wikitable"
|-
|<code>double {{spaces|7}} cabs(double complex); || [[Absolute value#Complex numbers|Absolute value]]
|-
|<code>double complex cacos(double complex);</code> || Complex [[inverse cosine]]
|-
|<code>double complex cacosh(double complex);</code> || Complex [[inverse hyperbolic cosine]]
|-
|<code>double {{spaces|7}} carg(double complex);</code> || [[arg (mathematics)|Complex argument]]
|-
|<code>double complex casin(double complex);</code> || Complex [[inverse sine]]
|-
|<code>double complex casinh(double complex);</code> || Complex [[inverse hyperbolic sine]]
|-
|<code>double complex catan(double complex);</code> || Complex [[inverse tangent]]
|-
|<code>double complex catanh(double complex);</code> || Complex [[inverse hyperbolic tangent]]
|-
|<code>double complex ccos(double complex);</code> || Complex [[cosine]]
|-
|<code>double complex ccosh(double complex);</code> || Complex [[hyperbolic cosine]]
|-
|<code>double complex cexp(double complex);</code> || Complex [[Exponential function|exponential]]
|-
|<code>double {{spaces|7}} cimag(double complex);</code> || [[Imaginary part]] of complex number
|-
|<code>double complex clog(double complex);</code> || Complex [[logarithm]]
|-
|<code>double complex conj(double complex);</code> || [[Complex conjugate]]
|-
|<code>double complex cpow(double complex, double complex);</code> || Complex [[exponentiation|power]]
|-
|<code>double complex cproj(double complex);</code> || Complex projection{{ref label|cproj|A|A}}
|-
|<code>double {{spaces|7}} creal(double complex);</code> || [[Real part]] of complex number
|-
|<code>double complex csin(double complex);</code> || Complex [[sine]]
|-
|<code>double complex csinh(double complex);</code> || Complex [[hyperbolic sine]]
|-
|<code>double complex csqrt(double complex);</code> || Complex [[square root]]
|-
|<code>double complex ctan(double complex);</code> || Complex [[tangent (trigonometric function)|tangent]]
|-
|<code>double complex ctanh(double complex);</code> || Complex [[hyperbolic tangent]]
|-
|}
 
:{{note label|cproj|A|A}} cproj(''z'') projects the complex number ''z'' onto the [[Riemann sphere]]; the result is ''z'' itself, except complex infinities are mapped to positive infinity on the real axis.<ref>{{man|sh|cproj|SUS|complex projection function}}</ref>
 
==References==
<references />
 
[[Category:C standard library headers]]
 
[[es:Complex.h]]
[[pt:Complex.h]]
[[ru:Complex.h]]
[[uk:Complex.h]]