I am coding a simple DFT algorithm now and I want to use the complex number i in complex exponential. I saw somebody use #include<complex>
and #include<cmath>
, and then they used the overloaded symbol I
such as exp(2*I)
. But it seems it doesn't work in my visual studio compiler. So, can anyone give a simple example of using complex exponential? Thanks!
I get this question recently as well and find a easy way for future reader:
Just use <complex>
library like the following
#include <iostream>
#include <complex>
using namespace std ;
int main(int argc, char* argv[])
{
const complex<double> i(0.0,1.0);
cout << i << endl ;
return(0) ;
}