mxnet.np.cos

cos(x, out=None, **kwargs)

Cosine, element-wise.

Parameters
  • x (ndarray or scalar) – Angle, in radians (\(2 \pi\) rad equals 360 degrees).

  • out (ndarray or None) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. The dtype of the output is the same as that of the input if the input is an ndarray.

Returns

y – The corresponding cosine values. This is a scalar if x is a scalar.

Return type

ndarray or scalar

Notes

This function only supports input type of float.

Examples

>>> np.cos(np.array([0, np.pi/2, np.pi]))
array([ 1.000000e+00, -4.371139e-08, -1.000000e+00])
>>> # Example of providing the optional output parameter
>>> out1 = np.array([0], dtype='f')
>>> out2 = np.cos(np.array([0.1]), out1)
>>> out2 is out1
True