<complex.h>

<complex.h>

[added with C99]


complex · _Complex_I · I · imaginary · _Imaginary_I

CX_LIMITED_RANGE

abs · acos · acosh · arg · asin · asinh · atan · atanh · cos · cosh · exp · fabs · imag · log · pow · real · sin · sinh · sqrt · tan · tanh

cabs · cacos · cacosh · carg · casin · casinh · catan · catanh · ccos · ccosh · cexp · cimag · clog · conj · cpow · cproj · creal · csin · csinh · csqrt · ctan · ctanh

cabsf · cacosf · cacoshf · cargf · casinf · casinhf · catanf · catanhf · ccosf · ccoshf · cexpf · cimagf · clogf · conjf · cpowf · cprojf · crealf · csinf · csinhf · csqrtf · ctanf · ctanhf

cabsl · cacosl · cacoshl · cargl · casinl · casinhl · catanl · catanhl · ccosl · ccoshl · cexpl · cimagl · clogl · conjl · cpowl · cprojl · creall · csinl · csinhl · csqrtl · ctanl · ctanhl


Include the standard header <complex.h> to define several macros and a host of functions for use with the three complex arithmetic types float _Complex, double _Complex, and long double _Complex. (If you include this header in a C++ program, these three types are effectively replaced by complex<float>, complex<double>, and complex<long double>, respectively.) Unless otherwise specified, functions that can return multiple values return an imaginary part in the half-open interval (-pi, pi].

The pragma:

#pragma STD CX_LIMITED_RANGE [ON|OFF|DEFAULT]

controls the behavior of complex multiply, divide, and magnitude. If the parameter is ON, the translator is permitted to use the conventional expressions:

(x + I * y) * (u + I * v) =
    (x * u - y * v) + I * (y * u + x * v)
(x + I * y) / (u + I * v) =
    ((x * u + y * v) + I * (y * u - x * v))
        / (u * u + v * v)
abs(x + I * y) = sqrt(x * x + y * y)

without regard to possible intermediate overflow. The parameter OFF has the same effect as DEFAULT; it restores the original state where such latitude is not permitted. If the pragma occurs outside an external declaration, it remains in effect until overridden by another such pragma. If the pragma occurs inside an external declaration, it must precede all explicit declarations and statements within a compound statement. It remains in effect until overridden by another such pragma or until the end of the compound statement.

Many of the functions declared in this header have additional overloads in C++, which behave much like the generic functions defined in <tgmath.h>. The following functions have such additional overloads:

acos     conj     pow
acosh    cos      real
arg      cosh     sin
asin     cproj    sinh
asinh    creal    sqrt
atan     exp      tan
atanh    fabs     tanh
carg     imag
cimag    log

        // MACROS
#define complex _Complex [not in C++]
#define _Complex_I (float _Complex){0, 1}
#define imaginary _Imaginary [optional]

#ifdef imaginary
 #define _Imaginary_I ((float _Imaginary)1)
#endif

#ifdef imaginary
 #define I _Imaginary_I
#else
 #define I _Complex_I
#endif

        // FUNCTIONS
double abs(double _Complex left); [C++ only]
float abs(float _Complex left); [C++ only]
long double abs(long double _Complex left); [C++ only]
double fabs(double _Complex left); [C++ only]
float fabs(float _Complex left); [C++ only]
long double fabs(long double _Complex left); [C++ only]
double cabs(double _Complex left);
float cabsf(float _Complex left);
long double cabsl(long double _Complex left);

double _Complex acos(double _Complex left); [C++ only]
float _Complex acos(float _Complex left); [C++ only]
long double _Complex acos(long double _Complex left); [C++ only]
double _Complex cacos(double _Complex left);
float _Complex cacosf(float _Complex left);
long double _Complex cacosl(long double _Complex left);

double _Complex acosh(double _Complex left); [C++ only]
float _Complex acosh(float _Complex left); [C++ only]
long double _Complex acosh(long double _Complex left); [C++ only]
double _Complex cacosh(double _Complex left);
float _Complex cacoshf(float _Complex left);
long double _Complex cacoshl(long double _Complex left);

