Creating Amplitude in C++.net

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2005
Posts: 5
Reputation: paladin4service is an unknown quantity at this point 
Solved Threads: 0
paladin4service paladin4service is offline Offline
Newbie Poster

Creating Amplitude in C++.net

 
0
  #1
Jul 12th, 2005
Hi!

I am new to this, and new to the programming. To be honest, it's not easy.

I am having this problem with doing Complex numbers. Basically, I have to write a program to show the Amplitude and Phase of a Complex object. First, because Amplitudes are usually absolute values, how do you write a absolute value equation in C++.net? Also, how do you show the phase?

Also, if anyone out there is a college student, or was a college student, maybe there is a better way to absorb this material. I read the book, but it tends to be too technical to understand. Anyone got any suggestions?
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,046
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: Creating Amplitude in C++.net

 
0
  #2
Jul 12th, 2005
From what I've read on Wikipedia, it looks like you want the magnitude and the argument of a complex number. Suppose the real part is stored in re and the imaginary part is stored in im (both doubles, presumably). Then

  1. double amplitude = sqrt( re * re + im * im);
  2. double phase = atan2( re, im);

Amplitude is the absolute value in the sense that it is the distance of the complex number from the origin.

What book is this?
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 76
Reputation: CrazyDieter is an unknown quantity at this point 
Solved Threads: 3
CrazyDieter's Avatar
CrazyDieter CrazyDieter is offline Offline
Junior Poster in Training

Re: Creating Amplitude in C++.net

 
0
  #3
Jul 12th, 2005
If you are coding in c++, The standard library provides a template class for complex numbers.

  1. #include <complex>
  2.  
  3. ...
  4.  
  5. complex<double> z1( 2.7, 3.4);
  6.  
  7. double phase=arg(z1);
  8. double magnitude=abs(z1);
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 5
Reputation: paladin4service is an unknown quantity at this point 
Solved Threads: 0
paladin4service paladin4service is offline Offline
Newbie Poster

Re: Creating Amplitude in C++.net

 
0
  #4
Jul 12th, 2005
Amplitude is the absolute value in the sense that it is the distance of the complex number from the origin.

What book is this?[/QUOTE]

The book we are using in class is called Visual C++.net by DEITEL. I think the book is ok, but it is hard to understand, maybe considering that I am not a programmer. Thanks for the assistance!!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC