[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## D.2 `complex`

Complex numbers are represented according to the ISO C standard as arrays of two IEEE double precision floating point numbers of 8 bytes each, with the number representing the real part first.

A small selection of operations on complex numbers is available by function calls of the form `library('complex',f)`. These functions are implemented by the host system’s C library.

One example is `library('complex','create')` which takes a pair of floating point numbers `(x,y)` to a complex number whose real part is x and whose imaginary part is y. See `math` for information about constructing floating point numbers.

Other than that, the `complex` library functions `f` fall into three main groups, which are the real valued unary operations, the complex valued unary operations, and the complex valued binary operations. All of these operations are designated by their standard C names as documented elsewhere, such as the GNU `libc` reference manual, except as noted.

• real valued unary operations

      creal  cimag  cabs  carg

• complex valued unary operations

      ccos   cexp    clog   conj   csin    csqrt
      ctan   csinh   ccosh  ctanh  casinh  cacosh
      catanh casin   cacos  catan

• complex valued binary operations

      cpow  vid  bus  mul  add  sub  div

The last four correspond to the C language operators `*`, `+`, `-`, and `/` for complex numbers. The functions named `vid` and `bus` are similar to `div` and `sub`, respectively, but with the operands interchanged. That is,

    library('complex','vid') (x,y)

is equivalent to

    library('complex','div') (y,x)

All functions in this library taking complex numbers as input may also operate on real numbers, and binary operators can have either or both operands real. For real operands, a value of zero is inferred as the imaginary part. The result type of the function is the same regardless.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated on November 8, 2012 using texi2html 1.82.