double arg(double _Complex left); [C++ only]
float arg(float _Complex left); [C++ only]
long double arg(long double _Complex left); [C++ only]
double carg(double _Complex left);
float carg(float _Complex left); [C++ only]
long double carg(long double _Complex left); [C++ only]
float cargf(float _Complex left);
long double cargl(long double _Complex left);

double _Complex asin(double _Complex left); [C++ only]
float _Complex asin(float _Complex left); [C++ only]
long double _Complex asin(long double _Complex left); [C++ only]
double _Complex casin(double _Complex left);
float _Complex casinf(float _Complex left);
long double _Complex casinl(long double _Complex left);

double _Complex asinh(double _Complex left); [C++ only]
float _Complex asinh(float _Complex left); [C++ only]
long double _Complex asinh(long double _Complex left); [C++ only]
double _Complex casinh(double _Complex left);
float _Complex casinhf(float _Complex left);
long double _Complex casinhl(long double _Complex left);

double _Complex atan(double _Complex left); [C++ only]
float _Complex atan(float _Complex left); [C++ only]
long double _Complex atan(long double _Complex left); [C++ only]
double _Complex catan(double _Complex left);
float _Complex catanf(float _Complex left);
long double _Complex catanl(long double _Complex left);

double _Complex atanh(double _Complex left); [C++ only]
float _Complex atanh(float _Complex left); [C++ only]
long double _Complex atanh(long double _Complex left); [C++ only]
double _Complex catanh(double _Complex left);
float _Complex catanhf(float _Complex left);
long double _Complex catanhl(long double _Complex left);

double _Complex conj(double _Complex left);
float _Complex conj(float _Complex left); [C++ only]
long double _Complex conj(long double _Complex left); [C++ only]
float _Complex conjf(float _Complex left);
long double _Complex conjl(long double _Complex left);

double _Complex cos(double _Complex left); [C++ only]
float _Complex cos(float _Complex left); [C++ only]
long double _Complex cos(long double _Complex left); [C++ only]
double _Complex ccos(double _Complex left);
float _Complex ccosf(float _Complex left);
long double _Complex ccosl(long double _Complex left);

double _Complex cosh(double _Complex left); [C++ only]
float _Complex cosh(float _Complex left); [C++ only]
long double _Complex cosh(long double _Complex left); [C++ only]
double _Complex ccosh(double _Complex left);
float _Complex ccoshf(float _Complex left);
long double _Complex ccoshl(long double _Complex left);

double _Complex cproj(double _Complex left);
float _Complex cproj(float _Complex left); [C++ only]
long double _Complex cproj(long double _Complex left); [C++ only]
float _Complex cprojf(float _Complex left);
long double _Complex cprojl(long double _Complex left);

double _Complex exp(double _Complex left); [C++ only]
float _Complex exp(float _Complex left); [C++ only]
long double _Complex exp(long double _Complex left); [C++ only]
double _Complex cexp(double _Complex left);
float _Complex cexpf(float _Complex left);
long double _Complex cexpl(long double _Complex left);

double imag(double _Complex left); [C++ only]
float imag(float _Complex left); [C++ only]
long double imag(long double _Complex left); [C++ only]
double cimag(double _Complex left);
float cimag(float _Complex left); [C++ only]
long double cimag(long double _Complex left); [C++ only]
float cimagf(float _Complex left);
long double cimagl(long double _Complex left);

double _Complex log(double _Complex left); [C++ only]
float _Complex log(float _Complex left); [C++ only]
long double _Complex log(long double _Complex left); [C++ only]
double _Complex clog(double _Complex left);
float _Complex clogf(float _Complex left);
long double _Complex clogl(long double _Complex left);

double _Complex pow(double _Complex left, double _Complex right); [C++ only]
float _Complex pow(float _Complex left, float _Complex right); [C++ only]
long double _Complex pow(long double _Complex left, long double _Complex right); [C++ only]
double _Complex cpow(double _Complex left, double _Complex right);
float _Complex cpowf(float _Complex left, float _Complex right);
long double _Complex cpowl(long double _Complex left, long double _Complex right);

