source: trunk/third/gcc/libf2c/libF77/c_div.c @ 16960

Revision 16960, 863 bytes checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r16959, which included commits to RCS files with non-trunk default branches.
Line 
1#include "f2c.h"
2
3#ifdef KR_headers
4extern VOID sig_die();
5VOID c_div(c, a, b)
6complex *a, *b, *c;
7#else
8extern void sig_die(char*,int);
9void c_div(complex *c, complex *a, complex *b)
10#endif
11{
12        double ratio, den;
13        double abr, abi, cr;
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#ifdef IEEE_COMPLEX_DIVIDE
23                        float af, bf;
24                        af = bf = abr;
25                        if (a->i != 0 || a->r != 0)
26                                af = 1.;
27                        c->i = c->r = af / bf;
28                        return;
29#else
30                        sig_die("complex division by zero", 1);
31#endif
32                        }
33                ratio = (double)b->r / b->i ;
34                den = b->i * (1 + ratio*ratio);
35                cr = (a->r*ratio + a->i) / den;
36                c->i = (a->i*ratio - a->r) / den;
37                }
38
39        else
40                {
41                ratio = (double)b->i / b->r ;
42                den = b->r * (1 + ratio*ratio);
43                cr = (a->r + a->i*ratio) / den;
44                c->i = (a->i - a->r*ratio) / den;
45                }
46        c->r = cr;
47        }
Note: See TracBrowser for help on using the repository browser.