1998-02-01 02:37:08 +01:00
|
|
|
#include "f2c.h"
|
|
|
|
|
|
|
|
#undef abs
|
|
|
|
#include <math.h>
|
2002-06-01 14:38:32 +02:00
|
|
|
extern double f__cabs (double, double);
|
|
|
|
void
|
|
|
|
pow_zz (doublecomplex * r, doublecomplex * a, doublecomplex * b)
|
1998-02-01 02:37:08 +01:00
|
|
|
{
|
2002-06-01 14:38:32 +02:00
|
|
|
double logr, logi, x, y;
|
1998-02-01 02:37:08 +01:00
|
|
|
|
2002-11-20 00:17:36 +01:00
|
|
|
if (a->r == 0.0 && a->i == 0.0)
|
|
|
|
{
|
|
|
|
/* Algorithm below doesn't cope. */
|
|
|
|
r->r = r->i = 0.0;
|
|
|
|
return;
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
logr = log (f__cabs (a->r, a->i));
|
|
|
|
logi = atan2 (a->i, a->r);
|
1998-02-01 02:37:08 +01:00
|
|
|
|
2002-06-01 14:38:32 +02:00
|
|
|
x = exp (logr * b->r - logi * b->i);
|
|
|
|
y = logr * b->i + logi * b->r;
|
1998-02-01 02:37:08 +01:00
|
|
|
|
2002-06-01 14:38:32 +02:00
|
|
|
r->r = x * cos (y);
|
|
|
|
r->i = x * sin (y);
|
1998-02-01 02:37:08 +01:00
|
|
|
}
|