在线文档教程
C++
数字 | Numerics

std::cos(std::complex)

性病::COS%28 std::Complex%29

Defined in header
template< class T > complex<T> cos( const complex<T>& z

计算复值的复余弦z...

参数

z-complex value

返回值

如果没有错误发生,则复余弦z会被归还。

处理错误和特殊情况时,就好像操作是由std::cosh(i*z),在哪里i是想象中的单位。

注记

余弦是复平面上的一个完整函数,没有分支割集。余弦的数学定义是cos z=

伊兹+伊兹

*。

二次

#include <iostream> #include <cmath> #include <complex> int main() { std::cout << std::fixed; std::complex<double> z(1, 0 // behaves like real cosine along the real line std::cout << "cos" << z << " = " << std::cos(z) << " ( cos(1) = " << std::cos(1) << ")\n"; std::complex<double> z2(0, 1 // behaves like real cosh along the imaginary line std::cout << "cos" << z2 << " = " << std::cos(z2) << " (cosh(1) = " << std::cosh(1) << ")\n"; }

二次

产出:

二次

cos(1.000000,0.000000) = (0.540302,-0.000000) ( cos(1) = 0.540302) cos(0.000000,1.000000) = (1.543081,-0.000000) (cosh(1) = 1.543081)

二次

另见

sin(std::complex)computes sine of a complex number (sin(z)) (function template)
tan(std::complex)computes tangent of a complex number (tan(z)) (function template)
acos(std::complex) (C++11)computes arc cosine of a complex number (arccos(z)) (function template)
coscomputes cosine (cos(x)) (function)
cos(std::valarray)applies the function std::cos to each element of valarray (function template)

C为首席运营官编制的文件

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/数值/复合/cos