1998-02-01 02:37:08 +01:00
|
|
|
#include "f2c.h"
|
|
|
|
|
2002-06-01 14:38:32 +02:00
|
|
|
double
|
|
|
|
pow_di (doublereal * ap, integer * bp)
|
1998-02-01 02:37:08 +01:00
|
|
|
{
|
2002-06-01 14:38:32 +02:00
|
|
|
double pow, x;
|
|
|
|
integer n;
|
|
|
|
unsigned long u;
|
1998-02-01 02:37:08 +01:00
|
|
|
|
2002-06-01 14:38:32 +02:00
|
|
|
pow = 1;
|
|
|
|
x = *ap;
|
|
|
|
n = *bp;
|
1998-02-01 02:37:08 +01:00
|
|
|
|
2002-06-01 14:38:32 +02:00
|
|
|
if (n != 0)
|
|
|
|
{
|
|
|
|
if (n < 0)
|
1998-02-01 02:37:08 +01:00
|
|
|
{
|
2002-06-01 14:38:32 +02:00
|
|
|
n = -n;
|
|
|
|
x = 1 / x;
|
1998-02-01 02:37:08 +01:00
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
for (u = n;;)
|
|
|
|
{
|
|
|
|
if (u & 01)
|
|
|
|
pow *= x;
|
|
|
|
if (u >>= 1)
|
|
|
|
x *= x;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (pow);
|
1998-02-01 02:37:08 +01:00
|
|
|
}
|