Skip to content

feat: add reciprocal to the specification #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -70,6 +70,7 @@ Objects in API
positive
pow
real
reciprocal
remainder
round
sign
Expand Down
24 changes: 24 additions & 0 deletions src/array_api_stubs/_draft/elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"positive",
"pow",
"real",
"reciprocal",
"remainder",
"round",
"sign",
Expand Down Expand Up @@ -2224,6 +2225,29 @@ def real(x: array, /) -> array:
"""


def reciprocal(x: array, /) -> array:
"""
Returns the reciprocal for each element ``x_i`` of the input array ``x``.

Parameters
----------
x: array
input array. Should have a floating-point data type.

Returns
-------
out: array
an array containing the element-wise results. The returned array must have a floating-point data type determined by :ref:`type-promotion`.

Notes
-----

**Special cases**

For floating-point operands, special cases must be handled as if the operation is implemented as ``1.0 / x`` (see :func:`~array_api.divide`).
"""


def remainder(x1: array, x2: array, /) -> array:
"""
Returns the remainder of division for each element ``x1_i`` of the input array ``x1`` and the respective element ``x2_i`` of the input array ``x2``.
Expand Down
Loading