/* File: complex.C Copyright 4/30/97 */ inline ostream& operator<<(ostream& os, const Complex& z) { os << z.real << " " << z.imag; return os; } inline Complex operator+(const Complex& z1, const Complex& z2) { return Complex(z1.real + z2.real, z1.imag + z2.imag); } inline Complex operator+=(Complex& z1, const Complex& z2) { z1.real += z2.real; z1.imag += z2.imag; return z1; } inline Complex operator-(const Complex& z1, const Complex& z2) { return Complex(z1.real - z2.real, z1.imag - z2.imag); } inline Complex operator-=(Complex& z1, const Complex& z2) { z1.real -= z2.real; z1.imag -= z2.imag; return z1; } inline Complex operator*(const Complex& z1, const Complex& z2) { return Complex(z1.real * z2.real - z1.imag * z2.imag, z1.real * z2.imag + z1.imag * z2.real); } inline Complex operator*=(Complex& z1, const Complex& z2) { z1.real = z1.real * z2.real - z1.imag * z2.imag; z1.imag = z1.real * z2.imag + z1.imag * z2.real; return z1; } inline Complex operator/(const Complex& z1, const Complex& z2) { float temp = z2.real * z2.real + z2.imag * z2.imag; return Complex((z1.real * z2.real + z1.imag * z2.imag) / temp, (z1.imag * z2.real - z1.real * z2.imag) / temp); } inline Complex operator/=(Complex& z1, const Complex& z2) { float temp = z2.real * z2.real + z2.imag * z2.imag; z1.real = (z1.real * z2.real + z1.imag * z2.imag) / temp; z1.imag = (z1.imag * z2.real - z1.real * z2.imag) / temp; return z1; } inline Complex operator!(const Complex& z) { return Complex(z.real, -z.imag); }