]> gcc.gnu.org Git - gcc.git/blob - gcc/f/runtime/libF77/z_div.c
Initial revision
[gcc.git] / gcc / f / runtime / libF77 / z_div.c
1 #include "f2c.h"
2
3 #ifdef KR_headers
4 extern VOID sig_die();
5 VOID z_div(resx, a, b) doublecomplex *a, *b, *resx;
6 #else
7 extern void sig_die(char*, int);
8 void z_div(doublecomplex *resx, doublecomplex *a, doublecomplex *b)
9 #endif
10 {
11 double ratio, den;
12 double abr, abi;
13 doublecomplex res;
14
15 if( (abr = b->r) < 0.)
16 abr = - abr;
17 if( (abi = b->i) < 0.)
18 abi = - abi;
19 if( abr <= abi )
20 {
21 if(abi == 0)
22 sig_die("complex division by zero", 1);
23 ratio = b->r / b->i ;
24 den = b->i * (1 + ratio*ratio);
25 res.r = (a->r*ratio + a->i) / den;
26 res.i = (a->i*ratio - a->r) / den;
27 }
28
29 else
30 {
31 ratio = b->i / b->r ;
32 den = b->r * (1 + ratio*ratio);
33 res.r = (a->r + a->i*ratio) / den;
34 res.i = (a->i - a->r*ratio) / den;
35 }
36
37 resx->r = res.r;
38 resx->i = res.i;
39 }
This page took 0.03814 seconds and 5 git commands to generate.