numpy.cos #

麻木的。cos ( x , / , out=None , * , where=True , casting='same_kind' , order='K' , dtype=None , subok=True [ , signature , extobj ] ) = <ufunc 'cos'> #

余弦元素方面。

参数
x类似数组

以弧度为单位的输入数组。

out ndarray、None 或 ndarray 和 None 的元组,可选

存储结果的位置。如果提供,它必须具有输入广播到的形状。如果未提供或无,则返回新分配的数组。元组(只能作为关键字参数)的长度必须等于输出的数量。

其中array_like,可选

该条件通过输入广播。在条件为 True 的位置,输出数组将设置为 ufunc 结果。在其他地方,输出数组将保留其原始值。请注意,如果通过 default 创建 未初始化的outout=None数组,则其中条件为 False 的位置将保持未初始化状态。

**夸格

对于其他仅关键字参数,请参阅 ufunc 文档

返回
y ndarray

对应的余弦值。如果x是标量,则这是标量。

笔记

如果提供了out,该函数会将结果写入其中,并返回对out 的引用。 (参见示例)

参考

M. Abramowitz 和 IA Stegun,数学函数手册。纽约州纽约:多佛,1972 年。

例子

>>> np.cos(np.array([0, np.pi/2, np.pi]))
array([  1.00000000e+00,   6.12303177e-17,  -1.00000000e+00])
>>>
>>> # Example of providing the optional output parameter
>>> out1 = np.array([0], dtype='d')
>>> out2 = np.cos([0.1], out1)
>>> out2 is out1
True
>>>
>>> # Example of ValueError due to provision of shape mis-matched `out`
>>> np.cos(np.zeros((3,3)),np.zeros((2,2)))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: operands could not be broadcast together with shapes (3,3) (2,2)