Skip to content

Commit b569b03

Browse files
authored
feat: add reciprocal to the specification
PR-URL: #802 Closes: #790
1 parent 25e7177 commit b569b03

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

spec/draft/API_specification/elementwise_functions.rst

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Objects in API
7171
positive
7272
pow
7373
real
74+
reciprocal
7475
remainder
7576
round
7677
sign

src/array_api_stubs/_draft/elementwise_functions.py

+24
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"positive",
5454
"pow",
5555
"real",
56+
"reciprocal",
5657
"remainder",
5758
"round",
5859
"sign",
@@ -2252,6 +2253,29 @@ def real(x: array, /) -> array:
22522253
"""
22532254

22542255

2256+
def reciprocal(x: array, /) -> array:
2257+
"""
2258+
Returns the reciprocal for each element ``x_i`` of the input array ``x``.
2259+
2260+
Parameters
2261+
----------
2262+
x: array
2263+
input array. Should have a floating-point data type.
2264+
2265+
Returns
2266+
-------
2267+
out: array
2268+
an array containing the element-wise results. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
2269+
2270+
Notes
2271+
-----
2272+
2273+
**Special cases**
2274+
2275+
For floating-point operands, special cases must be handled as if the operation is implemented as ``1.0 / x`` (see :func:`~array_api.divide`).
2276+
"""
2277+
2278+
22552279
def remainder(x1: array, x2: array, /) -> array:
22562280
"""
22572281
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``.

0 commit comments

Comments
 (0)