Introduction to Systems Programming

Introduction to Systems Programming - ' " Complex.h /...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
ז ' סשת ןושח " ט 1 #ifndef __COMPLEX_H__ // '{‘, Send errors to Yechiel Kimchi (June 1998) #define __COMPLEX_H__ // No multiple inclusion [email protected] #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 // 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/14/2011 for the course CS 234122 taught by Professor Gillbarequet during the Spring '11 term at Technion.

Page1 / 2

Introduction to Systems Programming - ' " Complex.h /...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online