ccosf, ccos, ccosl
From cppreference.net
|
定义于头文件
<complex.h>
|
||
| (1) | (C99 起) | |
| (2) | (C99 起) | |
| (3) | (C99 起) | |
|
定义于头文件
<tgmath.h>
|
||
|
#define cos( z )
|
(4) | (C99 起) |
1-3)
计算
z
的复余弦值。
4)
类型泛型宏:若
z
具有类型
long
double
complex
,则调用
ccosl
;若
z
具有类型
double
complex
,则调用
ccos
;若
z
具有类型
float
complex
,则调用
ccosf
。若
z
为实数或整数,则该宏调用对应的实数函数(
cosf
、
cos
、
cosl
)。若
z
为虚数,则该宏调用函数
cosh
的对应实数版本,实现公式
cos(iy) = cosh(y)
,且返回类型为实数。
目录 |
参数
| z | - | 复参数 |
返回值
如果没有发生错误,则返回
z
的复余弦值。
错误和特殊情况的处理方式如同该操作是通过 ccosh ( I * z ) 实现的一般。
注释
余弦是复平面上的整函数,且没有分支切割。
Mathematical definition of the cosine is cos z =|
e
iz
+e -iz |
| 2 |
示例
运行此代码
#include <stdio.h> #include <math.h> #include <complex.h> int main(void) { double complex z = ccos(1); // 沿实轴表现如实余弦函数 printf("cos(1+0i) = %f%+fi ( cos(1)=%f)\n", creal(z), cimag(z), cos(1)); double complex z2 = ccos(I); // 沿虚轴表现如实双曲余弦函数 printf("cos(0+1i) = %f%+fi (cosh(1)=%f)\n", creal(z2), cimag(z2), cosh(1)); }
输出:
cos(1+0i) = 0.540302-0.000000i ( cos(1)=0.540302) cos(0+1i) = 1.543081-0.000000i (cosh(1)=1.543081)
参考文献
- C11 标准 (ISO/IEC 9899:2011):
-
- 7.3.5.4 ccos 函数 (第 191 页)
-
- 7.25 泛型数学 <tgmath.h> (第 373-375 页)
-
- G.7 泛型数学 <tgmath.h> (第 545 页)
- C99 标准 (ISO/IEC 9899:1999):
-
- 7.3.5.4 ccos 函数 (第 173 页)
-
- 7.22 泛型数学 <tgmath.h> (第 335-337 页)
-
- G.7 泛型数学 <tgmath.h> (第 480 页)
另请参阅
|
(C99)
(C99)
(C99)
|
计算复数正弦
(函数) |
|
(C99)
(C99)
(C99)
|
计算复数正切
(函数) |
|
(C99)
(C99)
(C99)
|
计算复数反余弦
(函数) |
|
(C99)
(C99)
|
计算余弦 (
cos(x)
)
(函数) |
|
C++ 文档
for
cos
|
|