Introduction to Systems Programming

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

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

ז ' סשת ןושח " ט 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

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

View Full Document
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
Ask a homework question - tutors are online