|
Last change
on this file since 3224 was 1392, checked in by bird, 22 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:
841 bytes
|
| Line | |
|---|
| 1 | #include "f2c.h"
|
|---|
| 2 |
|
|---|
| 3 | extern void sig_die (char *, int);
|
|---|
| 4 | void
|
|---|
| 5 | c_div (complex * c, complex * a, complex * 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 | float af, bf;
|
|---|
| 20 | af = bf = abr;
|
|---|
| 21 | if (a->i != 0 || a->r != 0)
|
|---|
| 22 | af = 1.;
|
|---|
| 23 | c->i = c->r = af / bf;
|
|---|
| 24 | return;
|
|---|
| 25 | #else
|
|---|
| 26 | sig_die ("complex division by zero", 1);
|
|---|
| 27 | #endif
|
|---|
| 28 | }
|
|---|
| 29 | ratio = (double) b->r / b->i;
|
|---|
| 30 | den = b->i * (1 + ratio * ratio);
|
|---|
| 31 | cr = (a->r * ratio + a->i) / den;
|
|---|
| 32 | c->i = (a->i * ratio - a->r) / den;
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | else
|
|---|
| 36 | {
|
|---|
| 37 | ratio = (double) b->i / b->r;
|
|---|
| 38 | den = b->r * (1 + ratio * ratio);
|
|---|
| 39 | cr = (a->r + a->i * ratio) / den;
|
|---|
| 40 | c->i = (a->i - a->r * ratio) / den;
|
|---|
| 41 | }
|
|---|
| 42 | c->r = cr;
|
|---|
| 43 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.