• 9
• 9
• 11
• 13
• 9

# Complex Numbers Lib C++

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

## 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 on other sites
#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";}