40 #ifndef __EST_COMPLEX_H__ 41 #define __EST_COMPLEX_H__ 48 #define PI 3.14159265358979323846 75 {
return(sqrt(r*r+i*i)); }
78 double ang(
int degrees=0)
const {
80 if ( r == 0. && i == 0. ) a = 0.0;
81 else if ( r >= 0. ) a = atan(i/r);
82 else if ( i >= 0. ) a = atan(i/r) +
PI;
83 else a = atan(i/r) -
PI;
84 return (degrees == 1) ? (a * 180 /
PI) : a;
107 { s << a.r <<
" " << a.i;
return s;}
friend EST_Complex operator/(const EST_Complex &z1, const EST_Complex &z2)
A class for complex numbers.
friend EST_Complex operator*(const EST_Complex &z1, const EST_Complex &z2)
friend std::ostream & operator<<(std::ostream &s, const EST_Complex &a)
friend EST_Complex operator+(const EST_Complex &z1, const EST_Complex &z2)
double & real()
The real part - can be used for reading or writing.
double ang(int degrees=0) const
Polar angle, read only.
EST_Complex(double real, double imag)
Constructor initialising real and imaginary parts.
double & imag()
The imaginary part - can be used for reading or writing.
friend EST_Complex operator-(const EST_Complex &z1, const EST_Complex &z2)
double mag() const
Polar magnitude, read only.
EST_Complex()
default constructor, initialises values to 0.0