* config/netbsd.h (CPP_SPEC): Remove.
[official-gcc.git] / libf2c / libF77 / z_div.c
blobe14df32a1f8a79c3a8807abe9dfabdc984df8fe3
1 #include "f2c.h"
3 #ifdef KR_headers
4 extern VOID sig_die();
5 VOID z_div(c, a, b) doublecomplex *a, *b, *c;
6 #else
7 extern void sig_die(char*, int);
8 void z_div(doublecomplex *c, doublecomplex *a, doublecomplex *b)
9 #endif
11 double ratio, den;
12 double abr, abi, cr;
14 if( (abr = b->r) < 0.)
15 abr = - abr;
16 if( (abi = b->i) < 0.)
17 abi = - abi;
18 if( abr <= abi )
20 if(abi == 0) {
21 #ifdef IEEE_COMPLEX_DIVIDE
22 if (a->i != 0 || a->r != 0)
23 abi = 1.;
24 c->i = c->r = abi / abr;
25 return;
26 #else
27 sig_die("complex division by zero", 1);
28 #endif
30 ratio = b->r / b->i ;
31 den = b->i * (1 + ratio*ratio);
32 cr = (a->r*ratio + a->i) / den;
33 c->i = (a->i*ratio - a->r) / den;
36 else
38 ratio = b->i / b->r ;
39 den = b->r * (1 + ratio*ratio);
40 cr = (a->r + a->i*ratio) / den;
41 c->i = (a->i - a->r*ratio) / den;
43 c->r = cr;