|
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:
1.1 KB
|
| Line | |
|---|
| 1 | #include "f2c.h"
|
|---|
| 2 |
|
|---|
| 3 | #undef abs
|
|---|
| 4 | #include "math.h"
|
|---|
| 5 | extern double f__cabs (double, double);
|
|---|
| 6 | void
|
|---|
| 7 | z_log (doublecomplex * r, doublecomplex * z)
|
|---|
| 8 | {
|
|---|
| 9 | double s, s0, t, t2, u, v;
|
|---|
| 10 | double zi = z->i, zr = z->r;
|
|---|
| 11 |
|
|---|
| 12 | r->i = atan2 (zi, zr);
|
|---|
| 13 | #ifdef Pre20000310
|
|---|
| 14 | r->r = log (f__cabs (zr, zi));
|
|---|
| 15 | #else
|
|---|
| 16 | if (zi < 0)
|
|---|
| 17 | zi = -zi;
|
|---|
| 18 | if (zr < 0)
|
|---|
| 19 | zr = -zr;
|
|---|
| 20 | if (zr < zi)
|
|---|
| 21 | {
|
|---|
| 22 | t = zi;
|
|---|
| 23 | zi = zr;
|
|---|
| 24 | zr = t;
|
|---|
| 25 | }
|
|---|
| 26 | t = zi / zr;
|
|---|
| 27 | s = zr * sqrt (1 + t * t);
|
|---|
| 28 | /* now s = f__cabs(zi,zr), and zr = |zr| >= |zi| = zi */
|
|---|
| 29 | if ((t = s - 1) < 0)
|
|---|
| 30 | t = -t;
|
|---|
| 31 | if (t > .01)
|
|---|
| 32 | r->r = log (s);
|
|---|
| 33 | else
|
|---|
| 34 | {
|
|---|
| 35 |
|
|---|
| 36 | #ifdef Comment
|
|---|
| 37 |
|
|---|
| 38 | log (1 + x) = x - x ^ 2 / 2 + x ^ 3 / 3 - x ^ 4 / 4 + -...
|
|---|
| 39 | = x (1 - x / 2 + x ^ 2 / 3 - +...)
|
|---|
| 40 | [sqrt (y ^ 2 + z ^ 2) - 1] *[sqrt (y ^ 2 + z ^ 2) + 1] =
|
|---|
| 41 | y ^ 2 + z ^ 2 - 1, so sqrt (y ^ 2 + z ^ 2) - 1 =
|
|---|
| 42 | (y ^ 2 + z ^ 2 - 1) /[sqrt (y ^ 2 + z ^ 2) + 1]
|
|---|
| 43 | #endif /*Comment */
|
|---|
| 44 | t = ((zr * zr - 1.) + zi * zi) / (s + 1);
|
|---|
| 45 | t2 = t * t;
|
|---|
| 46 | s = 1. - 0.5 * t;
|
|---|
| 47 | u = v = 1;
|
|---|
| 48 | do
|
|---|
| 49 | {
|
|---|
| 50 | s0 = s;
|
|---|
| 51 | u *= t2;
|
|---|
| 52 | v += 2;
|
|---|
| 53 | s += u / v - t * u / (v + 1);
|
|---|
| 54 | }
|
|---|
| 55 | while (s > s0);
|
|---|
| 56 | r->r = s * t;
|
|---|
| 57 | }
|
|---|
| 58 | #endif
|
|---|
| 59 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.