Util is a collection of miscellaneous utility functions, only the complex variable and random variabler utilities are described here.

Complex numbers are represented as structures

typedef struct tcomplex { Ts_id ts_id; /* Tina structure identifier */ double x; double y; } Complex;

The internal structure should not be used. The real and imaginary parts of a complex should be got and set using statements like:

cmplx_re(z) = x; y = cmplx_im(z);

(this is allowed since cmplx_re() and cmplx_im() are macros).

A complex number with given components can be constructed using

i = cmplx(0.0, 1.0);

and operations on complex numbers are implemented as functions, e.g.

w = z/(z+2+3i)

translates as

w = cmplx_div(z, cmplx_sum(z, cmplx(2.0, 3.0)));

The random number generators all call the C-library function random() and can be seeded with

srandom(int seed)

if desired. Functions are provided for returning random bits, uniform random integers, and uniform and gaussian real variables. A function for return confidences in chi square variables is included.