C Programming/C Reference/complex.h

< C Programming < C Reference

complex.h is a header file that defines functionality for complex arithmetic.[1] These functions use the built-in type complex which was introduced with the C99 revision of C.

This header should not be confused with the C++ standard library header <complex>, which implements complex numbers in a completely different way (as a template class, complex<T>).

Macro

Universal macro:

Defined only for `C99 Annex G`-compatible compiler modes - native support of imaginary types (it is very rare because Annex G is mathematically incorrect[2]):

Universal alias of I:

Application may undefine complex, imaginary, and I macros if they interfere with internal values.

Functions

Each function declared in complex.h has three versions, each of which works with a different floating-point type (double, float and long double). Only the double version of each function is listed here; to use the float (or long double) version, append an f (or an l, respectively) to the function's name.

Note that all angles are in radians.


Basic operations
  • cabs - computes absolute value
  • carg - computes argument of a complex number
  • cimag - computes imaginary part of a complex number
  • creal - computes real part of a complex number
  • conj - computes complex conjugate
  • cproj - computes complex projection into the Riemann sphere
Exponentiation operations
  • cexp - computes complex exponential
  • clog - computes complex logarithm
  • csqrt - computes complex square root
  • cpow - computes complex power
Trigonometric operations
  • csin - computes complex sine
  • ccos - computes complex cosine
  • ctan - computes complex tangent
  • casin - computes complex arc sine
  • cacos - computes complex arc cosine
  • catan - computes complex arc tangent
Hyperbolic operations
  • csinh - computes complex hyperbolic sine
  • ccosh - computes complex hyperbolic cosine
  • ctanh - computes complex hyperbolic tangent
  • casinh - computes complex hyperbolic arc sine
  • cacosh - computes complex hyperbolic arc cosine
  • catanh - computes complex hyperbolic arc tangent

References

  1. complex.h: complex arithmetic  Base Definitions Reference, The Single UNIX® Specification, Issue 7 from The Open Group
  2. Dr. Dobb's journal: software tools for the professional programmer, Volume 27 "many results in Annex G are pure invention and mathematically incorrect"
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.