complex

complex - /* */ @file complex.cpp @author Randall Paul...

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

View Full Document Right Arrow Icon
/** @file complex.cpp @author Randall Paul Robert (9771) @date 2005-10-01 Description: implementation for the complex class Course: CS1254.02 Logon ID: cs125456 Lab #: 2 Instructor: William Duncan */ #include <cmath> #include <cstdlib> #include <math.h> #include "complex.h" /* SOME FUNCTION HAVE BEEN IMPLEMENTED FOR YOU. IMPLEMENT ALL OTHER FUNCTIONS DESCRIBED ON THE LAB HANDOUT. */ Complex::Complex() { real = 0.0; imag = 0.0; } Complex::Complex(double r) { real = r; imag = 0; } Complex::Complex(double r, double i) { real = r; imag = i; } double Complex::getReal() const { return real; } double Complex::getImag() const { return imag; } Complex Complex::conjugate() const { Complex z; z.real = real; z.imag = -imag; return z; } double Complex::magnitude() const {
Background image of page 1

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

View Full DocumentRight Arrow Icon
Complex z; double rad, mag, rmag, immag; z.real = real; z.imag = imag; rmag = ((z.real)*(z.real)); immag = ((z.imag)*(z.imag)); rad = rmag + immag; mag = sqrt(rad); return mag; } double Complex::angle() { Complex z; double degree;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

complex - /* */ @file complex.cpp @author Randall Paul...

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

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