+=, -=, *=, 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);Return the conjugate, real part, imaginary part, or absolute value, respectively.
double real(const Complex& arg);
double imag(const Complex& arg);
double abs(const Complex& arg);
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);Standard mathematical functions.
Complex cos(const Complex& arg);
Complex exp(const Complex& arg);
Complex log(const Complex& arg);
Complex sqrt(const Complex& arg);
log returns the principal logarithm.
Complex pow(double base,const Complex& expon);Raise base to expon power. There is also an operator to print a Complex on an ostream.
xpon);
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 ();The default constructor produces a fraction with numerator 0 and denominator 1. The other constructor allows the numerator and denominator to be specified arbitrarily.
Fraction (int num, int den=1);
int num() const;Return the numerator or denominator.
int den() const;
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.