mindspore.mint.cos

View Source On Gitee
mindspore.mint.cos(input)[source]

Computes cosine of input element-wise.

outi=cos(xi)

Warning

Using float64 may cause a problem of missing precision.

Parameters

input (Tensor) – The input tensor.

Returns

Tensor

Supported Platforms:

Ascend

Examples

>>> 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])