| 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 | {
|
|---|
|
|---|