40 #ifndef __EST_COMPLEX_H__
41 #define __EST_COMPLEX_H__
49 #define PI 3.14159265358979323846
71 { r = real; i = imag;}
76 {
return(sqrt(r*r+i*i)); }
79 double ang(
int degrees=0)
const {
81 if ( r == 0. && i == 0. ) a = 0.0;
82 else if ( r >= 0. ) a = atan(i/r);
83 else if ( i >= 0. ) a = atan(i/r) + PI;
84 else a = atan(i/r) - PI;
85 return (degrees == 1) ? (a * 180 / PI) : a;
107 friend ostream& operator<< (ostream& s,
const EST_Complex& a)
108 { s << a.r <<
" " << a.i;
return s;}
A class for complex numbers.
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.
double mag() const
Polar magnitude, read only.
EST_Complex()
default constructor, initialises values to 0.0