double real(double _Complex left); [C++ only]
float real(float _Complex left); [C++ only]
long double real(long double _Complex left); [C++ only]
double creal(double _Complex left);
float creal(float _Complex left); [C++ only]
long double creal(long double _Complex left); [C++ only]
float crealf(float _Complex left);
long double creall(long double _Complex left);

double _Complex sin(double _Complex left); [C++ only]
float _Complex sin(float _Complex left); [C++ only]
long double _Complex sin(long double _Complex left); [C++ only]
double _Complex csin(double _Complex left);
float _Complex csinf(float _Complex left);
long double _Complex csinl(long double _Complex left);

double _Complex sinh(double _Complex left); [C++ only]
float _Complex sinh(float _Complex left); [C++ only]
long double _Complex sinh(long double _Complex left); [C++ only]
double _Complex csinh(double _Complex left);
float _Complex csinhf(float _Complex left);
long double _Complex csinhl(long double _Complex left);

double _Complex sqrt(double _Complex left); [C++ only]
float _Complex sqrt(float _Complex left); [C++ only]
long double _Complex sqrt(long double _Complex left); [C++ only]
double _Complex csqrt(double _Complex left);
float _Complex csqrtf(float _Complex left);
long double _Complex csqrtl(long double _Complex left);

double _Complex tan(double _Complex left); [C++ only]
float _Complex tan(float _Complex left); [C++ only]
long double _Complex tan(long double _Complex left); [C++ only]
double _Complex ctan(double _Complex left);
float _Complex ctanf(float _Complex left);
long double _Complex ctanl(long double _Complex left);

double _Complex tanh(double _Complex left); [C++ only]
float _Complex tanh(float _Complex left); [C++ only]
long double _Complex tanh(long double _Complex left); [C++ only]
double _Complex ctanh(double _Complex left);
float _Complex ctanhf(float _Complex left);
long double _Complex ctanhl(long double _Complex left);

abs, fabs, cabs, cabsf, cabsl

double abs(double _Complex left); [C++ only]
float abs(float _Complex left); [C++ only]
long double abs(long double _Complex left); [C++ only]
double fabs(double _Complex left); [C++ only]
float fabs(float _Complex left); [C++ only]
long double fabs(long double _Complex left); [C++ only]
double cabs(double _Complex left);
float cabsf(float _Complex left);
long double cabsl(long double _Complex left);

The function returns the magnitude of left, |left|.

acos, cacos, cacosf, cacosl

double _Complex acos(double _Complex left); [C++ only]
float _Complex acos(float _Complex left); [C++ only]
long double _Complex acos(long double _Complex left); [C++ only]
double _Complex cacos(double _Complex left);
float _Complex cacosf(float _Complex left);
long double _Complex cacosl(long double _Complex left);

The function returns the arccosine of left.

acosh, cacosh, cacoshf, cacoshl

double _Complex acosh(double _Complex left); [C++ only]
float _Complex acosh(float _Complex left); [C++ only]
long double _Complex acosh(long double _Complex left); [C++ only]
double _Complex cacosh(double _Complex left);
float _Complex cacoshf(float _Complex left);
long double _Complex cacoshl(long double _Complex left);

The function returns the hyperbolic arccosine of left.

arg, carg, cargf, cargl

double arg(double _Complex left); [C++ only]
float arg(float _Complex left); [C++ only]
long double arg(long double _Complex left); [C++ only]
double carg(double _Complex left);
float carg(float _Complex left); [C++ only]
long double carg(long double _Complex left); [C++ only]
float cargf(float _Complex left);
long double cargl(long double _Complex left);

The function returns the phase angle of left.

asin, casin, casinf, casinl

double _Complex asin(double _Complex left); [C++ only]
float _Complex asin(float _Complex left); [C++ only]
long double _Complex asin(long double _Complex left); [C++ only]
double _Complex casin(double _Complex left);
float _Complex casinf(float _Complex left);
long double _Complex casinl(long double _Complex left);

The function returns the arcsine of left.

