mindspore.mint.cos

mindspore.mint.cos(input)[源代码]

逐元素计算输入tensor的余弦。

outi=cos(xi)

警告

如果使用float64,可能会存在精度丢失的问题。

参数:
  • input (Tensor) - 输入tensor。

返回:

Tensor

支持平台:

Ascend

样例:

>>> import mindspore
>>> # The data type of output will be float32 when `input` is in [bool, int8, uint8, int16, int32, int64].
>>> input = mindspore.tensor([0, 1, 2], mindspore.int32)
>>> mindspore.mint.cos(input)
Tensor(shape=[3], dtype=Float32, value= [ 1.00000000e+00,  5.40302306e-01, -4.16146837e-01])
>>>
>>> # Otherwise output has the same dtype as the `input`.
>>> input = mindspore.tensor([0.74, 0.04, 0.30, 0.56], mindspore.float64)
>>> mindspore.mint.cos(input)
Tensor(shape=[4], dtype=Float64, value= [ 7.38468559e-01,  9.99200107e-01,  9.55336489e-01,  8.47255111e-01])