Skip to content

Commit cee4167

Browse files
authored
feat: add nextafter to specification
PR-URL: #792 Closes: #664 Reviewed-by: Ralf Gommers <[email protected]>
1 parent 6a5767a commit cee4167

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

spec/draft/API_specification/elementwise_functions.rst

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Objects in API
6666
minimum
6767
multiply
6868
negative
69+
nextafter
6970
not_equal
7071
positive
7172
pow

src/array_api_stubs/_draft/elementwise_functions.py

+30
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"minimum",
4949
"multiply",
5050
"negative",
51+
"nextafter",
5152
"not_equal",
5253
"positive",
5354
"pow",
@@ -2069,6 +2070,35 @@ def negative(x: array, /) -> array:
20692070
"""
20702071

20712072

2073+
def nextafter(x1: array, x2: array, /) -> array:
2074+
"""
2075+
Returns the next representable floating-point value for each element ``x1_i`` of the input array ``x1`` in the direction of the respective element ``x2_i`` of the input array ``x2``.
2076+
2077+
Parameters
2078+
----------
2079+
x1: array
2080+
first input array. Should have a real-valued floating-point data type.
2081+
x2: array
2082+
second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have the same data type as ``x1``.
2083+
2084+
Returns
2085+
-------
2086+
out: array
2087+
an array containing the element-wise results. The returned array must have the same data type as ``x1``.
2088+
2089+
Notes
2090+
-----
2091+
2092+
**Special cases**
2093+
2094+
For real-valued floating-point operands,
2095+
2096+
- If either ``x1_i`` or ``x2_i`` is ``NaN``, the result is ``NaN``.
2097+
- If ``x1_i`` is ``-0`` and ``x2_i`` is ``+0``, the result is ``+0``.
2098+
- If ``x1_i`` is ``+0`` and ``x2_i`` is ``-0``, the result is ``-0``.
2099+
"""
2100+
2101+
20722102
def not_equal(x1: array, x2: array, /) -> array:
20732103
"""
20742104
Computes the truth value of ``x1_i != x2_i`` for each element ``x1_i`` of the input array ``x1`` with the respective element ``x2_i`` of the input array ``x2``.

0 commit comments

Comments
 (0)