Jump to content
  • Advertisement
Sign in to follow this  
CzarKirk

Complex Numbers Lib C++

This topic is 3471 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!