@@ -1766,19 +1766,38 @@ def round(x: array, /) -> array:
17661766 """
17671767
17681768def sign (x : array , / ) -> array :
1769- """
1769+ r """
17701770 Returns an indication of the sign of a number for each element ``x_i`` of the input array ``x``.
17711771
1772+ The sign function (also known as the **signum function**) of a number :math:`x_i` is defined as
1773+
1774+ .. math::
1775+ \operatorname{sign}(x_i) = \begin{cases}
1776+ 0 & \textrm{if } x_i = 0 \\
1777+ \frac{x}{|x|} & \textrm{otherwise}
1778+ \end{cases}
1779+
1780+ where :math:`|x_i|` is the absolute value of :math:`x_i`.
1781+
17721782 **Special cases**
17731783
1784+ For real-valued operands,
1785+
17741786 - If ``x_i`` is less than ``0``, the result is ``-1``.
17751787 - If ``x_i`` is either ``-0`` or ``+0``, the result is ``0``.
17761788 - If ``x_i`` is greater than ``0``, the result is ``+1``.
1789+ - If ``x_i`` is ``NaN``, the result is ``NaN``.
1790+
1791+ For complex floating-point operands, let ``a = real(x_i)``, ``b = imag(x_i)``, and
1792+
1793+ - If ``a`` is either ``-0`` or ``+0`` and ``b`` is either ``-0`` or ``+0``, the result is ``0 + 0j``.
1794+ - If ``a`` is ``NaN`` or ``b`` is ``NaN``, the result is ``NaN + NaN j``.
1795+ - In the remaining cases, special cases must be handled according to the rules of complex number division (see :func:`~array_api.divide`).
17771796
17781797 Parameters
17791798 ----------
17801799 x: array
1781- input array. Should have a real-valued data type.
1800+ input array. Should have a numeric data type.
17821801
17831802 Returns
17841803 -------
0 commit comments