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:
490 bytes
|
Line | |
---|
1 | #include "f2c.h"
|
---|
2 |
|
---|
3 | #undef abs
|
---|
4 | #include "math.h"
|
---|
5 | extern double f__cabs (double, double);
|
---|
6 |
|
---|
7 | void
|
---|
8 | c_sqrt (complex * r, complex * z)
|
---|
9 | {
|
---|
10 | double mag, t;
|
---|
11 | double zi = z->i, zr = z->r;
|
---|
12 |
|
---|
13 | if ((mag = f__cabs (zr, zi)) == 0.)
|
---|
14 | r->r = r->i = 0.;
|
---|
15 | else if (zr > 0)
|
---|
16 | {
|
---|
17 | r->r = t = sqrt (0.5 * (mag + zr));
|
---|
18 | t = zi / t;
|
---|
19 | r->i = 0.5 * t;
|
---|
20 | }
|
---|
21 | else
|
---|
22 | {
|
---|
23 | t = sqrt (0.5 * (mag - zr));
|
---|
24 | if (zi < 0)
|
---|
25 | t = -t;
|
---|
26 | r->i = t;
|
---|
27 | t = zi / t;
|
---|
28 | r->r = 0.5 * t;
|
---|
29 | }
|
---|
30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.