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 extern VOID sig_die();
00008 VOID z_div(c, a, b) doublecomplex *a, *b, *c;
00009 #else
00010 extern void sig_die(const char*, int);
00011 void z_div(doublecomplex *c, doublecomplex *a, doublecomplex *b)
00012 #endif
00013 {
00014 double ratio, den;
00015 double abr, abi, cr;
00016
00017 if( (abr = b->r) < 0.)
00018 abr = - abr;
00019 if( (abi = b->i) < 0.)
00020 abi = - abi;
00021 if( abr <= abi )
00022 {
00023 if(abi == 0) {
00024 #ifdef IEEE_COMPLEX_DIVIDE
00025 if (a->i != 0 || a->r != 0)
00026 abi = 1.;
00027 c->i = c->r = abi / abr;
00028 return;
00029 #else
00030 sig_die("complex division by zero", 1);
00031 #endif
00032 }
00033 ratio = b->r / b->i ;
00034 den = b->i * (1 + ratio*ratio);
00035 cr = (a->r*ratio + a->i) / den;
00036 c->i = (a->i*ratio - a->r) / den;
00037 }
00038
00039 else
00040 {
00041 ratio = b->i / b->r ;
00042 den = b->r * (1 + ratio*ratio);
00043 cr = (a->r + a->i*ratio) / den;
00044 c->i = (a->i - a->r*ratio) / den;
00045 }
00046 c->r = cr;
00047 }
00048 #ifdef __cplusplus
00049 }
00050 #endif