Go to the documentation of this file.00001 #include "f2c.h"
00002 #ifdef __cplusplus
00003 extern "C" {
00004 #endif
00005
00006 #ifdef KR_headers
00007 VOID pow_zi(p, a, b)
00008 doublecomplex *p, *a; integer *b;
00009 #else
00010 extern void z_div(doublecomplex*, doublecomplex*, doublecomplex*);
00011 void pow_zi(doublecomplex *p, doublecomplex *a, integer *b)
00012 #endif
00013 {
00014 integer n;
00015 unsigned long u;
00016 double t;
00017 doublecomplex q, x;
00018 static doublecomplex one = {1.0, 0.0};
00019
00020 n = *b;
00021 q.r = 1;
00022 q.i = 0;
00023
00024 if(n == 0)
00025 goto done;
00026 if(n < 0)
00027 {
00028 n = -n;
00029 z_div(&x, &one, a);
00030 }
00031 else
00032 {
00033 x.r = a->r;
00034 x.i = a->i;
00035 }
00036
00037 for(u = n; ; )
00038 {
00039 if(u & 01)
00040 {
00041 t = q.r * x.r - q.i * x.i;
00042 q.i = q.r * x.i + q.i * x.r;
00043 q.r = t;
00044 }
00045 if(u >>= 1)
00046 {
00047 t = x.r * x.r - x.i * x.i;
00048 x.i = 2 * x.r * x.i;
00049 x.r = t;
00050 }
00051 else
00052 break;
00053 }
00054 done:
00055 p->i = q.i;
00056 p->r = q.r;
00057 }
00058 #ifdef __cplusplus
00059 }
00060 #endif