m (Inject moved page Complex.h - C to c/complex.h) |
|
(No difference)
|
Revision as of 19:22, 7 January 2015
The <complex.h> header is part of the standard library of the C programming language which provides a set of macros and functions that support complex arithmetic.
This header is optional and therefore need not be provided by an implementation. A program can check for the existence of this header by checking if the macro __STDC_NO_COMPLEX__ is defined. When defined, an implementation is not required to provide this header nor any of its facilities.
#ifndef __STDC_NO_COMPLEX__
# include <complex.h>
#else
# error Implementation has no complex type support!
#endif
Contents
Naming convention
The naming convention used in this header is a set of principle functions followed by a number of secondary functions of the same name but with a f and l suffixes for the float and long double versions of the function. The principle function is one with one or more double complex parameters an a double complex or double return value.
Values in radians
All the functions in this header expect values in radians, not degrees.
Imaginary unit
The imaginary unit number, commonly denoted as i, is defined as a number i such that i2 = -1.
Macros
The header provides the following macro definitions:
Macro Name | Description | Since |
---|---|---|
complex | Expands to the _Complex keyword | C99 |
_Complex_I | Expands to the value of the imaginary unit with the type const float _Complex. | C99 |
imaginary | Expands to _Imaginary keyword | C99 |
_Imaginary_I | Expands to the value of the imaginary unit with the type const float _Imaginary. | C99 |
I | Expands to _Imaginary_I if defined, otherwise expands to _Complex_I | C99 |
CMPLX | Expand to an expression of type double complex | C11 |
CMPLXF | Expand to an expression of type float complex | C11 |
Pragmas
The algorithms used by the functions in this header can be more finely tuned by the following pragmas:
Pragma Name | Description | Since |
---|---|---|
STDC CX_LIMITED_RANGE | Indicates that the usual mathematical formulas are acceptable. | C99 |
Functions
The <complex.h> header provides functions that fall under five distinct categories:
- Trigonometric functions
- Hyperbolic functions
- Exponential and logarithmic functions
- Power and absolute-value functions
- Manipulation functions
Trigonometric functions
This category provides a set of the basic trigonometric functions such as cosine, sine, and tangent as well as arc cosine, arc sine, and arc tangent for operating on complex numbers.
Hyperbolic functions
This category includes a set of functions for computing the hyperbolic cosine, sine, and tangent of complex numbers as well as the arc hyperbolic cosine, sine, and tangent of complex numbers.
Function Prototype | Description | Since |
---|---|---|
double complex cacosh(double complex z); | Computes the complex arc hyperbolic cosine of z. | C99 |
float complex cacoshf(float complex z); | Computes the complex arc hyperbolic cosine of z. | C99 |
long double complex cacoshl(long double complex z); | Computes the complex arc hyperbolic cosine of z. | C99 |
double complex casinh(double complex z); | Computes the complex arc hyperbolic sine of z. | C99 |
float complex casinhf(float complex z) | Computes the complex arc hyperbolic sine of z. | C99 |
long double complex casinhl(long double complex z); | Computes the complex arc hyperbolic sine of z. | C99 |
double complex catanh(double complex z); | Computes the complex arc hyperbolic tangent of z. | C99 |
float complex catanhf(float complex z); | Computes the complex arc hyperbolic tangent of z. | C99 |
long double complex catanhl(long double complex z); | Computes the complex arc hyperbolic tangent of z. | C99 |
double complex ccosh(double complex z); | Computes the complex hyperbolic cosine of z. | C99 |
float complex ccoshf(float complex z); | Computes the complex hyperbolic cosine of z. | C99 |
long double complex ccoshl(long double complex z); | Computes the complex hyperbolic cosine of z. | C99 |
double complex csinh(double complex z); | Computes the complex hyperbolic sine of z. | C99 |
float complex csinhf(float complex z); | Computes the complex hyperbolic sine of z. | C99 |
long double complex csinhl(long double complex z); | Computes the complex hyperbolic sine of z. | C99 |
double complex ctanh(double complex z); | Computes the complex hyperbolic tangent of z. | C99 |
float complex ctanhf(float complex z); | Computes the complex hyperbolic tangent of z. | C99 |
long double complex ctanhl(long double complex z); | Computes the complex hyperbolic tangent of z. | C99 |
Exponential and logarithmic functions
Below are a set of functions for computing the base-e exponent or logarithm of a complex number.
Function Prototype | Description | Since |
---|---|---|
double complex cexp(double complex z); | Computes the complex base-e exponential of z. | C99 |
float complex cexpf(float complex z); | Computes the complex base-e exponential of z. | C99 |
long double complex cexpl(long double complex z); | Computes the complex base-e exponential of z. | C99 |
double complex clog(double complex z); | Computes the complex natural (base-e) logarithm of z. | C99 |
float complex clogf(float complex z); | Computes the complex natural (base-e) logarithm of z. | C99 |
long double complex clogl(long double complex z); | Computes the complex natural (base-e) logarithm of z. | C99 |
Power and absolute-value functions
This category provides functions that can calculate the the absolute value, power, and square root of complex numbers.
Function Prototype | Description | Since |
---|---|---|
double cabs(double complex z); | Computes the complex absolute value of z. | C99 |
float cabsf(float complex z); | Computes the complex absolute value of z. | C99 |
long double cabsl(long double complex z); | Computes the complex absolute value of z. | C99 |
double complex cpow(double complex x, double complex y); | Computes the complex power function xy. | C99 |
float complex cpowf(float complex x, float complex y); | Computes the complex power function xy. | C99 |
long double complex cpowl(long double complex x, long double complex y); | Computes the complex power function xy. | C99 |
double complex csqrt(double complex z); | Computes the complex square root of z. | C99 |
float complex csqrtf(float complex z); | Computes the complex square root of z. | C99 |
long double complex csqrtl(long double complex z); | Computes the complex square root of z. | C99 |
Manipulation functions
The manipulation functions provide a way of accessing the imaginary or real part of a complex number as well as computing its projection and conjugate.
Function Prototype | Description | Since |
---|---|---|
double carg(double complex z); | Computes the phase angle of z. | C99 |
float cargf(float complex z); | Computes the phase angle of z. | C99 |
long double cargl(long double complex z); | Computes the phase angle of z. | C99 |
double cimag(double complex z); | Computes the imaginary part of z. | C99 |
float cimagf(float complex z); | Computes the imaginary part of z. | C99 |
long double cimagl(long double complex z); | Computes the imaginary part of z. | C99 |
double complex conj(double complex z); | Computes the complex conjugate of z. | C99 |
float complex conjf(float complex z); | Computes the complex conjugate of z. | C99 |
long double complex conjl(long double complex z); | Computes the complex conjugate of z. | C99 |
double complex cproj(double complex z); | Computes a projection of z onto the Riemann sphere. | C99 |
float complex cprojf(float complex z); | Computes a projection of z onto the Riemann sphere. | C99 |
long double complex cprojl(long double complex z); | Computes a projection of z onto the Riemann sphere. | C99 |
double creal(double complex z); | The creal functions compute the real part of z. | C99 |
float crealf(float complex z); | The creal functions compute the real part of z. | C99 |
long double creall(long double complex z); | The creal functions compute the real part of z. | C99 |