repo.or.cz
/
dragonfly.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Mention KTR_IFQ and KTR_IF_START
[dragonfly.git]
/
contrib
/
gcc-3.4
/
libf2c
/
libF77
/
c_sqrt.c
blob
81b72fc372e1dc89cb15483e77ada1c079b0f78c
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
}