1999-09-18 12:51:31 +02:00
|
|
|
#include "f2c.h"
|
|
|
|
|
2003-07-11 05:42:19 +02:00
|
|
|
double
|
|
|
|
pow_di (doublereal * ap, integer * bp)
|
1999-09-18 12:51:31 +02:00
|
|
|
{
|
2003-07-11 05:42:19 +02:00
|
|
|
double pow, x;
|
|
|
|
integer n;
|
|
|
|
unsigned long u;
|
1999-09-18 12:51:31 +02:00
|
|
|
|
2003-07-11 05:42:19 +02:00
|
|
|
pow = 1;
|
|
|
|
x = *ap;
|
|
|
|
n = *bp;
|
1999-09-18 12:51:31 +02:00
|
|
|
|
2003-07-11 05:42:19 +02:00
|
|
|
if (n != 0)
|
|
|
|
{
|
|
|
|
if (n < 0)
|
1999-09-18 12:51:31 +02:00
|
|
|
{
|
2003-07-11 05:42:19 +02:00
|
|
|
n = -n;
|
|
|
|
x = 1 / x;
|
1999-09-18 12:51:31 +02:00
|
|
|
}
|
2003-07-11 05:42:19 +02:00
|
|
|
for (u = n;;)
|
|
|
|
{
|
|
|
|
if (u & 01)
|
|
|
|
pow *= x;
|
|
|
|
if (u >>= 1)
|
|
|
|
x *= x;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (pow);
|
1999-09-18 12:51:31 +02:00
|
|
|
}
|