I am currently writing a small tool which should help me check whether my manually calculated fourier vectors are correct. Now i need the n-th Root of Unity specified by omega = exp(2*pi*i / n)
. Can somebody explain me how to represent this omega
as a complex
in C++?
Use Euler's formula:
exp(2πi/n) = cos(2π/n) + i sin(2π/n)
Then it's easy:
complex<double> rootOfUnity(cos(TWOPI/n), sin(TWOPI/n));
(replace TWOPI with either a macro available on your system or just the value of 2π however you see fit).