#include #include "Complex.h" constexpr double PI = 3.14159265358979323846; void Complex::roots(int n, Complex* root) const { double r = abs(); r = pow(r, 1./double(n)); double theta = arg()/double(n); Complex z = Complex::polar(r, theta); root[0] = z; Complex unitRoot = Complex::polar(1., 2.*PI/double(n)); for (int i = 1; i < n; ++i) { root[i] = root[i-1]*unitRoot; } }