Skip to content

Commit

Permalink
feat: add specification for determining whether a sign bit is set
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Nov 15, 2023
1 parent 0f64005 commit f3de9fb
Show file tree
Hide file tree
Showing 2 changed files with 34 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 @@ -69,6 +69,7 @@ Objects in API
remainder
round
sign
signbit
sin
sinh
square
Expand Down
33 changes: 33 additions & 0 deletions src/array_api_stubs/_draft/elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"remainder",
"round",
"sign",
"signbit",
"sin",
"sinh",
"square",
Expand Down Expand Up @@ -2215,6 +2216,38 @@ def sign(x: array, /) -> array:
"""


def signbit(x: array, /) -> array:
r"""
Determines whether the sign bit is set for each element ``x_i`` of the input array ``x``.
Parameters
----------
x: array
input array. Should have a real-valued floating-point data type.
Returns
-------
out: array
an array containing the evaluated result for each element in ``x``. The returned array must have a data type of ``bool``.
Notes
-----
**Special cases**
For real-valued floating-point operands,
- If ``x_i`` is ``+0``, the result is ``False``.
- If ``x_i`` is ``-0``, the result is ``True``.
- If ``x_i`` is ``+infinity``, the result is ``False``.
- If ``x_i`` is ``-infinity``, the result is ``True``.
- If ``x_i`` is a positive (i.e., greater than ``0``) finite number, the result is ``False``.
- If ``x_i`` is a negative (i.e., less than ``0``) finite number, the result is ``True``.
- If ``x_i`` is ``NaN`` and the sign bit of ``x_i`` is ``0``, the result is ``False``.
- If ``x_i`` is ``NaN`` and the sign bit of ``x_i`` is ``1``, the result is ``True``.
"""


def sin(x: array, /) -> array:
r"""
Calculates an implementation-dependent approximation to the sine for each element ``x_i`` of the input array ``x``.
Expand Down

0 comments on commit f3de9fb

Please sign in to comment.