Skip to content

Commit 596ef94

Browse files
authored
Add complex number support to round (#440)
* Add complex number support to `round`, `ceil`, `floor`, and `trunc` * Remove complex dtype support for `floor`, `ceil`, and `trunc`
1 parent 42eb7a0 commit 596ef94

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

spec/API_specification/array_api/elementwise_functions.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1166,8 +1166,16 @@ def round(x: array, /) -> array:
11661166
"""
11671167
Rounds each element ``x_i`` of the input array ``x`` to the nearest integer-valued number.
11681168
1169+
.. note::
1170+
For complex floating-point operands, real and imaginary components must be independently rounded to the nearest integer-valued number.
1171+
1172+
Rounded real and imaginary components must be equal to their equivalent rounded real-valued floating-point counterparts (i.e., for complex-valued ``x``, ``real(round(x))`` must equal ``round(real(x)))`` and ``imag(round(x))`` must equal ``round(imag(x))``).
1173+
11691174
**Special cases**
11701175
1176+
.. note::
1177+
For complex floating-point operands, the following special cases apply to real and imaginary components independently (e.g., if ``real(x_i)`` is ``NaN``, the rounded real component is ``NaN``).
1178+
11711179
- If ``x_i`` is already integer-valued, the result is ``x_i``.
11721180
11731181
For floating-point operands,
@@ -1182,7 +1190,7 @@ def round(x: array, /) -> array:
11821190
Parameters
11831191
----------
11841192
x: array
1185-
input array. Should have a real-valued data type.
1193+
input array. Should have a numeric data type.
11861194
11871195
Returns
11881196
-------

0 commit comments

Comments
 (0)