asinh, casinh, casinhf, casinhl

double _Complex asinh(double _Complex left); [C++ only]
float _Complex asinh(float _Complex left); [C++ only]
long double _Complex asinh(long double _Complex left); [C++ only]
double _Complex casinh(double _Complex left);
float _Complex casinhf(float _Complex left);
long double _Complex casinhl(long double _Complex left);

The function returns the hyperbolic arcsine of left.

atan, catan, catanf, catanl

double _Complex atan(double _Complex left); [C++ only]
float _Complex atan(float _Complex left); [C++ only]
long double _Complex atan(long double _Complex left); [C++ only]
double _Complex catan(double _Complex left);
float _Complex catanf(float _Complex left);
long double _Complex catanl(long double _Complex left);

The function returns the arctangent of left.

atanh, catanh, catanhf, catanhl

double _Complex atanh(double _Complex left); [C++ only]
float _Complex atanh(float _Complex left); [C++ only]
long double _Complex atanh(long double _Complex left); [C++ only]
double _Complex catanh(double _Complex left);
float _Complex catanhf(float _Complex left);
long double _Complex catanhl(long double _Complex left);

The function returns the hyperbolic arctangent of left.

complex

#define complex _Complex [not in C++]

The macro expands to the keyword _Complex.

_Complex_I

#define _Complex_I (float _Complex){0, 1}

The macro expands to an expression of type const float _Complex whose real component is zero and whose imaginary component is one.

conj, conjf, conjl

double _Complex conj(double _Complex left); [C++ only]
float _Complex conj(float _Complex left); [C++ only]
long double _Complex conj(long double _Complex left); [C++ only]
float _Complex conjf(float _Complex left);
long double _Complex conjl(long double _Complex left);

The function returns the conjugate of left.

cos, ccos, ccosf, ccosl

double _Complex cos(double _Complex left); [C++ only]
float _Complex cos(float _Complex left); [C++ only]
long double _Complex cos(long double _Complex left); [C++ only]
double _Complex ccos(double _Complex left);
float _Complex ccosf(float _Complex left);
long double _Complex ccosl(long double _Complex left);

The function returns the cosine of left.

cosh, ccosh, ccoshf, ccoshl

double _Complex cosh(double _Complex left); [C++ only]
float _Complex cosh(float _Complex left); [C++ only]
long double _Complex cosh(long double _Complex left); [C++ only]
double _Complex ccosh(double _Complex left);
float _Complex ccoshf(float _Complex left);
long double _Complex ccoshl(long double _Complex left);

The function returns the hyperbolic cosine of left.

cproj, cprojf, cprojl

double _Complex cproj(double _Complex left);
float _Complex cproj(float _Complex left); [C++ only]
long double _Complex cproj(long double _Complex left); [C++ only]
float _Complex cprojf(float _Complex left);
long double _Complex cprojl(long double _Complex left);

The function returns a projection of left onto the Riemann sphere. Specifically, if either component of left is an infinity of either sign, the function returns a value whose real part is positive infinity and whose imaginary part is zero with the same sign as the imaginary part of left. Otherwise, the function returns left.

exp, cexp, cexpf, cexpl

double _Complex exp(double _Complex left); [C++ only]
float _Complex exp(float _Complex left); [C++ only]
long double _Complex exp(long double _Complex left); [C++ only]
double _Complex cexp(double _Complex left);
float _Complex cexpf(float _Complex left);
long double _Complex cexpl(long double _Complex left);

The function returns the exponential of left.

I

#ifdef imaginary
 #define I _Imaginary_I
#else
 #define I _Complex_I
#endif

The macro expands to _Imaginary_I if imaginary is defined; otherwise it expands to _Complex_I.

imag, cimag, cimagf, cimagl

double imag(double _Complex left); [C++ only]
float imag(float _Complex left); [C++ only]
long double imag(long double _Complex left); [C++ only]
double cimag(double _Complex left);
float cimag(float _Complex left); [C++ only]
long double cimag(long double _Complex left); [C++ only]
float cimagf(float _Complex left);
long double cimagl(long double _Complex left);

