complex_1onPage

# complex_1onPage - #ifndef_COMPLEX_H'cfw Send errors to...

This preview shows pages 1–3. Sign up to view the full content.

#ifndef __COMPLEX_H__ // '{‘, Send errors to Yechiel Kimchi (June 1998) #define __COMPLEX_H__ // No multiple inclusion #include <iostream.h> #include <math.h> // An example of building a simple class (complex) // A better one will be a template, see // t2: /usr/local/gcc/lib/g++-include/std/complext.h // csd: /usr/local/lib/g++-include/std/complext.h // More sophisticated floating-point arithmetic will use EPSILON // though for NICE_PRINT I do have to use epsilons of size .1E+k class complex { double re, im; static bool equal(double object, double other, int); void im_print(ostream& os) const; ostream& stnd_print(ostream& os) const; ostream& gnrl_print(ostream& os) const; public: // Constructor (0 - 2 arguments) complex(double x = 0, double y = 0): re(x), im(y) {} Complex.h

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
// Extracting basic data double real() const { return re;} double imag() const { return im;} // Simple manipulations (unary functions) double rsq() const { return re*re + im*im;} // r^2 ; i.e, norm-square double abs() const { return sqrt(rsq());} double arg() const { return atan2(im,re);} // atan2(0,0) is 0 complex
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 8

complex_1onPage - #ifndef_COMPLEX_H'cfw Send errors to...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online