Esempio n. 1
0
 public static Complex log(double x_re, double x_im) {
   double h;
   /* #ifdef JAVA5 */
   // h = Math.hypot(x_re, x_im);
   /* #else */
   h = DComplex.hypot(x_re, x_im);
   /* #endif */
   return make(Math.log(h), Math.atan2(x_im, x_re));
 }
Esempio n. 2
0
 public static DComplex power(double x_re, double x_im, double y_re, double y_im) {
   double h;
   /* #ifdef JAVA5 */
   // h = Math.hypot(x_re, x_im);
   /* #else */
   h = DComplex.hypot(x_re, x_im);
   /* #endif */
   double logr = Math.log(h);
   double t = Math.atan2(x_im, x_re);
   double r = Math.exp(logr * y_re - y_im * t);
   t = y_im * logr + y_re * t;
   return Complex.polar(r, t);
 }
Esempio n. 3
0
 public static Complex sqrt(double x_re, double x_im) {
   /* #ifdef JAVA5 */
   // double r = Math.hypot(x_re, x_im);
   /* #else */
   double r = DComplex.hypot(x_re, x_im);
   /* #endif */
   double nr, ni;
   if (r == 0.0) nr = ni = r;
   else if (x_re > 0) {
     nr = Math.sqrt(0.5 * (r + x_re));
     ni = x_im / nr / 2;
   } else {
     ni = Math.sqrt(0.5 * (r - x_re));
     if (x_im < 0) ni = -ni;
     nr = x_im / ni / 2;
   }
   return new DComplex(nr, ni);
 }