Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
cfbaba79
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
大约 1 年 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cfbaba79
编写于
11月 13, 2012
作者:
S
Szabolcs Nagy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
complex: add C11 CMPLX macros and replace cpack with them
上级
e2fe959f
变更
47
隐藏空白更改
内联
并排
Showing
47 changed file
with
152 addition
and
156 deletion
+152
-156
include/complex.h
include/complex.h
+9
-0
src/complex/__cexp.c
src/complex/__cexp.c
+1
-1
src/complex/__cexpf.c
src/complex/__cexpf.c
+1
-1
src/complex/cacos.c
src/complex/cacos.c
+1
-1
src/complex/cacosf.c
src/complex/cacosf.c
+1
-1
src/complex/cacosh.c
src/complex/cacosh.c
+1
-1
src/complex/cacoshf.c
src/complex/cacoshf.c
+1
-1
src/complex/cacoshl.c
src/complex/cacoshl.c
+1
-1
src/complex/cacosl.c
src/complex/cacosl.c
+1
-1
src/complex/casin.c
src/complex/casin.c
+2
-2
src/complex/casinf.c
src/complex/casinf.c
+2
-2
src/complex/casinh.c
src/complex/casinh.c
+2
-2
src/complex/casinhf.c
src/complex/casinhf.c
+2
-2
src/complex/casinhl.c
src/complex/casinhl.c
+2
-2
src/complex/casinl.c
src/complex/casinl.c
+2
-2
src/complex/catanh.c
src/complex/catanh.c
+2
-2
src/complex/catanhf.c
src/complex/catanhf.c
+2
-2
src/complex/catanhl.c
src/complex/catanhl.c
+2
-2
src/complex/ccos.c
src/complex/ccos.c
+1
-1
src/complex/ccosf.c
src/complex/ccosf.c
+1
-1
src/complex/ccosh.c
src/complex/ccosh.c
+13
-13
src/complex/ccoshf.c
src/complex/ccoshf.c
+13
-13
src/complex/ccosl.c
src/complex/ccosl.c
+1
-1
src/complex/cexp.c
src/complex/cexp.c
+6
-6
src/complex/cexpf.c
src/complex/cexpf.c
+6
-6
src/complex/clog.c
src/complex/clog.c
+1
-1
src/complex/clogf.c
src/complex/clogf.c
+1
-1
src/complex/clogl.c
src/complex/clogl.c
+1
-1
src/complex/conj.c
src/complex/conj.c
+1
-1
src/complex/conjf.c
src/complex/conjf.c
+1
-1
src/complex/conjl.c
src/complex/conjl.c
+1
-1
src/complex/cproj.c
src/complex/cproj.c
+1
-1
src/complex/cprojf.c
src/complex/cprojf.c
+1
-1
src/complex/cprojl.c
src/complex/cprojl.c
+1
-1
src/complex/csin.c
src/complex/csin.c
+2
-2
src/complex/csinf.c
src/complex/csinf.c
+2
-2
src/complex/csinh.c
src/complex/csinh.c
+13
-13
src/complex/csinhf.c
src/complex/csinhf.c
+13
-13
src/complex/csinl.c
src/complex/csinl.c
+2
-2
src/complex/csqrt.c
src/complex/csqrt.c
+7
-7
src/complex/csqrtf.c
src/complex/csqrtf.c
+7
-7
src/complex/ctan.c
src/complex/ctan.c
+2
-2
src/complex/ctanf.c
src/complex/ctanf.c
+2
-2
src/complex/ctanh.c
src/complex/ctanh.c
+5
-5
src/complex/ctanhf.c
src/complex/ctanhf.c
+5
-5
src/complex/ctanl.c
src/complex/ctanl.c
+2
-2
src/internal/libm.h
src/internal/libm.h
+5
-18
未找到文件。
include/complex.h
浏览文件 @
cfbaba79
...
...
@@ -112,6 +112,15 @@ long double creall(long double complex);
#define cimagf(x) __CIMAG(x, float)
#define cimagl(x) __CIMAG(x, long double)
#define __CMPLX(x, y, t) \
((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
#if __STDC_VERSION__ >= 201112L
#define CMPLX(x, y) __CMPLX(x, y, double)
#define CMPLXF(x, y) __CMPLX(x, y, float)
#define CMPLXL(x, y) __CMPLX(x, y, long double)
#endif
#ifdef __cplusplus
}
#endif
...
...
src/complex/__cexp.c
浏览文件 @
cfbaba79
...
...
@@ -83,5 +83,5 @@ double complex __ldexp_cexp(double complex z, int expt)
half_expt
=
expt
-
half_expt
;
INSERT_WORDS
(
scale2
,
(
0x3ff
+
half_expt
)
<<
20
,
0
);
return
cpack
(
cos
(
y
)
*
exp_x
*
scale1
*
scale2
,
sin
(
y
)
*
exp_x
*
scale1
*
scale2
);
return
CMPLX
(
cos
(
y
)
*
exp_x
*
scale1
*
scale2
,
sin
(
y
)
*
exp_x
*
scale1
*
scale2
);
}
src/complex/__cexpf.c
浏览文件 @
cfbaba79
...
...
@@ -63,6 +63,6 @@ float complex __ldexp_cexpf(float complex z, int expt)
half_expt
=
expt
-
half_expt
;
SET_FLOAT_WORD
(
scale2
,
(
0x7f
+
half_expt
)
<<
23
);
return
cpackf
(
cosf
(
y
)
*
exp_x
*
scale1
*
scale2
,
return
CMPLXF
(
cosf
(
y
)
*
exp_x
*
scale1
*
scale2
,
sinf
(
y
)
*
exp_x
*
scale1
*
scale2
);
}
src/complex/cacos.c
浏览文件 @
cfbaba79
...
...
@@ -7,5 +7,5 @@
double
complex
cacos
(
double
complex
z
)
{
z
=
casin
(
z
);
return
cpack
(
M_PI_2
-
creal
(
z
),
-
cimag
(
z
));
return
CMPLX
(
M_PI_2
-
creal
(
z
),
-
cimag
(
z
));
}
src/complex/cacosf.c
浏览文件 @
cfbaba79
...
...
@@ -5,5 +5,5 @@
float
complex
cacosf
(
float
complex
z
)
{
z
=
casinf
(
z
);
return
cpackf
((
float
)
M_PI_2
-
crealf
(
z
),
-
cimagf
(
z
));
return
CMPLXF
((
float
)
M_PI_2
-
crealf
(
z
),
-
cimagf
(
z
));
}
src/complex/cacosh.c
浏览文件 @
cfbaba79
...
...
@@ -5,5 +5,5 @@
double
complex
cacosh
(
double
complex
z
)
{
z
=
cacos
(
z
);
return
cpack
(
-
cimag
(
z
),
creal
(
z
));
return
CMPLX
(
-
cimag
(
z
),
creal
(
z
));
}
src/complex/cacoshf.c
浏览文件 @
cfbaba79
...
...
@@ -3,5 +3,5 @@
float
complex
cacoshf
(
float
complex
z
)
{
z
=
cacosf
(
z
);
return
cpackf
(
-
cimagf
(
z
),
crealf
(
z
));
return
CMPLXF
(
-
cimagf
(
z
),
crealf
(
z
));
}
src/complex/cacoshl.c
浏览文件 @
cfbaba79
...
...
@@ -9,6 +9,6 @@ long double complex cacoshl(long double complex z)
long
double
complex
cacoshl
(
long
double
complex
z
)
{
z
=
cacosl
(
z
);
return
cpackl
(
-
cimagl
(
z
),
creall
(
z
));
return
CMPLXL
(
-
cimagl
(
z
),
creall
(
z
));
}
#endif
src/complex/cacosl.c
浏览文件 @
cfbaba79
...
...
@@ -11,6 +11,6 @@ long double complex cacosl(long double complex z)
long
double
complex
cacosl
(
long
double
complex
z
)
{
z
=
casinl
(
z
);
return
cpackl
(
PI_2
-
creall
(
z
),
-
cimagl
(
z
));
return
CMPLXL
(
PI_2
-
creall
(
z
),
-
cimagl
(
z
));
}
#endif
src/complex/casin.c
浏览文件 @
cfbaba79
...
...
@@ -11,6 +11,6 @@ double complex casin(double complex z)
x
=
creal
(
z
);
y
=
cimag
(
z
);
w
=
cpack
(
1
.
0
-
(
x
-
y
)
*
(
x
+
y
),
-
2
.
0
*
x
*
y
);
return
clog
(
cpack
(
-
y
,
x
)
+
csqrt
(
w
));
w
=
CMPLX
(
1
.
0
-
(
x
-
y
)
*
(
x
+
y
),
-
2
.
0
*
x
*
y
);
return
clog
(
CMPLX
(
-
y
,
x
)
+
csqrt
(
w
));
}
src/complex/casinf.c
浏览文件 @
cfbaba79
...
...
@@ -9,6 +9,6 @@ float complex casinf(float complex z)
x
=
crealf
(
z
);
y
=
cimagf
(
z
);
w
=
cpackf
(
1
.
0
-
(
x
-
y
)
*
(
x
+
y
),
-
2
.
0
*
x
*
y
);
return
clogf
(
cpackf
(
-
y
,
x
)
+
csqrtf
(
w
));
w
=
CMPLXF
(
1
.
0
-
(
x
-
y
)
*
(
x
+
y
),
-
2
.
0
*
x
*
y
);
return
clogf
(
CMPLXF
(
-
y
,
x
)
+
csqrtf
(
w
));
}
src/complex/casinh.c
浏览文件 @
cfbaba79
...
...
@@ -4,6 +4,6 @@
double
complex
casinh
(
double
complex
z
)
{
z
=
casin
(
cpack
(
-
cimag
(
z
),
creal
(
z
)));
return
cpack
(
cimag
(
z
),
-
creal
(
z
));
z
=
casin
(
CMPLX
(
-
cimag
(
z
),
creal
(
z
)));
return
CMPLX
(
cimag
(
z
),
-
creal
(
z
));
}
src/complex/casinhf.c
浏览文件 @
cfbaba79
...
...
@@ -2,6 +2,6 @@
float
complex
casinhf
(
float
complex
z
)
{
z
=
casinf
(
cpackf
(
-
cimagf
(
z
),
crealf
(
z
)));
return
cpackf
(
cimagf
(
z
),
-
crealf
(
z
));
z
=
casinf
(
CMPLXF
(
-
cimagf
(
z
),
crealf
(
z
)));
return
CMPLXF
(
cimagf
(
z
),
-
crealf
(
z
));
}
src/complex/casinhl.c
浏览文件 @
cfbaba79
...
...
@@ -8,7 +8,7 @@ long double complex casinhl(long double complex z)
#else
long
double
complex
casinhl
(
long
double
complex
z
)
{
z
=
casinl
(
cpackl
(
-
cimagl
(
z
),
creall
(
z
)));
return
cpackl
(
cimagl
(
z
),
-
creall
(
z
));
z
=
casinl
(
CMPLXL
(
-
cimagl
(
z
),
creall
(
z
)));
return
CMPLXL
(
cimagl
(
z
),
-
creall
(
z
));
}
#endif
src/complex/casinl.c
浏览文件 @
cfbaba79
...
...
@@ -14,7 +14,7 @@ long double complex casinl(long double complex z)
x
=
creall
(
z
);
y
=
cimagl
(
z
);
w
=
cpackl
(
1
.
0
-
(
x
-
y
)
*
(
x
+
y
),
-
2
.
0
*
x
*
y
);
return
clogl
(
cpackl
(
-
y
,
x
)
+
csqrtl
(
w
));
w
=
CMPLXL
(
1
.
0
-
(
x
-
y
)
*
(
x
+
y
),
-
2
.
0
*
x
*
y
);
return
clogl
(
CMPLXL
(
-
y
,
x
)
+
csqrtl
(
w
));
}
#endif
src/complex/catanh.c
浏览文件 @
cfbaba79
...
...
@@ -4,6 +4,6 @@
double
complex
catanh
(
double
complex
z
)
{
z
=
catan
(
cpack
(
-
cimag
(
z
),
creal
(
z
)));
return
cpack
(
cimag
(
z
),
-
creal
(
z
));
z
=
catan
(
CMPLX
(
-
cimag
(
z
),
creal
(
z
)));
return
CMPLX
(
cimag
(
z
),
-
creal
(
z
));
}
src/complex/catanhf.c
浏览文件 @
cfbaba79
...
...
@@ -2,6 +2,6 @@
float
complex
catanhf
(
float
complex
z
)
{
z
=
catanf
(
cpackf
(
-
cimagf
(
z
),
crealf
(
z
)));
return
cpackf
(
cimagf
(
z
),
-
crealf
(
z
));
z
=
catanf
(
CMPLXF
(
-
cimagf
(
z
),
crealf
(
z
)));
return
CMPLXF
(
cimagf
(
z
),
-
crealf
(
z
));
}
src/complex/catanhl.c
浏览文件 @
cfbaba79
...
...
@@ -8,7 +8,7 @@ long double complex catanhl(long double complex z)
#else
long
double
complex
catanhl
(
long
double
complex
z
)
{
z
=
catanl
(
cpackl
(
-
cimagl
(
z
),
creall
(
z
)));
return
cpackl
(
cimagl
(
z
),
-
creall
(
z
));
z
=
catanl
(
CMPLXL
(
-
cimagl
(
z
),
creall
(
z
)));
return
CMPLXL
(
cimagl
(
z
),
-
creall
(
z
));
}
#endif
src/complex/ccos.c
浏览文件 @
cfbaba79
...
...
@@ -4,5 +4,5 @@
double
complex
ccos
(
double
complex
z
)
{
return
ccosh
(
cpack
(
-
cimag
(
z
),
creal
(
z
)));
return
ccosh
(
CMPLX
(
-
cimag
(
z
),
creal
(
z
)));
}
src/complex/ccosf.c
浏览文件 @
cfbaba79
...
...
@@ -2,5 +2,5 @@
float
complex
ccosf
(
float
complex
z
)
{
return
ccoshf
(
cpackf
(
-
cimagf
(
z
),
crealf
(
z
)));
return
ccoshf
(
CMPLXF
(
-
cimagf
(
z
),
crealf
(
z
)));
}
src/complex/ccosh.c
浏览文件 @
cfbaba79
...
...
@@ -55,23 +55,23 @@ double complex ccosh(double complex z)
/* Handle the nearly-non-exceptional cases where x and y are finite. */
if
(
ix
<
0x7ff00000
&&
iy
<
0x7ff00000
)
{
if
((
iy
|
ly
)
==
0
)
return
cpack
(
cosh
(
x
),
x
*
y
);
return
CMPLX
(
cosh
(
x
),
x
*
y
);
if
(
ix
<
0x40360000
)
/* small x: normal case */
return
cpack
(
cosh
(
x
)
*
cos
(
y
),
sinh
(
x
)
*
sin
(
y
));
return
CMPLX
(
cosh
(
x
)
*
cos
(
y
),
sinh
(
x
)
*
sin
(
y
));
/* |x| >= 22, so cosh(x) ~= exp(|x|) */
if
(
ix
<
0x40862e42
)
{
/* x < 710: exp(|x|) won't overflow */
h
=
exp
(
fabs
(
x
))
*
0
.
5
;
return
cpack
(
h
*
cos
(
y
),
copysign
(
h
,
x
)
*
sin
(
y
));
return
CMPLX
(
h
*
cos
(
y
),
copysign
(
h
,
x
)
*
sin
(
y
));
}
else
if
(
ix
<
0x4096bbaa
)
{
/* x < 1455: scale to avoid overflow */
z
=
__ldexp_cexp
(
cpack
(
fabs
(
x
),
y
),
-
1
);
return
cpack
(
creal
(
z
),
cimag
(
z
)
*
copysign
(
1
,
x
));
z
=
__ldexp_cexp
(
CMPLX
(
fabs
(
x
),
y
),
-
1
);
return
CMPLX
(
creal
(
z
),
cimag
(
z
)
*
copysign
(
1
,
x
));
}
else
{
/* x >= 1455: the result always overflows */
h
=
huge
*
x
;
return
cpack
(
h
*
h
*
cos
(
y
),
h
*
sin
(
y
));
return
CMPLX
(
h
*
h
*
cos
(
y
),
h
*
sin
(
y
));
}
}
...
...
@@ -85,7 +85,7 @@ double complex ccosh(double complex z)
* the same as d(NaN).
*/
if
((
ix
|
lx
)
==
0
&&
iy
>=
0x7ff00000
)
return
cpack
(
y
-
y
,
copysign
(
0
,
x
*
(
y
-
y
)));
return
CMPLX
(
y
-
y
,
copysign
(
0
,
x
*
(
y
-
y
)));
/*
* cosh(+-Inf +- I 0) = +Inf + I (+-)(+-)0.
...
...
@@ -95,8 +95,8 @@ double complex ccosh(double complex z)
*/
if
((
iy
|
ly
)
==
0
&&
ix
>=
0x7ff00000
)
{
if
(((
hx
&
0xfffff
)
|
lx
)
==
0
)
return
cpack
(
x
*
x
,
copysign
(
0
,
x
)
*
y
);
return
cpack
(
x
*
x
,
copysign
(
0
,
(
x
+
x
)
*
y
));
return
CMPLX
(
x
*
x
,
copysign
(
0
,
x
)
*
y
);
return
CMPLX
(
x
*
x
,
copysign
(
0
,
(
x
+
x
)
*
y
));
}
/*
...
...
@@ -108,7 +108,7 @@ double complex ccosh(double complex z)
* nonzero x. Choice = don't raise (except for signaling NaNs).
*/
if
(
ix
<
0x7ff00000
&&
iy
>=
0x7ff00000
)
return
cpack
(
y
-
y
,
x
*
(
y
-
y
));
return
CMPLX
(
y
-
y
,
x
*
(
y
-
y
));
/*
* cosh(+-Inf + I NaN) = +Inf + I d(NaN).
...
...
@@ -121,8 +121,8 @@ double complex ccosh(double complex z)
*/
if
(
ix
>=
0x7ff00000
&&
((
hx
&
0xfffff
)
|
lx
)
==
0
)
{
if
(
iy
>=
0x7ff00000
)
return
cpack
(
x
*
x
,
x
*
(
y
-
y
));
return
cpack
((
x
*
x
)
*
cos
(
y
),
x
*
sin
(
y
));
return
CMPLX
(
x
*
x
,
x
*
(
y
-
y
));
return
CMPLX
((
x
*
x
)
*
cos
(
y
),
x
*
sin
(
y
));
}
/*
...
...
@@ -136,5 +136,5 @@ double complex ccosh(double complex z)
* Optionally raises the invalid floating-point exception for finite
* nonzero y. Choice = don't raise (except for signaling NaNs).
*/
return
cpack
((
x
*
x
)
*
(
y
-
y
),
(
x
+
x
)
*
(
y
-
y
));
return
CMPLX
((
x
*
x
)
*
(
y
-
y
),
(
x
+
x
)
*
(
y
-
y
));
}
src/complex/ccoshf.c
浏览文件 @
cfbaba79
...
...
@@ -48,43 +48,43 @@ float complex ccoshf(float complex z)
if
(
ix
<
0x7f800000
&&
iy
<
0x7f800000
)
{
if
(
iy
==
0
)
return
cpackf
(
coshf
(
x
),
x
*
y
);
return
CMPLXF
(
coshf
(
x
),
x
*
y
);
if
(
ix
<
0x41100000
)
/* small x: normal case */
return
cpackf
(
coshf
(
x
)
*
cosf
(
y
),
sinhf
(
x
)
*
sinf
(
y
));
return
CMPLXF
(
coshf
(
x
)
*
cosf
(
y
),
sinhf
(
x
)
*
sinf
(
y
));
/* |x| >= 9, so cosh(x) ~= exp(|x|) */
if
(
ix
<
0x42b17218
)
{
/* x < 88.7: expf(|x|) won't overflow */
h
=
expf
(
fabsf
(
x
))
*
0
.
5
f
;
return
cpackf
(
h
*
cosf
(
y
),
copysignf
(
h
,
x
)
*
sinf
(
y
));
return
CMPLXF
(
h
*
cosf
(
y
),
copysignf
(
h
,
x
)
*
sinf
(
y
));
}
else
if
(
ix
<
0x4340b1e7
)
{
/* x < 192.7: scale to avoid overflow */
z
=
__ldexp_cexpf
(
cpackf
(
fabsf
(
x
),
y
),
-
1
);
return
cpackf
(
crealf
(
z
),
cimagf
(
z
)
*
copysignf
(
1
,
x
));
z
=
__ldexp_cexpf
(
CMPLXF
(
fabsf
(
x
),
y
),
-
1
);
return
CMPLXF
(
crealf
(
z
),
cimagf
(
z
)
*
copysignf
(
1
,
x
));
}
else
{
/* x >= 192.7: the result always overflows */
h
=
huge
*
x
;
return
cpackf
(
h
*
h
*
cosf
(
y
),
h
*
sinf
(
y
));
return
CMPLXF
(
h
*
h
*
cosf
(
y
),
h
*
sinf
(
y
));
}
}
if
(
ix
==
0
&&
iy
>=
0x7f800000
)
return
cpackf
(
y
-
y
,
copysignf
(
0
,
x
*
(
y
-
y
)));
return
CMPLXF
(
y
-
y
,
copysignf
(
0
,
x
*
(
y
-
y
)));
if
(
iy
==
0
&&
ix
>=
0x7f800000
)
{
if
((
hx
&
0x7fffff
)
==
0
)
return
cpackf
(
x
*
x
,
copysignf
(
0
,
x
)
*
y
);
return
cpackf
(
x
*
x
,
copysignf
(
0
,
(
x
+
x
)
*
y
));
return
CMPLXF
(
x
*
x
,
copysignf
(
0
,
x
)
*
y
);
return
CMPLXF
(
x
*
x
,
copysignf
(
0
,
(
x
+
x
)
*
y
));
}
if
(
ix
<
0x7f800000
&&
iy
>=
0x7f800000
)
return
cpackf
(
y
-
y
,
x
*
(
y
-
y
));
return
CMPLXF
(
y
-
y
,
x
*
(
y
-
y
));
if
(
ix
>=
0x7f800000
&&
(
hx
&
0x7fffff
)
==
0
)
{
if
(
iy
>=
0x7f800000
)
return
cpackf
(
x
*
x
,
x
*
(
y
-
y
));
return
cpackf
((
x
*
x
)
*
cosf
(
y
),
x
*
sinf
(
y
));
return
CMPLXF
(
x
*
x
,
x
*
(
y
-
y
));
return
CMPLXF
((
x
*
x
)
*
cosf
(
y
),
x
*
sinf
(
y
));
}
return
cpackf
((
x
*
x
)
*
(
y
-
y
),
(
x
+
x
)
*
(
y
-
y
));
return
CMPLXF
((
x
*
x
)
*
(
y
-
y
),
(
x
+
x
)
*
(
y
-
y
));
}
src/complex/ccosl.c
浏览文件 @
cfbaba79
...
...
@@ -8,6 +8,6 @@ long double complex ccosl(long double complex z)
#else
long
double
complex
ccosl
(
long
double
complex
z
)
{
return
ccoshl
(
cpackl
(
-
cimagl
(
z
),
creall
(
z
)));
return
ccoshl
(
CMPLXL
(
-
cimagl
(
z
),
creall
(
z
)));
}
#endif
src/complex/cexp.c
浏览文件 @
cfbaba79
...
...
@@ -44,22 +44,22 @@ double complex cexp(double complex z)
/* cexp(x + I 0) = exp(x) + I 0 */
if
((
hy
|
ly
)
==
0
)
return
cpack
(
exp
(
x
),
y
);
return
CMPLX
(
exp
(
x
),
y
);
EXTRACT_WORDS
(
hx
,
lx
,
x
);
/* cexp(0 + I y) = cos(y) + I sin(y) */
if
(((
hx
&
0x7fffffff
)
|
lx
)
==
0
)
return
cpack
(
cos
(
y
),
sin
(
y
));
return
CMPLX
(
cos
(
y
),
sin
(
y
));
if
(
hy
>=
0x7ff00000
)
{
if
(
lx
!=
0
||
(
hx
&
0x7fffffff
)
!=
0x7ff00000
)
{
/* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */
return
cpack
(
y
-
y
,
y
-
y
);
return
CMPLX
(
y
-
y
,
y
-
y
);
}
else
if
(
hx
&
0x80000000
)
{
/* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */
return
cpack
(
0
.
0
,
0
.
0
);
return
CMPLX
(
0
.
0
,
0
.
0
);
}
else
{
/* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */
return
cpack
(
x
,
y
-
y
);
return
CMPLX
(
x
,
y
-
y
);
}
}
...
...
@@ -78,6 +78,6 @@ double complex cexp(double complex z)
* - x = NaN (spurious inexact exception from y)
*/
exp_x
=
exp
(
x
);
return
cpack
(
exp_x
*
cos
(
y
),
exp_x
*
sin
(
y
));
return
CMPLX
(
exp_x
*
cos
(
y
),
exp_x
*
sin
(
y
));
}
}
src/complex/cexpf.c
浏览文件 @
cfbaba79
...
...
@@ -44,22 +44,22 @@ float complex cexpf(float complex z)
/* cexp(x + I 0) = exp(x) + I 0 */
if
(
hy
==
0
)
return
cpackf
(
expf
(
x
),
y
);
return
CMPLXF
(
expf
(
x
),
y
);
GET_FLOAT_WORD
(
hx
,
x
);
/* cexp(0 + I y) = cos(y) + I sin(y) */
if
((
hx
&
0x7fffffff
)
==
0
)
return
cpackf
(
cosf
(
y
),
sinf
(
y
));
return
CMPLXF
(
cosf
(
y
),
sinf
(
y
));
if
(
hy
>=
0x7f800000
)
{
if
((
hx
&
0x7fffffff
)
!=
0x7f800000
)
{
/* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */
return
cpackf
(
y
-
y
,
y
-
y
);
return
CMPLXF
(
y
-
y
,
y
-
y
);
}
else
if
(
hx
&
0x80000000
)
{
/* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */
return
cpackf
(
0
.
0
,
0
.
0
);
return
CMPLXF
(
0
.
0
,
0
.
0
);
}
else
{
/* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */
return
cpackf
(
x
,
y
-
y
);
return
CMPLXF
(
x
,
y
-
y
);
}
}
...
...
@@ -78,6 +78,6 @@ float complex cexpf(float complex z)
* - x = NaN (spurious inexact exception from y)
*/
exp_x
=
expf
(
x
);
return
cpackf
(
exp_x
*
cosf
(
y
),
exp_x
*
sinf
(
y
));
return
CMPLXF
(
exp_x
*
cosf
(
y
),
exp_x
*
sinf
(
y
));
}
}
src/complex/clog.c
浏览文件 @
cfbaba79
...
...
@@ -10,5 +10,5 @@ double complex clog(double complex z)
r
=
cabs
(
z
);
phi
=
carg
(
z
);
return
cpack
(
log
(
r
),
phi
);
return
CMPLX
(
log
(
r
),
phi
);
}
src/complex/clogf.c
浏览文件 @
cfbaba79
...
...
@@ -8,5 +8,5 @@ float complex clogf(float complex z)
r
=
cabsf
(
z
);
phi
=
cargf
(
z
);
return
cpackf
(
logf
(
r
),
phi
);
return
CMPLXF
(
logf
(
r
),
phi
);
}
src/complex/clogl.c
浏览文件 @
cfbaba79
...
...
@@ -13,6 +13,6 @@ long double complex clogl(long double complex z)
r
=
cabsl
(
z
);
phi
=
cargl
(
z
);
return
cpackl
(
logl
(
r
),
phi
);
return
CMPLXL
(
logl
(
r
),
phi
);
}
#endif
src/complex/conj.c
浏览文件 @
cfbaba79
...
...
@@ -2,5 +2,5 @@
double
complex
conj
(
double
complex
z
)
{
return
cpack
(
creal
(
z
),
-
cimag
(
z
));
return
CMPLX
(
creal
(
z
),
-
cimag
(
z
));
}
src/complex/conjf.c
浏览文件 @
cfbaba79
...
...
@@ -2,5 +2,5 @@
float
complex
conjf
(
float
complex
z
)
{
return
cpackf
(
crealf
(
z
),
-
cimagf
(
z
));
return
CMPLXF
(
crealf
(
z
),
-
cimagf
(
z
));
}
src/complex/conjl.c
浏览文件 @
cfbaba79
...
...
@@ -2,5 +2,5 @@
long
double
complex
conjl
(
long
double
complex
z
)
{
return
cpackl
(
creall
(
z
),
-
cimagl
(
z
));
return
CMPLXL
(
creall
(
z
),
-
cimagl
(
z
));
}
src/complex/cproj.c
浏览文件 @
cfbaba79
...
...
@@ -3,6 +3,6 @@
double
complex
cproj
(
double
complex
z
)
{
if
(
isinf
(
creal
(
z
))
||
isinf
(
cimag
(
z
)))
return
cpack
(
INFINITY
,
copysign
(
0
.
0
,
creal
(
z
)));
return
CMPLX
(
INFINITY
,
copysign
(
0
.
0
,
creal
(
z
)));
return
z
;
}
src/complex/cprojf.c
浏览文件 @
cfbaba79
...
...
@@ -3,6 +3,6 @@
float
complex
cprojf
(
float
complex
z
)
{
if
(
isinf
(
crealf
(
z
))
||
isinf
(
cimagf
(
z
)))
return
cpackf
(
INFINITY
,
copysignf
(
0
.
0
,
crealf
(
z
)));
return
CMPLXF
(
INFINITY
,
copysignf
(
0
.
0
,
crealf
(
z
)));
return
z
;
}
src/complex/cprojl.c
浏览文件 @
cfbaba79
...
...
@@ -9,7 +9,7 @@ long double complex cprojl(long double complex z)
long
double
complex
cprojl
(
long
double
complex
z
)
{
if
(
isinf
(
creall
(
z
))
||
isinf
(
cimagl
(
z
)))
return
cpackl
(
INFINITY
,
copysignl
(
0
.
0
,
creall
(
z
)));
return
CMPLXL
(
INFINITY
,
copysignl
(
0
.
0
,
creall
(
z
)));
return
z
;
}
#endif
src/complex/csin.c
浏览文件 @
cfbaba79
...
...
@@ -4,6 +4,6 @@
double
complex
csin
(
double
complex
z
)
{
z
=
csinh
(
cpack
(
-
cimag
(
z
),
creal
(
z
)));
return
cpack
(
cimag
(
z
),
-
creal
(
z
));
z
=
csinh
(
CMPLX
(
-
cimag
(
z
),
creal
(
z
)));
return
CMPLX
(
cimag
(
z
),
-
creal
(
z
));
}
src/complex/csinf.c
浏览文件 @
cfbaba79
...
...
@@ -2,6 +2,6 @@
float
complex
csinf
(
float
complex
z
)
{
z
=
csinhf
(
cpackf
(
-
cimagf
(
z
),
crealf
(
z
)));
return
cpackf
(
cimagf
(
z
),
-
crealf
(
z
));
z
=
csinhf
(
CMPLXF
(
-
cimagf
(
z
),
crealf
(
z
)));
return
CMPLXF
(
cimagf
(
z
),
-
crealf
(
z
));
}
src/complex/csinh.c
浏览文件 @
cfbaba79
...
...
@@ -55,23 +55,23 @@ double complex csinh(double complex z)
/* Handle the nearly-non-exceptional cases where x and y are finite. */
if
(
ix
<
0x7ff00000
&&
iy
<
0x7ff00000
)
{
if
((
iy
|
ly
)
==
0
)
return
cpack
(
sinh
(
x
),
y
);
return
CMPLX
(
sinh
(
x
),
y
);
if
(
ix
<
0x40360000
)
/* small x: normal case */
return
cpack
(
sinh
(
x
)
*
cos
(
y
),
cosh
(
x
)
*
sin
(
y
));
return
CMPLX
(
sinh
(
x
)
*
cos
(
y
),
cosh
(
x
)
*
sin
(
y
));
/* |x| >= 22, so cosh(x) ~= exp(|x|) */
if
(
ix
<
0x40862e42
)
{
/* x < 710: exp(|x|) won't overflow */
h
=
exp
(
fabs
(
x
))
*
0
.
5
;
return
cpack
(
copysign
(
h
,
x
)
*
cos
(
y
),
h
*
sin
(
y
));
return
CMPLX
(
copysign
(
h
,
x
)
*
cos
(
y
),
h
*
sin
(
y
));
}
else
if
(
ix
<
0x4096bbaa
)
{
/* x < 1455: scale to avoid overflow */
z
=
__ldexp_cexp
(
cpack
(
fabs
(
x
),
y
),
-
1
);
return
cpack
(
creal
(
z
)
*
copysign
(
1
,
x
),
cimag
(
z
));
z
=
__ldexp_cexp
(
CMPLX
(
fabs
(
x
),
y
),
-
1
);
return
CMPLX
(
creal
(
z
)
*
copysign
(
1
,
x
),
cimag
(
z
));
}
else
{
/* x >= 1455: the result always overflows */
h
=
huge
*
x
;
return
cpack
(
h
*
cos
(
y
),
h
*
h
*
sin
(
y
));
return
CMPLX
(
h
*
cos
(
y
),
h
*
h
*
sin
(
y
));
}
}
...
...
@@ -85,7 +85,7 @@ double complex csinh(double complex z)
* the same as d(NaN).
*/
if
((
ix
|
lx
)
==
0
&&
iy
>=
0x7ff00000
)
return
cpack
(
copysign
(
0
,
x
*
(
y
-
y
)),
y
-
y
);
return
CMPLX
(
copysign
(
0
,
x
*
(
y
-
y
)),
y
-
y
);
/*
* sinh(+-Inf +- I 0) = +-Inf + I +-0.
...
...
@@ -94,8 +94,8 @@ double complex csinh(double complex z)
*/
if
((
iy
|
ly
)
==
0
&&
ix
>=
0x7ff00000
)
{
if
(((
hx
&
0xfffff
)
|
lx
)
==
0
)
return
cpack
(
x
,
y
);
return
cpack
(
x
,
copysign
(
0
,
y
));
return
CMPLX
(
x
,
y
);
return
CMPLX
(
x
,
copysign
(
0
,
y
));
}
/*
...
...
@@ -107,7 +107,7 @@ double complex csinh(double complex z)
* nonzero x. Choice = don't raise (except for signaling NaNs).
*/
if
(
ix
<
0x7ff00000
&&
iy
>=
0x7ff00000
)
return
cpack
(
y
-
y
,
x
*
(
y
-
y
));
return
CMPLX
(
y
-
y
,
x
*
(
y
-
y
));
/*
* sinh(+-Inf + I NaN) = +-Inf + I d(NaN).
...
...
@@ -122,8 +122,8 @@ double complex csinh(double complex z)
*/
if
(
ix
>=
0x7ff00000
&&
((
hx
&
0xfffff
)
|
lx
)
==
0
)
{
if
(
iy
>=
0x7ff00000
)
return
cpack
(
x
*
x
,
x
*
(
y
-
y
));
return
cpack
(
x
*
cos
(
y
),
INFINITY
*
sin
(
y
));
return
CMPLX
(
x
*
x
,
x
*
(
y
-
y
));
return
CMPLX
(
x
*
cos
(
y
),
INFINITY
*
sin
(
y
));
}
/*
...
...
@@ -137,5 +137,5 @@ double complex csinh(double complex z)
* Optionally raises the invalid floating-point exception for finite
* nonzero y. Choice = don't raise (except for signaling NaNs).
*/
return
cpack
((
x
*
x
)
*
(
y
-
y
),
(
x
+
x
)
*
(
y
-
y
));
return
CMPLX
((
x
*
x
)
*
(
y
-
y
),
(
x
+
x
)
*
(
y
-
y
));
}
src/complex/csinhf.c
浏览文件 @
cfbaba79
...
...
@@ -48,43 +48,43 @@ float complex csinhf(float complex z)
if
(
ix
<
0x7f800000
&&
iy
<
0x7f800000
)
{
if
(
iy
==
0
)
return
cpackf
(
sinhf
(
x
),
y
);
return
CMPLXF
(
sinhf
(
x
),
y
);
if
(
ix
<
0x41100000
)
/* small x: normal case */
return
cpackf
(
sinhf
(
x
)
*
cosf
(
y
),
coshf
(
x
)
*
sinf
(
y
));
return
CMPLXF
(
sinhf
(
x
)
*
cosf
(
y
),
coshf
(
x
)
*
sinf
(
y
));
/* |x| >= 9, so cosh(x) ~= exp(|x|) */
if
(
ix
<
0x42b17218
)
{
/* x < 88.7: expf(|x|) won't overflow */
h
=
expf
(
fabsf
(
x
))
*
0
.
5
f
;
return
cpackf
(
copysignf
(
h
,
x
)
*
cosf
(
y
),
h
*
sinf
(
y
));
return
CMPLXF
(
copysignf
(
h
,
x
)
*
cosf
(
y
),
h
*
sinf
(
y
));
}
else
if
(
ix
<
0x4340b1e7
)
{
/* x < 192.7: scale to avoid overflow */
z
=
__ldexp_cexpf
(
cpackf
(
fabsf
(
x
),
y
),
-
1
);
return
cpackf
(
crealf
(
z
)
*
copysignf
(
1
,
x
),
cimagf
(
z
));
z
=
__ldexp_cexpf
(
CMPLXF
(
fabsf
(
x
),
y
),
-
1
);
return
CMPLXF
(
crealf
(
z
)
*
copysignf
(
1
,
x
),
cimagf
(
z
));
}
else
{
/* x >= 192.7: the result always overflows */
h
=
huge
*
x
;
return
cpackf
(
h
*
cosf
(
y
),
h
*
h
*
sinf
(
y
));
return
CMPLXF
(
h
*
cosf
(
y
),
h
*
h
*
sinf
(
y
));
}
}
if
(
ix
==
0
&&
iy
>=
0x7f800000
)
return
cpackf
(
copysignf
(
0
,
x
*
(
y
-
y
)),
y
-
y
);
return
CMPLXF
(
copysignf
(
0
,
x
*
(
y
-
y
)),
y
-
y
);
if
(
iy
==
0
&&
ix
>=
0x7f800000
)
{
if
((
hx
&
0x7fffff
)
==
0
)
return
cpackf
(
x
,
y
);
return
cpackf
(
x
,
copysignf
(
0
,
y
));
return
CMPLXF
(
x
,
y
);
return
CMPLXF
(
x
,
copysignf
(
0
,
y
));
}
if
(
ix
<
0x7f800000
&&
iy
>=
0x7f800000
)
return
cpackf
(
y
-
y
,
x
*
(
y
-
y
));
return
CMPLXF
(
y
-
y
,
x
*
(
y
-
y
));
if
(
ix
>=
0x7f800000
&&
(
hx
&
0x7fffff
)
==
0
)
{
if
(
iy
>=
0x7f800000
)
return
cpackf
(
x
*
x
,
x
*
(
y
-
y
));
return
cpackf
(
x
*
cosf
(
y
),
INFINITY
*
sinf
(
y
));
return
CMPLXF
(
x
*
x
,
x
*
(
y
-
y
));
return
CMPLXF
(
x
*
cosf
(
y
),
INFINITY
*
sinf
(
y
));
}
return
cpackf
((
x
*
x
)
*
(
y
-
y
),
(
x
+
x
)
*
(
y
-
y
));
return
CMPLXF
((
x
*
x
)
*
(
y
-
y
),
(
x
+
x
)
*
(
y
-
y
));
}
src/complex/csinl.c
浏览文件 @
cfbaba79
...
...
@@ -8,7 +8,7 @@ long double complex csinl(long double complex z)
#else
long
double
complex
csinl
(
long
double
complex
z
)
{
z
=
csinhl
(
cpackl
(
-
cimagl
(
z
),
creall
(
z
)));
return
cpackl
(
cimagl
(
z
),
-
creall
(
z
));
z
=
csinhl
(
CMPLXL
(
-
cimagl
(
z
),
creall
(
z
)));
return
CMPLXL
(
cimagl
(
z
),
-
creall
(
z
));
}
#endif
src/complex/csqrt.c
浏览文件 @
cfbaba79
...
...
@@ -51,12 +51,12 @@ double complex csqrt(double complex z)
/* Handle special cases. */
if
(
z
==
0
)
return
cpack
(
0
,
b
);
return
CMPLX
(
0
,
b
);
if
(
isinf
(
b
))
return
cpack
(
INFINITY
,
b
);
return
CMPLX
(
INFINITY
,
b
);
if
(
isnan
(
a
))
{
t
=
(
b
-
b
)
/
(
b
-
b
);
/* raise invalid if b is not a NaN */
return
cpack
(
a
,
t
);
/* return NaN + NaN i */
return
CMPLX
(
a
,
t
);
/* return NaN + NaN i */
}
if
(
isinf
(
a
))
{
/*
...
...
@@ -66,9 +66,9 @@ double complex csqrt(double complex z)
* csqrt(-inf + y i) = 0 + inf i
*/
if
(
signbit
(
a
))
return
cpack
(
fabs
(
b
-
b
),
copysign
(
a
,
b
));
return
CMPLX
(
fabs
(
b
-
b
),
copysign
(
a
,
b
));
else
return
cpack
(
a
,
copysign
(
b
-
b
,
b
));
return
CMPLX
(
a
,
copysign
(
b
-
b
,
b
));
}
/*
* The remaining special case (b is NaN) is handled just fine by
...
...
@@ -87,10 +87,10 @@ double complex csqrt(double complex z)
/* Algorithm 312, CACM vol 10, Oct 1967. */
if
(
a
>=
0
)
{
t
=
sqrt
((
a
+
hypot
(
a
,
b
))
*
0
.
5
);
result
=
cpack
(
t
,
b
/
(
2
*
t
));
result
=
CMPLX
(
t
,
b
/
(
2
*
t
));
}
else
{
t
=
sqrt
((
-
a
+
hypot
(
a
,
b
))
*
0
.
5
);
result
=
cpack
(
fabs
(
b
)
/
(
2
*
t
),
copysign
(
t
,
b
));
result
=
CMPLX
(
fabs
(
b
)
/
(
2
*
t
),
copysign
(
t
,
b
));
}
/* Rescale. */
...
...
src/complex/csqrtf.c
浏览文件 @
cfbaba79
...
...
@@ -43,12 +43,12 @@ float complex csqrtf(float complex z)
/* Handle special cases. */
if
(
z
==
0
)
return
cpackf
(
0
,
b
);
return
CMPLXF
(
0
,
b
);
if
(
isinf
(
b
))
return
cpackf
(
INFINITY
,
b
);
return
CMPLXF
(
INFINITY
,
b
);
if
(
isnan
(
a
))
{
t
=
(
b
-
b
)
/
(
b
-
b
);
/* raise invalid if b is not a NaN */
return
cpackf
(
a
,
t
);
/* return NaN + NaN i */
return
CMPLXF
(
a
,
t
);
/* return NaN + NaN i */
}
if
(
isinf
(
a
))
{
/*
...
...
@@ -58,9 +58,9 @@ float complex csqrtf(float complex z)
* csqrtf(-inf + y i) = 0 + inf i
*/
if
(
signbit
(
a
))
return
cpackf
(
fabsf
(
b
-
b
),
copysignf
(
a
,
b
));
return
CMPLXF
(
fabsf
(
b
-
b
),
copysignf
(
a
,
b
));
else
return
cpackf
(
a
,
copysignf
(
b
-
b
,
b
));
return
CMPLXF
(
a
,
copysignf
(
b
-
b
,
b
));
}
/*
* The remaining special case (b is NaN) is handled just fine by
...
...
@@ -74,9 +74,9 @@ float complex csqrtf(float complex z)
*/
if
(
a
>=
0
)
{
t
=
sqrt
((
a
+
hypot
(
a
,
b
))
*
0
.
5
);
return
cpackf
(
t
,
b
/
(
2
.
0
*
t
));
return
CMPLXF
(
t
,
b
/
(
2
.
0
*
t
));
}
else
{
t
=
sqrt
((
-
a
+
hypot
(
a
,
b
))
*
0
.
5
);
return
cpackf
(
fabsf
(
b
)
/
(
2
.
0
*
t
),
copysignf
(
t
,
b
));
return
CMPLXF
(
fabsf
(
b
)
/
(
2
.
0
*
t
),
copysignf
(
t
,
b
));
}
}
src/complex/ctan.c
浏览文件 @
cfbaba79
...
...
@@ -4,6 +4,6 @@
double
complex
ctan
(
double
complex
z
)
{
z
=
ctanh
(
cpack
(
-
cimag
(
z
),
creal
(
z
)));
return
cpack
(
cimag
(
z
),
-
creal
(
z
));
z
=
ctanh
(
CMPLX
(
-
cimag
(
z
),
creal
(
z
)));
return
CMPLX
(
cimag
(
z
),
-
creal
(
z
));
}
src/complex/ctanf.c
浏览文件 @
cfbaba79
...
...
@@ -2,6 +2,6 @@
float
complex
ctanf
(
float
complex
z
)
{
z
=
ctanhf
(
cpackf
(
-
cimagf
(
z
),
crealf
(
z
)));
return
cpackf
(
cimagf
(
z
),
-
crealf
(
z
));
z
=
ctanhf
(
CMPLXF
(
-
cimagf
(
z
),
crealf
(
z
)));
return
CMPLXF
(
cimagf
(
z
),
-
crealf
(
z
));
}
src/complex/ctanh.c
浏览文件 @
cfbaba79
...
...
@@ -95,9 +95,9 @@ double complex ctanh(double complex z)
*/
if
(
ix
>=
0x7ff00000
)
{
if
((
ix
&
0xfffff
)
|
lx
)
/* x is NaN */
return
cpack
(
x
,
(
y
==
0
?
y
:
x
*
y
));
return
CMPLX
(
x
,
(
y
==
0
?
y
:
x
*
y
));
SET_HIGH_WORD
(
x
,
hx
-
0x40000000
);
/* x = copysign(1, x) */
return
cpack
(
x
,
copysign
(
0
,
isinf
(
y
)
?
y
:
sin
(
y
)
*
cos
(
y
)));
return
CMPLX
(
x
,
copysign
(
0
,
isinf
(
y
)
?
y
:
sin
(
y
)
*
cos
(
y
)));
}
/*
...
...
@@ -105,7 +105,7 @@ double complex ctanh(double complex z)
* ctanh(x +- i Inf) = NaN + i NaN
*/
if
(
!
isfinite
(
y
))
return
cpack
(
y
-
y
,
y
-
y
);
return
CMPLX
(
y
-
y
,
y
-
y
);
/*
* ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the
...
...
@@ -114,7 +114,7 @@ double complex ctanh(double complex z)
*/
if
(
ix
>=
0x40360000
)
{
/* x >= 22 */
double
exp_mx
=
exp
(
-
fabs
(
x
));
return
cpack
(
copysign
(
1
,
x
),
4
*
sin
(
y
)
*
cos
(
y
)
*
exp_mx
*
exp_mx
);
return
CMPLX
(
copysign
(
1
,
x
),
4
*
sin
(
y
)
*
cos
(
y
)
*
exp_mx
*
exp_mx
);
}
/* Kahan's algorithm */
...
...
@@ -123,5 +123,5 @@ double complex ctanh(double complex z)
s
=
sinh
(
x
);
rho
=
sqrt
(
1
+
s
*
s
);
/* = cosh(x) */
denom
=
1
+
beta
*
s
*
s
;
return
cpack
((
beta
*
rho
*
s
)
/
denom
,
t
/
denom
);
return
CMPLX
((
beta
*
rho
*
s
)
/
denom
,
t
/
denom
);
}
src/complex/ctanhf.c
浏览文件 @
cfbaba79
...
...
@@ -44,17 +44,17 @@ float complex ctanhf(float complex z)
if
(
ix
>=
0x7f800000
)
{
if
(
ix
&
0x7fffff
)
return
cpackf
(
x
,
(
y
==
0
?
y
:
x
*
y
));
return
CMPLXF
(
x
,
(
y
==
0
?
y
:
x
*
y
));
SET_FLOAT_WORD
(
x
,
hx
-
0x40000000
);
return
cpackf
(
x
,
copysignf
(
0
,
isinf
(
y
)
?
y
:
sinf
(
y
)
*
cosf
(
y
)));
return
CMPLXF
(
x
,
copysignf
(
0
,
isinf
(
y
)
?
y
:
sinf
(
y
)
*
cosf
(
y
)));
}
if
(
!
isfinite
(
y
))
return
cpackf
(
y
-
y
,
y
-
y
);
return
CMPLXF
(
y
-
y
,
y
-
y
);
if
(
ix
>=
0x41300000
)
{
/* x >= 11 */
float
exp_mx
=
expf
(
-
fabsf
(
x
));
return
cpackf
(
copysignf
(
1
,
x
),
4
*
sinf
(
y
)
*
cosf
(
y
)
*
exp_mx
*
exp_mx
);
return
CMPLXF
(
copysignf
(
1
,
x
),
4
*
sinf
(
y
)
*
cosf
(
y
)
*
exp_mx
*
exp_mx
);
}
t
=
tanf
(
y
);
...
...
@@ -62,5 +62,5 @@ float complex ctanhf(float complex z)
s
=
sinhf
(
x
);
rho
=
sqrtf
(
1
+
s
*
s
);
denom
=
1
+
beta
*
s
*
s
;
return
cpackf
((
beta
*
rho
*
s
)
/
denom
,
t
/
denom
);
return
CMPLXF
((
beta
*
rho
*
s
)
/
denom
,
t
/
denom
);
}
src/complex/ctanl.c
浏览文件 @
cfbaba79
...
...
@@ -8,7 +8,7 @@ long double complex ctanl(long double complex z)
#else
long
double
complex
ctanl
(
long
double
complex
z
)
{
z
=
ctanhl
(
cpackl
(
-
cimagl
(
z
),
creall
(
z
)));
return
cpackl
(
cimagl
(
z
),
-
creall
(
z
));
z
=
ctanhl
(
CMPLXL
(
-
cimagl
(
z
),
creall
(
z
)));
return
CMPLXL
(
cimagl
(
z
),
-
creall
(
z
));
}
#endif
src/internal/libm.h
浏览文件 @
cfbaba79
...
...
@@ -170,25 +170,12 @@ long double __p1evll(long double, const long double *, int);
#define STRICT_ASSIGN(type, lval, rval) ((lval) = (type)(rval))
#endif
/* complex */
union
dcomplex
{
double
complex
z
;
double
a
[
2
];
};
union
fcomplex
{
float
complex
z
;
float
a
[
2
];
};
union
lcomplex
{
long
double
complex
z
;
long
double
a
[
2
];
};
/* x + y*I is not supported properly by gcc */
#define cpack(x,y) ((union dcomplex){.a={(x),(y)}}.z)
#define cpackf(x,y) ((union fcomplex){.a={(x),(y)}}.z)
#define cpackl(x,y) ((union lcomplex){.a={(x),(y)}}.z)
#ifndef CMPLX
#define CMPLX(x, y) __CMPLX(x, y, double)
#define CMPLXF(x, y) __CMPLX(x, y, float)
#define CMPLXL(x, y) __CMPLX(x, y, long double)
#endif
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录