package smith_abagi;

/*     */ import java.io.Serializable;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public final class Complex
/*     */   implements Cloneable, Serializable
/*     */ {
/*     */   private double u;
/*     */   private double v;
/*     */   public static final int CARTESIAN = 0;
/*     */   public static final int POLAR_DEGREE = 1;
/*     */   public static final int POLAR_RADIAN = 2;
/*     */   
/*     */   public Complex(double x, double y)
/*     */   {
/*  23 */     u = x;
/*  24 */     v = y;
/*     */   }
/*     */   
/*     */   public Complex() {
/*  28 */     this(0.0D, 0.0D);
/*     */   }
/*     */   
/*     */   public Object clone() {
/*     */     try {
/*  33 */       Complex ZZ = new Complex();
/*  34 */       ZZ.setReal(u);
/*  35 */       ZZ.setImaginary(v);
/*  36 */       return ZZ;
/*     */     }
/*     */     catch (Exception e) {}
/*  39 */     return null;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void Conjugate()
/*     */   {
/*  49 */     u = u;
/*  50 */     v = (-v);
/*     */   }
/*     */   
/*     */   public static final Complex Conjugate(Complex z)
/*     */   {
/*  55 */     Complex mytmp = new Complex(z.Real(), -z.Imaginary());
/*  56 */     return mytmp;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public double Real()
/*     */   {
/*  66 */     return u;
/*     */   }
/*     */   
/*     */   public static final double Real(Complex z) {
/*  70 */     return z.Real();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public double Imaginary()
/*     */   {
/*  80 */     return v;
/*     */   }
/*     */   
/*     */   public static final double Imaginary(Complex z) {
/*  84 */     return z.Imaginary();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public double Magnitude()
/*     */   {
/*  94 */     return Math.sqrt(u * u + v * v);
/*     */   }
/*     */   
/*     */   public static final double Magnitude(Complex z) {
/*  98 */     return z.Magnitude();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public double Magnitude2()
/*     */   {
/* 107 */     return u * u + v * v;
/*     */   }
/*     */   
/*     */   public static final double Magnitude2(Complex z) {
/* 111 */     return z.Magnitude2();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public double Arg1()
/*     */   {
/* 120 */     return Math.atan(v / u);
/*     */   }
/*     */   
/*     */   public static final double Arg1(Complex z)
/*     */   {
/* 125 */     return z.Arg1();
/*     */   }
/*     */   
/*     */   public double Arg1(int tipo) {
/* 129 */     if (tipo == 1) {
/* 130 */       return Arg1() * 180.0D / 3.141592653589793D;
/*     */     }
/*     */     
/* 133 */     return Arg1();
/*     */   }
/*     */   
/*     */   public static final double Arg1(Complex z, int tipo)
/*     */   {
/* 138 */     if (tipo == 1) {
/* 139 */       return Arg1(z) * 180.0D / 3.141592653589793D;
/*     */     }
/*     */     
/* 142 */     return Arg1(z);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public double Arg2()
/*     */   {
/* 153 */     return Math.atan2(v, u);
/*     */   }
/*     */   
/*     */   public static final double Arg2(Complex z)
/*     */   {
/* 158 */     return z.Arg2();
/*     */   }
/*     */   
/*     */   public double Arg2(int tipo) {
/* 162 */     if (tipo == 1) {
/* 163 */       return Arg2() * 180.0D / 3.141592653589793D;
/*     */     }
/*     */     
/* 166 */     return Arg2();
/*     */   }
/*     */   
/*     */   public static final double Arg2(Complex z, int tipo)
/*     */   {
/* 171 */     if (tipo == 1) {
/* 172 */       return z.Arg2() * 180.0D / 3.141592653589793D;
/*     */     }
/*     */     
/* 175 */     return z.Arg2();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void Add(Complex z)
/*     */   {
/* 185 */     u += u;
/* 186 */     v += v;
/*     */   }
/*     */   
/*     */   public static final Complex Add(Complex z1, Complex z2) {
/* 190 */     Complex tmp = (Complex)z1.clone();
/* 191 */     tmp.Add(z2);
/* 192 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void Add(double x)
/*     */   {
/* 202 */     u += x;
/*     */   }
/*     */   
/*     */   public static final Complex Add(Complex z, double x) {
/* 206 */     Complex tmp = (Complex)z.clone();
/* 207 */     tmp.Add(x);
/* 208 */     return tmp;
/*     */   }
/*     */   
/*     */   public static final Complex Add(double x, Complex z) {
/* 212 */     return Add(z, x);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void Subtract(Complex z)
/*     */   {
/* 222 */     u -= u;
/* 223 */     v -= v;
/*     */   }
/*     */   
/*     */ 
/*     */   public static final Complex Subtract(Complex z1, Complex z2)
/*     */   {
/* 229 */     Complex tmp = (Complex)z1.clone();
/* 230 */     tmp.Subtract(z2);
/* 231 */     return tmp;
/*     */   }
/*     */   
/*     */   public static final Complex Subtract(double x, Complex z)
/*     */   {
/* 236 */     Complex tmp = new Complex(x - z.Real(), -z.Imaginary());
/* 237 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void Subtract(double x)
/*     */   {
/* 246 */     u -= x;
/*     */   }
/*     */   
/*     */   public static final Complex Subtract(Complex z, double x)
/*     */   {
/* 251 */     Complex tmp = (Complex)z.clone();
/* 252 */     tmp.Subtract(x);
/* 253 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void Multiply(Complex z)
/*     */   {
/* 262 */     double tempx = u;
/* 263 */     double tempy = v;
/* 264 */     u = (tempx * u - tempy * v);
/* 265 */     v = (tempx * v + tempy * u);
/*     */   }
/*     */   
/*     */ 
/*     */   public static final Complex Multiply(Complex z1, Complex z2)
/*     */   {
/* 271 */     Complex tmp = (Complex)z1.clone();
/* 272 */     tmp.Multiply(z2);
/* 273 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void Multiply(double x)
/*     */   {
/* 283 */     u *= x;
/* 284 */     v *= x;
/*     */   }
/*     */   
/*     */   public static final Complex Multiply(Complex z, double x)
/*     */   {
/* 289 */     Complex tmp = (Complex)z.clone();
/* 290 */     tmp.Multiply(x);
/* 291 */     return tmp;
/*     */   }
/*     */   
/*     */   public static final Complex Multiply(double x, Complex z) {
/* 295 */     return Multiply(z, x);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void Divide(Complex z)
/*     */   {
/* 306 */     double tempx = u;
/* 307 */     double tempy = v;
/* 308 */     double rz = z.Magnitude();
/* 309 */     u = ((tempx * u + tempy * v) / (rz * rz));
/* 310 */     v = ((tempy * u - tempx * v) / (rz * rz));
/*     */   }
/*     */   
/*     */ 
/*     */   public static final Complex Divide(Complex z1, Complex z2)
/*     */   {
/* 316 */     Complex tmp = (Complex)z1.clone();
/* 317 */     tmp.Divide(z2);
/* 318 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void Divide(double x)
/*     */   {
/* 330 */     u /= x;
/* 331 */     v /= x;
/*     */   }
/*     */   
/*     */ 
/*     */   public static final Complex Divide(Complex z, double x)
/*     */   {
/* 337 */     Complex tmp = (Complex)z.clone();
/* 338 */     tmp.Divide(x);
/* 339 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */   public static final Complex Divide(double x, Complex z)
/*     */   {
/* 345 */     Complex tmp = (Complex)z.clone();
/* 346 */     tmp.Conjugate();
/* 347 */     tmp.Multiply(x);
/* 348 */     double mag2 = tmp.Magnitude2();
/* 349 */     tmp.Divide(mag2);
/* 350 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void Exp()
/*     */   {
/* 362 */     double temp = Math.exp(u);
/* 363 */     double tr = Math.cos(v) * temp;
/* 364 */     double ti = Math.sin(v) * temp;
/* 365 */     u = tr;
/* 366 */     v = ti;
/*     */   }
/*     */   
/*     */ 
/*     */   public static final Complex Exp(Complex z)
/*     */   {
/* 372 */     Complex tmp = (Complex)z.clone();
/* 373 */     tmp.Exp();
/* 374 */     return tmp;
/*     */   }
/*     */   
/*     */   public static final Complex Sinh(Complex z)
/*     */   {
/* 379 */     Complex tmp1 = Exp(z);
/* 380 */     Complex tmp2 = Exp(Multiply(z, -1.0D));
/* 381 */     Complex tmp = Divide(Subtract(tmp1, tmp2), 2.0D);
/* 382 */     return tmp;
/*     */   }
/*     */   
/*     */   public static final Complex Cosh(Complex z)
/*     */   {
/* 387 */     Complex tmp1 = Exp(z);
/* 388 */     Complex tmp2 = Exp(Multiply(z, -1.0D));
/* 389 */     Complex tmp = Divide(Add(tmp1, tmp2), 2.0D);
/* 390 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */   public static final Complex Tanh(Complex z)
/*     */   {
/* 396 */     Complex tmp1 = Exp(z);
/* 397 */     Complex tmp2 = Exp(Multiply(z, -1.0D));
/* 398 */     Complex tmp = Divide(Subtract(tmp1, tmp2), Add(tmp1, tmp2));
/* 399 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void Pow(double x)
/*     */   {
/* 411 */     double am = Math.pow(Magnitude(), x);
/* 412 */     double at = Arg2() * x;
/* 413 */     u = (am * Math.cos(at));
/* 414 */     v = (am * Math.sin(at));
/*     */   }
/*     */   
/*     */   public static final Complex Pow(Complex z, double x)
/*     */   {
/* 419 */     Complex tmp = (Complex)z.clone();
/* 420 */     tmp.Pow(x);
/* 421 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public final String toString()
/*     */   {
/*     */     String tmp;
/*     */     
/*     */     String tmp;
/*     */     
/* 432 */     if (v >= 0.0D) {
/* 433 */       tmp = String.valueOf(u) + " + j " + String.valueOf(v);
/*     */     }
/*     */     else
/*     */     {
/* 437 */       tmp = String.valueOf(u) + " - j " + String.valueOf(Math.abs(v));
/*     */     }
/* 439 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public final String toString(int tipo, int res)
/*     */   {
/* 458 */     double dtmp2 = MaestroA.rounder(v, res);
/* 459 */     double dtmp1 = MaestroA.rounder(u, res);
/*     */     
/* 461 */     Complex ctmp1 = new Complex(dtmp1, dtmp2);
/* 462 */     String tmp = ctmp1.toString();
/* 463 */     switch (tipo)
/*     */     {
/*     */     case 1: 
/* 466 */       dtmp1 = MaestroA.rounder(Magnitude(), res);
/* 467 */       if (dtmp1 == 0.0D) { dtmp2 = 0.0D;
/*     */       } else {
/* 469 */         dtmp2 = MaestroA.rounder(Arg2() * 180.0D / 3.141592653589793D, res);
/*     */       }
/*     */       
/*     */ 
/* 473 */       tmp = "" + dtmp1 + "   |_ " + dtmp2 + " º ";
/* 474 */       break;
/*     */     case 2: 
/* 476 */       dtmp1 = MaestroA.rounder(Magnitude(), res);
/* 477 */       if (dtmp1 == 0.0D) { dtmp2 = 0.0D;
/*     */       } else {
/* 479 */         dtmp2 = MaestroA.rounder(Arg2(), res);
/*     */       }
/*     */       
/* 482 */       tmp = "" + dtmp1 + "   |_ " + dtmp2 + " rad ";
/*     */     }
/*     */     
/* 485 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */   public final String toString(int tipo, int res1, int res2)
/*     */   {
/* 491 */     double dtmp2 = MaestroA.rounder(v, res1);
/* 492 */     double dtmp1 = MaestroA.rounder(u, res1);
/*     */     
/* 494 */     Complex ctmp1 = new Complex(dtmp1, dtmp2);
/* 495 */     String tmp = ctmp1.toString();
/* 496 */     switch (tipo)
/*     */     {
/*     */     case 1: 
/* 499 */       dtmp1 = MaestroA.rounder(Magnitude(), res1);
/* 500 */       if (dtmp1 == 0.0D) { dtmp2 = 0.0D;
/*     */       } else {
/* 502 */         dtmp2 = MaestroA.rounder(Arg2() * 180.0D / 3.141592653589793D, res2);
/*     */       }
/*     */       
/*     */ 
/* 506 */       tmp = "" + dtmp1 + "   |_ " + dtmp2 + " º ";
/* 507 */       break;
/*     */     case 2: 
/* 509 */       dtmp1 = MaestroA.rounder(Magnitude(), res1);
/* 510 */       if (dtmp1 == 0.0D) { dtmp2 = 0.0D;
/*     */       } else {
/* 512 */         dtmp2 = MaestroA.rounder(Arg2(), res2);
/*     */       }
/*     */       
/* 515 */       tmp = "" + dtmp1 + "   |_ " + dtmp2 + " rad ";
/*     */     }
/*     */     
/* 518 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */   public final String toString(int tipo, int res, boolean roundoff)
/*     */   {
/* 524 */     double dtmp2 = MaestroA.rounder(v, res, roundoff);
/* 525 */     double dtmp1 = MaestroA.rounder(u, res, roundoff);
/*     */     
/* 527 */     Complex ctmp1 = new Complex(dtmp1, dtmp2);
/* 528 */     String tmp = ctmp1.toString();
/* 529 */     switch (tipo)
/*     */     {
/*     */     case 1: 
/* 532 */       dtmp1 = MaestroA.rounder(Magnitude(), res, roundoff);
/*     */       
/* 534 */       if (dtmp1 == 0.0D) dtmp2 = 0.0D; else {
/* 535 */         dtmp2 = MaestroA.rounder(Arg2() * 180.0D / 3.141592653589793D, res, roundoff);
/*     */       }
/* 537 */       tmp = "" + dtmp1 + "   |_ " + dtmp2 + " º ";
/* 538 */       break;
/*     */     
/*     */     case 2: 
/* 541 */       dtmp1 = MaestroA.rounder(Magnitude(), res, roundoff);
/* 542 */       if (dtmp1 == 0.0D) dtmp2 = 0.0D; else {
/* 543 */         dtmp2 = MaestroA.rounder(Arg2(), res, roundoff);
/*     */       }
/* 545 */       tmp = "" + dtmp1 + "   |_ " + dtmp2 + " rad ";
/*     */     }
/*     */     
/* 548 */     return tmp;
/*     */   }
/*     */   
/*     */   public static final String toString(Complex z) {
/*     */     String tmp;
/*     */     String tmp;
/* 554 */     if (z.Imaginary() >= 0.0D) {
/* 555 */       tmp = String.valueOf(z.Real()) + " + j " + String.valueOf(z.Imaginary());
/*     */     }
/*     */     else {
/* 558 */       tmp = String.valueOf(z.Real()) + " - j " + String.valueOf(z.Imaginary());
/*     */     }
/* 560 */     return tmp;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public final String toString(int tipo)
/*     */   {
/* 571 */     String tmp = toString();
/* 572 */     switch (tipo)
/*     */     {
/*     */     case 1: 
/* 575 */       tmp = "" + Magnitude() + " [" + Arg2() * 180.0D / 3.141592653589793D + " º]";
/* 576 */       break;
/*     */     case 2: 
/* 578 */       tmp = "" + Magnitude() + " [" + Arg2() + " rad]";
/*     */     }
/*     */     
/* 581 */     return tmp;
/*     */   }
/*     */   
/*     */   public static final String toString(Complex z, int tipo) {
/* 585 */     return z.toString(tipo);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public final synchronized void setReal(double u)
/*     */   {
/* 595 */     this.u = u;
/*     */   }
/*     */   
/*     */   public static final synchronized void setReal(Complex z, double u) {
/* 599 */     z.setReal(u);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public final synchronized void setImaginary(double v)
/*     */   {
/* 608 */     this.v = v;
/*     */   }
/*     */   
/*     */   public static final synchronized void setImaginary(Complex z, double v) {
/* 612 */     z.setImaginary(v);
/*     */   }
/*     */   
/*     */   public boolean equals(Complex z) {
/* 616 */     if ((u == z.Real()) && (v == z.Imaginary())) {
/* 617 */       return true;
/*     */     }
/*     */     
/* 620 */     return false;
/*     */   }
/*     */ }

/* Location:           C:\Users\GENÇ\JAVA\smithchart20033\ImportedClasses
 * Qualified Name:     Complex
 * Java Class Version: 7 (51.0)
 * JD-Core Version:    0.7.1
 */