Sign in to follow this  
johnnyBravo

c++, should I create my own Complex Numbers class?

Recommended Posts

I need to use complex numbers, and I've found that there is a std::complex class, but it doesn't have any sqrt function for it, so should I just create my own one, or is there a sqrt function for complex numbers hidden away somewhere in the std library? thx

Share this post


Link to post
Share on other sites
I think <complex> specialises std::sqrt() to work with it.

Remember the SC++L often uses free functions where some may expect member functions.

Even if it didn't instead of re-writing the entire class you could write a free function to compute the square root, much faster [smile]

Share this post


Link to post
Share on other sites
Why did you include <cmath>? Are you bringing the c standard lib sqrt into scope just so it can be ignored?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this