


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Out: 9/ Due: 9/29 by 11:50 PM Maximum possible points: 25
Definition 1. The complex numbers are the field C of numbers of the form x + iy, where x and y are real numbers and i is the imaginary unit equal to the square root of -1,
−1. Very often a complex number is represented by a single letter, z = x + iy. z may also be associated with a point in a plane by using the rectangular coordinates (x, y).
Definition 2. The complex conjugate of a complex number z = x + iy is defined to be ¯z ≡ x − iy.
Definition 3.√ The modulus of a complex number z = x + iy is |z| = x^2 + y^2. The set of all complex numbers is referred to as ”Complex,” and is usually denoted C. In this lab, you will complete a simple complex number ADT. We will ignore some of the inefficiencies but in a subsequent lab, we will modify the lab and add some enhancements. But for now, we will live with the inefficiencies. We will use the rectangular coordinates representation as described above. The class Complex consists of two member variables: real, the real part, and imag, the imaginary part. In your mathematical sojourn you have had countless opportunities to toy around with scalar quantities. Scalar numbers are the kind of numbers
that represent only the magnitude of a quantity. For example, the voltage produced by a battery is a scalar quantity. The resistance of a conductor (ohms), or the current through it (amps). This applies only to direct current (DC) circuits. In alternating current (AC) circuits, as you have already seen or will see, quantities such as voltage, current, and resistance (termed impedance in AC circuits) are two-dimensional quantities because they are alternating in direction and amplitude. Thus they can only be adequately modeled using two dimensions. Frequency and phase shift are two dimensions that are considered when measuring these quantities. Your goal in this project is to write the interface and implementation for the complex number class. The public interface for the complex number class should provide the following member functions:
a. Complex() : the default constructor sets both real and imag, pri- vate member variables, to 0. The default constructor is imple- mented for you. b. Complex(double r) : the second constructor sets real to r, the double, and imag to 0. c. Complex(double r, double i) : the third constructor sets real to r and imag to i.
a. getReal(): this function returns the real part of the complex num- ber. This member function has been implemented for you. b. getImag() : this function returns the imaginary part of the com- plex number.
Copy the following files from the class directory: complex.h, complex.cpp and complextest.cpp. I have also included cmplexexe a working version of the lab. You may copy this file and run it to have a feel for how I expect the program to work when you are done. You will write your own makefile in this lab. Copy the makefile from the previous project and tweak it. Compile your program with your makefile until it works properly. Once you are satisfied that your program properly compiles and is error-free, submit your work. Name your executable file complex; that is, set the EXE variable in your makefile to complex. You may submit your work as many times as you wish once the due time has not elapsed. After the due time, any further submission will mean that you get no points for the lab.
/**