c++complex-numbers

How to use complex numbers in c++?


How can I use a complex variable in C++ code?

I do have the separate real and imaginary parts psi_rl and psi_im. Now I have to write psi = psi_rl + i psi_im. How would I use one variable for this?


Solution

  • You should read the documentation for std::complex, it will give you answers to these questions and many more.