• Advertisement
Sign in to follow this  

Complex Numbers Lib C++

This topic is 3294 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I'm using Visual C++ 2008 Express but it seems it doesn't come with a built-in complex number lib. Can anyone recommend a free, simple-to-use yet powerful complex number library I can use? Ideally operator overloaded (Z1 + Z2 etc) but anything will be considered. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
#include <complex>

Example

#include <iostream>
#include <complex>
using namespace std;

typedef complex<double> dcmplx;

int main(){

dcmplx a(5.,6.),b;

cout << "Enter b: ";
cin >> b;

cout << "a = " << a << "\n";
cout << "b = " << b << "\n";

cout << "a + b = " << a + b << "\n";
cout << "a * b = " << a * b << "\n";
cout << "a / b = " << a / b << "\n";
cout << "|a| = " << abs(a) << "\n";
cout << "complex conjugate of a = " << conj(a) << "\n";
cout << "norm of a = " << norm(a) << "\n";
cout << "abs of a = " << abs(a) << "\n";
cout << "exp(a) = " << exp(a) << "\n";
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement