// Principal log Complex log(const Complex & a) { double theta = a.arg(); if ((theta / PI) > 1.0 || (theta / PI) < -1.0) { theta = theta - floor(theta / PI) * PI; } Complex temp(log(a.mod()), a.arg()); return temp; }
bool Complex::setLog (const Complex& z, int n) { Real mag = z.norm(); if(mag == 0.0) return false; x = Log(mag); y = z.arg() + Two*Pi*n; return true; }
void Complex::setPow (const Complex& z, Real n) { Real mag = z.norm(); Real theta = z.arg(); Real cntheta = Cos(n*theta); Real sntheta = Sin(n*theta); Real powm = Pow(mag, n); x = powm * cntheta; y = powm * sntheta; }
void Complex::setPow (const Complex& z, const Complex& w) { Real mag = z.norm(); Real theta = z.arg(); Real powm = Pow(mag,w.x); Real expt = Exp(-w.y*theta); Real phi = w.x*theta; if(w.y != 0) { Assert(mag != Zero); phi += w.y*Log(mag); } x = powm*expt*Cos(phi); y = powm*expt*Sin(phi); }