Skip to content

Commit baabad4

Browse files
committed
Add warning concerning older C versions
1 parent b88e296 commit baabad4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

spec/API_specification/array_api/elementwise_functions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,11 @@ def tanh(x: array, /) -> array:
13821382
- If ``a`` is ``NaN`` and ``b`` is a nonzero number, the result is ``NaN + NaN j``.
13831383
- If ``a`` is ``NaN`` and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
13841384
1385+
.. warning::
1386+
For historical reasons stemming from the C standard, array libraries may not return the expected result when ``a`` is ``+0`` and ``b`` is either ``+infinity`` or ``NaN``. The result should be ``+0 + NaN j`` in both cases; however, for libraries compiled against older C versions, the result may be ``NaN + NaN j``.
1387+
1388+
Array libraries are not required to patch these older C versions, and, thus, users are advised that results may vary across array library implementations for these special cases.
1389+
13851390
.. note::
13861391
The hyperbolic tangent is an analytical function on the complex plane and has no branch cuts. The function is periodic, with period :math:`\pi j`, with respect to the imaginary component and has first order poles along the imaginary line at coordinates :math:`(0, \pi (\frac{1}{2} + n))`. However, IEEE 754 binary floating-point representation cannot represent :math:`\pi / 2` exactly, and, thus, no argument value is possible such that a pole error occurs.
13871392

0 commit comments

Comments
 (0)