Complex Complex::operator/(Complex &op) { double cd = op.norm(); double realval = real*op.real + imag*op.imag; double imagval = imag*op.real - real*op.imag; return Complex(realval/cd, imagval/cd); }
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; }
Complex Complex::operator /=(const Complex &x){ double temp=x.norm(); if(temp!=0.0){ double oldRpart=rpart; rpart=(rpart*x.rpart+ipart*x.ipart)/temp; ipart=(ipart*x.rpart-oldRpart*x.ipart)/temp; } else{ cout<<"ERROR"<<endl; exit(1); } return *this; }
Complex operator/(const Complex& x1,const Complex& x2){ Complex x; double temp=x2.norm(); if(temp!=0.0){ x.rpart=(x1.rpart*x2.rpart+x2.ipart*x1.ipart)/temp; x.ipart=(x1.rpart*x2.ipart-x1.ipart*x2.rpart)/temp; return x; } else{ cout<<"x2 equals zero!"<<endl; exit(1); } }
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); }
void divdet(const Gauge_Field &U, Gauge_Field &U2){ Lattice_Vector x; int mu,site; Complex tmp; double r,theta,scale; site=0; while(loop_over_lattice(x,site)){ for(mu=0;mu<NUMLINK;mu++){ tmp=det(U.get(x,mu)); r=tmp.norm(); theta=atan(tmp.imag()/tmp.real()); scale=pow(r,(-1.0/NCOLOR)); theta=-1.0*theta/NCOLOR; tmp=scale*Complex(cos(theta),sin(theta)); U2.set(x,mu,tmp*U.get(x,mu)); }} return; }
int operator <=(const Complex& x1,const Complex& x2){ return x1.norm()<=x2.norm(); }
int operator >(const Complex& x1,const Complex& x2){ return x1.norm()>x2.norm(); }