freebsd-nq/contrib/libf2c/libF77/pow_zz.c

26 lines
500 B
C
Raw Normal View History

1999-09-18 10:51:31 +00:00
#include "f2c.h"
#undef abs
#include <math.h>
2003-07-11 03:42:19 +00:00
extern double f__cabs (double, double);
void
pow_zz (doublecomplex * r, doublecomplex * a, doublecomplex * b)
1999-09-18 10:51:31 +00:00
{
2003-07-11 03:42:19 +00:00
double logr, logi, x, y;
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
if (a->r == 0.0 && a->i == 0.0)
{
/* Algorithm below doesn't cope. */
r->r = r->i = 0.0;
return;
}
logr = log (f__cabs (a->r, a->i));
logi = atan2 (a->i, a->r);
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
x = exp (logr * b->r - logi * b->i);
y = logr * b->i + logi * b->r;
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
r->r = x * cos (y);
r->i = x * sin (y);
1999-09-18 10:51:31 +00:00
}