Revision 14548,
700 bytes
checked in by ghudson, 24 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r14547,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
1 | #include "f2c.h" |
---|
2 | |
---|
3 | #ifdef KR_headers |
---|
4 | extern VOID sig_die(); |
---|
5 | VOID c_div(c, a, b) |
---|
6 | complex *a, *b, *c; |
---|
7 | #else |
---|
8 | extern void sig_die(char*,int); |
---|
9 | void 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 | sig_die("complex division by zero", 1); |
---|
23 | ratio = (double)b->r / b->i ; |
---|
24 | den = b->i * (1 + ratio*ratio); |
---|
25 | cr = (a->r*ratio + a->i) / den; |
---|
26 | c->i = (a->i*ratio - a->r) / den; |
---|
27 | } |
---|
28 | |
---|
29 | else |
---|
30 | { |
---|
31 | ratio = (double)b->i / b->r ; |
---|
32 | den = b->r * (1 + ratio*ratio); |
---|
33 | cr = (a->r + a->i*ratio) / den; |
---|
34 | c->i = (a->i - a->r*ratio) / den; |
---|
35 | } |
---|
36 | c->r = cr; |
---|
37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.