Class Complex is a simple subset of functions provided in the Gnu and AT&T complex classes. The standard arithmetic operators are implemented, as are the assignment arithmetic operators `+=,`

`-=,`

`*=,`

and `/=,`

and equality and inequality operators `==`

and `!=.`

There is also `real()`

and `imag()`

methods for accessing real and imaginary parts. It was originally written when libg++ was subject to the GPL. The current licensing for libg++ does not prevent us from using it and still distributing Ptolemy the way we want, but having it makes ports to other compilers (e.g. cfront) easier. The following non-member functions take Complex arguments:

Complex conj(const Complex& arg);

double real(const Complex& arg);

double imag(const Complex& arg);

double abs(const Complex& arg);

Return the conjugate, real part, imaginary part, or absolute value, respectively.

double arg(const Complex& arg);

Return the angle between the X axis and the vector made by the argument. The expression

`abs(z)*exp(Complex(0.,1.)*arg(z))`

is in theory always equal to z.

double norm(const Complex& arg);

return the absolute value squared.

Complex sin(const Complex& arg);

Complex cos(const Complex& arg);

Complex exp(const Complex& arg);

Complex log(const Complex& arg);

Complex sqrt(const Complex& arg);

Standard mathematical functions. `log`

returns the principal logarithm.

Complex pow(double base,const Complex& expon);

xpon);

Raise base to expon power. There is also an operator to print a Complex on an ostream.

Class Fraction represents fractions. The header `Fraction.h`

also provides declarations for the `lcm`

(least common multiple) and `gcd`

(greatest common divisor) functions, as these functions are needed for Fraction but are generally useful.

Fraction ();

Fraction (int num, int den=1);

The default constructor produces a fraction with numerator 0 and denominator 1. The other constructor allows the numerator and denominator to be specified arbitrarily.

int num() const;

int den() const;

Return the numerator or denominator.

operator double() const;

Return the value of the fraction as a double. Class Fraction implements the basic binary math operators `+,`

`-,`

`*,`

`/;`

the assignment operators `=,`

`+=,`

`-=,`

`*=,`

and `/=,`

and the equality test operators `==`

and `!=.`

The method

Fraction& simplify();

reduces the fraction to lowest terms, and returns a reference to the fraction. There is also an operator to print a Fraction on an ostream.

*Copyright © 1990-1997, University of California. All rights
reserved.*