/*     */ package DFT;
/*     */ 
/*     */ 
/*     */ 
/*     */ public class Complex
/*     */ {
/*     */   private float R;
/*     */   
/*     */ 
/*     */   private float I;
/*     */   
/*     */ 
/*     */   public Complex()
/*     */   {
/*  15 */     this.R = 0.0F;
/*  16 */     this.I = 0.0F;
/*     */   }
/*     */   
/*     */ 
/*     */   public Complex(float r, float i)
/*     */   {
/*  22 */     this.R = r;
/*  23 */     this.I = i;
/*     */   }
/*     */   
/*     */ 
/*     */   public Complex(Phasor ph)
/*     */   {
/*  29 */     this.R = ph.cx().R;
/*  30 */     this.I = ph.cx().I;
/*     */   }
/*     */   
/*     */ 
/*  34 */   public void real(float r) { this.R = r; }
/*     */   
/*  36 */   public float real() { return this.R; }
/*     */   
/*     */ 
/*  39 */   public void imag(float i) { this.I = i; }
/*     */   
/*  41 */   public float imag() { return this.I; }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public float mag()
/*     */   {
/*  59 */     float Mag = (float)Math.sqrt(this.R * this.R + this.I * this.I);
/*  60 */     return Mag;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public float angle()
/*     */   {
/*  77 */     float Angle = (float)Math.atan(this.I / this.R);
/*     */     
/*  79 */     Angle = Angle * 180.0F / 3.1415927F;
/*     */     
/*  81 */     return Angle;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Phasor phase()
/*     */   {
/*  88 */     Phasor ph = new Phasor(mag(), angle());
/*  89 */     return ph;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Complex add(Complex rhs)
/*     */   {
/*  99 */     float newR = this.R + rhs.R;
/* 100 */     float newI = this.I + rhs.I;
/*     */     
/* 102 */     Complex C = new Complex(newR, newI);
/* 103 */     return C;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Complex sub(Complex rhs)
/*     */   {
/* 112 */     float newR = this.R - rhs.R;
/* 113 */     float newI = this.I - rhs.I;
/*     */     
/* 115 */     Complex C = new Complex(newR, newI);
/* 116 */     return C;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Complex mult(Complex rhs)
/*     */   {
/* 123 */     float newR = this.R * rhs.R - this.I * rhs.I;
/* 124 */     float newI = this.R * rhs.I + rhs.R * this.I;
/*     */     
/* 126 */     Complex C = new Complex(newR, newI);
/* 127 */     return C;
/*     */   }
/*     */   
/*     */ 
/*     */   public Complex mult(float rhs)
/*     */   {
/* 133 */     float newR = this.R * rhs;
/* 134 */     float newI = rhs * this.I;
/*     */     
/* 136 */     Complex C = new Complex(newR, newI);
/* 137 */     return C;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Complex div(Complex divisor)
/*     */   {
/* 144 */     float R2 = divisor.R;
/* 145 */     float I2 = divisor.I;
/*     */     
/*     */ 
/*     */ 
/* 149 */     float div = R2 * R2 + I2 * I2;
/*     */     
/* 151 */     float newR = (this.R * R2 + this.I * I2) / div;
/* 152 */     float newI = (R2 * this.I - this.R * I2) / div;
/*     */     
/* 154 */     Complex C = new Complex(newR, newI);
/* 155 */     return C;
/*     */   }
/*     */   
/*     */ 
/*     */   public Complex div(float divisor)
/*     */   {
/* 161 */     float R2 = divisor;
/* 162 */     float I2 = 0.0F;
/*     */     
/*     */ 
/*     */ 
/* 166 */     float div = R2 * R2;
/*     */     
/* 168 */     float newR = this.R * R2 / div;
/* 169 */     float newI = R2 * this.I / div;
/*     */     
/* 171 */     Complex C = new Complex(newR, newI);
/* 172 */     return C;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public boolean eq(Complex rhs)
/*     */   {
/* 179 */     return (this.R == rhs.R) && (this.I == rhs.I);
/*     */   }
/*     */ }


/* Location:              F:\JAVA\WORKSPACE\chronoEditor_v2.3.jar!\DFT\Complex.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */