G.6 Complex arithmetic <complex.h>

1

The macros

imaginary

and

_Imaginary_I

are defined, respectively, as _Imaginary and a constant expression of type const float _Imaginary with the value of the imaginary unit. The macro

I

is defined to be _Imaginary_I (not _Complex_I as stated in 7.3). Notwithstanding the provisions of 7.1.3, a program may undefine and then perhaps redefine the macro imaginary.

2

This subclause contains specifications for the <complex.h> functions that are particularly suited to IEC 60559 implementations. For families of functions, the specifications apply to all of the functions even though only the principal function is shown. Unless otherwise specified, where the symbol ‘’(+-)’’ occurs in both an argument and the result, the result has the same sign as the argument.

3

The functions are continuous onto both sides of their branch cuts, taking into account the sign of zero. For example, csqrt(-2 (+-) i0) = (+-)i(sqrt)(2).

4

Since complex and imaginary values are composed of real values, each function may be regarded as computing real values from real values. Except as noted, the functions treat real infinities, NaNs, signed zeros, subnormals, and the floating-point exception flags in a manner consistent with the specifications for real functions in F.9.[1]

5

The functions cimag, conj, cproj, and creal are fully specified for all implementations, including IEC 60559 ones, in 7.3.9. These functions raise no floating- point exceptions.

6

Each of the functions cabs and carg is specified by a formula in terms of a real function (whose special cases are covered in annex F):

cabs(x + iy) = hypot(x, y)
carg(x + iy) = atan2(y, x)

7

Each of the functions casin, catan, ccos, csin, and ctan is specified implicitly by a formula in terms of other complex functions (whose special cases are specified below):

casin(z)        =   -i casinh(iz)
catan(z)        =   -i catanh(iz)
ccos(z)         =   ccosh(iz)
csin(z)         =   -i csinh(iz)
ctan(z)         =   -i ctanh(iz)

8

For the other functions, the following subclauses specify behavior for special cases, including treatment of the “invalid” and “divide-by-zero” floating-point exceptions. For families of functions, the specifications apply to all of the functions even though only the principal function is shown. For a function f satisfying f (conj(z)) = conj( f (z)), the specifications for the upper half-plane imply the specifications for the lower half-plane; if the function f is also either even, f (-z) = f (z), or odd, f (-z) = - f (z), then the specifications for the first quadrant imply the specifications for the other three quadrants.

9

In the following subclauses, cis(y) is defined as cos(y) + i sin(y).

Footnotes