Patch for PR 9255
[official-gcc.git] / libf2c / libF77 / pow_zz.c
blobd5cfbf3d9316dce6358a846894257fabf5f23f69
1 #include "f2c.h"
3 #undef abs
4 #include <math.h>
5 extern double f__cabs (double, double);
6 void
7 pow_zz (doublecomplex * r, doublecomplex * a, doublecomplex * b)
9 double logr, logi, x, y;
11 if (a->r == 0.0 && a->i == 0.0)
13 /* Algorithm below doesn't cope. */
14 r->r = r->i = 0.0;
15 return;
17 logr = log (f__cabs (a->r, a->i));
18 logi = atan2 (a->i, a->r);
20 x = exp (logr * b->r - logi * b->i);
21 y = logr * b->i + logi * b->r;
23 r->r = x * cos (y);
24 r->i = x * sin (y);