The function returns the imaginary part of left.

imaginary

#define imaginary _Imaginary [optional]

The macro expands to the optional keyword _Imaginary, if that keyword is defined by the implementation.

_Imaginary_I

#ifdef imaginary
 #define _Imaginary_I ((float _Imaginary)1)
#endif

The macro expands to an expression of type const float _Imaginary) with value one, but only if imaginary is defined.

log, clog, clogf, clogl

double _Complex log(double _Complex left); [C++ only]
float _Complex log(float _Complex left); [C++ only]
long double _Complex log(long double _Complex left); [C++ only]
double _Complex clog(double _Complex left);
float _Complex clogf(float _Complex left);
long double _Complex clogl(long double _Complex left);

The function returns the logarithm of left. The branch cuts are along the negative real axis.

Note that in C++ clog is not defined in namespace std, to avoid collisions with the standard error logging stream object clog.

pow, cpow, cpowf, cpowl

double _Complex pow(double _Complex left, double _Complex right); [C++ only]
float _Complex pow(float _Complex left, float _Complex right); [C++ only]
long double _Complex pow(long double _Complex left, long double _Complex right); [C++ only]
double _Complex cpow(double _Complex left, double _Complex right);
float _Complex cpowf(float _Complex left, float _Complex right);
long double _Complex cpowl(long double _Complex left, long double _Complex right);

The function returns left to the power right, left^right. The branch cut for left is along the negative real axis.

real, creal, crealf, creall

double real(double _Complex left); [C++ only]
float real(float _Complex left); [C++ only]
long double real(long double _Complex left); [C++ only]
double creal(double _Complex left);
float creal(float _Complex left); [C++ only]
long double creal(long double _Complex left); [C++ only]
float crealf(float _Complex left);
long double creall(long double _Complex left);

The function returns the real part of left.

sin, csin, csinf, csinl

double _Complex sin(double _Complex left); [C++ only]
float _Complex sin(float _Complex left); [C++ only]
long double _Complex sin(long double _Complex left); [C++ only]
double _Complex csin(double _Complex left);
float _Complex csinf(float _Complex left);
long double _Complex csinl(long double _Complex left);

The function returns the sine of left.

sinh, csinh, csinhf, csinhl

double _Complex sinh(double _Complex left); [C++ only]
float _Complex sinh(float _Complex left); [C++ only]
long double _Complex sinh(long double _Complex left); [C++ only]
double _Complex csinh(double _Complex left);
float _Complex csinhf(float _Complex left);
long double _Complex csinhl(long double _Complex left);

The function returns the hyperbolic sine of left.

sqrt, csqrt, csqrtf, csqrtl

double _Complex sqrt(double _Complex left); [C++ only]
float _Complex sqrt(float _Complex left); [C++ only]
long double _Complex sqrt(long double _Complex left); [C++ only]
double _Complex csqrt(double _Complex left);
float _Complex csqrtf(float _Complex left);
long double _Complex csqrtl(long double _Complex left);

The function returns the square root of left, left^(1/2), with phase angle in the half-open interval (-pi/2, pi/2]. The branch cuts are along the negative real axis.

tan, ctan, ctanf, ctanl

double _Complex tan(double _Complex left); [C++ only]
float _Complex tan(float _Complex left); [C++ only]
long double _Complex tan(long double _Complex left); [C++ only]
double _Complex ctan(double _Complex left);
float _Complex ctanf(float _Complex left);
long double _Complex ctanl(long double _Complex left);

The function returns the tangent of left.

tanh, ctanh, ctanhf, ctanhl

double _Complex tanh(double _Complex left); [C++ only]
float _Complex tanh(float _Complex left); [C++ only]
long double _Complex tanh(long double _Complex left); [C++ only]
double _Complex ctanh(double _Complex left);
float _Complex ctanhf(float _Complex left);
long double _Complex ctanhl(long double _Complex left);

The function returns the hyperbolic tangent of left.


See also the Table of Contents and the Index.

Copyright © 1992-2006 by P.J. Plauger. All rights reserved.

Last modified: 2013-12-21



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus