r"""Element-wise :math:`\cos(x)` function. Calculates an approximation to the cosine for each element :math:`x_i` of the input tensor :math:`x`. Each element :math:`x_i` is assumed to be expressed in radians. This function has domain ``(-infinity, +infinity)`` and codomain ``[-1, +
(x)
| 1086 | |
| 1087 | |
| 1088 | def cos(x): |
| 1089 | r"""Element-wise :math:`\cos(x)` function. |
| 1090 | |
| 1091 | Calculates an approximation to the cosine for each element :math:`x_i` of the input tensor :math:`x`. |
| 1092 | Each element :math:`x_i` is assumed to be expressed in radians. |
| 1093 | |
| 1094 | This function has domain ``(-infinity, +infinity)`` and codomain ``[-1, +1]``. |
| 1095 | |
| 1096 | Args: |
| 1097 | x: input tensor whose elements are each expressed in radians. Should have a floating-point data type. |
| 1098 | |
| 1099 | Returns: |
| 1100 | a tensor containing the cosine of each element in :math:`x`. |
| 1101 | The returned tensor must have a floating-point data type determined by :ref:`dtype-promotion`. |
| 1102 | |
| 1103 | Examples: |
| 1104 | >>> F.cos(0) |
| 1105 | Tensor(1.0, device=xpux:0) |
| 1106 | |
| 1107 | Element-wise cosine: |
| 1108 | |
| 1109 | >>> import math |
| 1110 | >>> x = Tensor([0, math.pi/2, math.pi]) |
| 1111 | >>> F.cos(x) |
| 1112 | Tensor([ 1. -0. -1.], device=xpux:0) |
| 1113 | """ |
| 1114 | return _elwise(x, mode=Elemwise.Mode.COS) |
| 1115 | |
| 1116 | |
| 1117 | def sin(x): |