Skip to content

Commit

Permalink
feat: add nextafter to specification
Browse files Browse the repository at this point in the history
PR-URL: #792
Closes: #664
Reviewed-by: Ralf Gommers <ralf.gommers@gmail.com>
  • Loading branch information
kgryte committed May 2, 2024
1 parent 6a5767a commit cee4167
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/draft/API_specification/elementwise_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Objects in API
minimum
multiply
negative
nextafter
not_equal
positive
pow
Expand Down
30 changes: 30 additions & 0 deletions src/array_api_stubs/_draft/elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"minimum",
"multiply",
"negative",
"nextafter",
"not_equal",
"positive",
"pow",
Expand Down Expand Up @@ -2069,6 +2070,35 @@ def negative(x: array, /) -> array:
"""


def nextafter(x1: array, x2: array, /) -> array:
"""
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``.
Parameters
----------
x1: array
first input array. Should have a real-valued floating-point data type.
x2: array
second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have the same data type as ``x1``.
Returns
-------
out: array
an array containing the element-wise results. The returned array must have the same data type as ``x1``.
Notes
-----
**Special cases**
For real-valued floating-point operands,
- If either ``x1_i`` or ``x2_i`` is ``NaN``, the result is ``NaN``.
- If ``x1_i`` is ``-0`` and ``x2_i`` is ``+0``, the result is ``+0``.
- If ``x1_i`` is ``+0`` and ``x2_i`` is ``-0``, the result is ``-0``.
"""


def not_equal(x1: array, x2: array, /) -> array:
"""
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``.
Expand Down

0 comments on commit cee4167

Please sign in to comment.