Last change
on this file was 1392, checked in by bird, 21 years ago |
This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.
|
-
Property cvs2svn:cvs-rev
set to
1.1.1.2
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
File size:
809 bytes
|
Line | |
---|
1 | #include "f2c.h"
|
---|
2 |
|
---|
3 | extern void sig_die (char *, int);
|
---|
4 | void
|
---|
5 | z_div (doublecomplex * c, doublecomplex * a, doublecomplex * b)
|
---|
6 | {
|
---|
7 | double ratio, den;
|
---|
8 | double abr, abi, cr;
|
---|
9 |
|
---|
10 | if ((abr = b->r) < 0.)
|
---|
11 | abr = -abr;
|
---|
12 | if ((abi = b->i) < 0.)
|
---|
13 | abi = -abi;
|
---|
14 | if (abr <= abi)
|
---|
15 | {
|
---|
16 | if (abi == 0)
|
---|
17 | {
|
---|
18 | #ifdef IEEE_COMPLEX_DIVIDE
|
---|
19 | if (a->i != 0 || a->r != 0)
|
---|
20 | abi = 1.;
|
---|
21 | c->i = c->r = abi / abr;
|
---|
22 | return;
|
---|
23 | #else
|
---|
24 | sig_die ("complex division by zero", 1);
|
---|
25 | #endif
|
---|
26 | }
|
---|
27 | ratio = b->r / b->i;
|
---|
28 | den = b->i * (1 + ratio * ratio);
|
---|
29 | cr = (a->r * ratio + a->i) / den;
|
---|
30 | c->i = (a->i * ratio - a->r) / den;
|
---|
31 | }
|
---|
32 |
|
---|
33 | else
|
---|
34 | {
|
---|
35 | ratio = b->i / b->r;
|
---|
36 | den = b->r * (1 + ratio * ratio);
|
---|
37 | cr = (a->r + a->i * ratio) / den;
|
---|
38 | c->i = (a->i - a->r * ratio) / den;
|
---|
39 | }
|
---|
40 | c->r = cr;
|
---|
41 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.