Complex = {
function Complex(re, im) { this.re = re; this.im = im; };
Complex.prototype.clone = function(){ return new Complex(this.re,this.im); };
Complex.prototype.conj = function(){ return new Complex(this.re,-this.im); };
Complex.prototype.add = function(z) { this.re += z.re; this.im += z.im; return this; };
Complex.prototype.sub = function(z) { this.re -= z.re; this.im -= z.im; return this; };
Complex.prototype.mul = function(z)
{
var tmp = this.re;
this.re = this.re*z.re - this.im*z.im;
this.im = tmp*z.im + this.im*z.re;
return this;
};
Complex.prototype.div = function(z){
var tmp = this.re,
n = z.re*z.re + z.im*z.im;
this.re = (this.re*z.re + this.im*z.im)/n;
this.im = ( -tmp*z.im + this.im*z.re)/n;
return this;
};
return Complex;
}