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