Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4de335

Browse files
authored
Add complex number support to not_equal (#529)
1 parent 73a1a91 commit f4de335

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

spec/API_specification/array_api/array_object.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,26 @@ def __ne__(self: array, other: Union[int, float, bool, array], /) -> array:
806806
"""
807807
Computes the truth value of ``self_i != other_i`` for each element of an array instance with the respective element of the array ``other``.
808808
809+
**Special Cases**
810+
811+
Let ``self`` equal ``x1`` and ``other`` equal ``x2``.
812+
813+
For real-valued floating-point operands,
814+
815+
- If ``x1_i`` is ``NaN`` or ``x2_i`` is ``NaN``, the result is ``True``.
816+
- If ``x1_i`` is ``+infinity`` and ``x2_i`` is ``-infinity``, the result is ``True``.
817+
- If ``x1_i`` is ``-infinity`` and ``x2_i`` is ``+infinity``, the result is ``True``.
818+
- If ``x1_i`` is a finite number, ``x2_i`` is a finite number, and ``x1_i`` does not equal ``x2_i``, the result is ``True``.
819+
- In the remaining cases, the result is ``False``.
820+
821+
For complex floating-point operands, let ``a = real(x1_i)``, ``b = imag(x1_i)``, ``c = real(x2_i)``, ``d = imag(x2_i)``, and
822+
823+
- If ``a``, ``b``, ``c``, or ``d`` is ``NaN``, the result is ``True``.
824+
- In the remaining cases, the result is the logical OR of the equality comparison between the real values ``a`` and ``c`` (real components) and between the real values ``b`` and ``d`` (imaginary components), as described above for real-valued floating-point operands (i.e., ``a != c OR b != d``).
825+
826+
.. note::
827+
For discussion of complex number equality, see :ref:`complex-numbers`.
828+
809829
Parameters
810830
----------
811831
self: array

spec/API_specification/array_api/elementwise_functions.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,24 @@ def not_equal(x1: array, x2: array, /) -> array:
15041504
"""
15051505
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``.
15061506
1507+
**Special Cases**
1508+
1509+
For real-valued floating-point operands,
1510+
1511+
- If ``x1_i`` is ``NaN`` or ``x2_i`` is ``NaN``, the result is ``True``.
1512+
- If ``x1_i`` is ``+infinity`` and ``x2_i`` is ``-infinity``, the result is ``True``.
1513+
- If ``x1_i`` is ``-infinity`` and ``x2_i`` is ``+infinity``, the result is ``True``.
1514+
- If ``x1_i`` is a finite number, ``x2_i`` is a finite number, and ``x1_i`` does not equal ``x2_i``, the result is ``True``.
1515+
- In the remaining cases, the result is ``False``.
1516+
1517+
For complex floating-point operands, let ``a = real(x1_i)``, ``b = imag(x1_i)``, ``c = real(x2_i)``, ``d = imag(x2_i)``, and
1518+
1519+
- If ``a``, ``b``, ``c``, or ``d`` is ``NaN``, the result is ``True``.
1520+
- In the remaining cases, the result is the logical OR of the equality comparison between the real values ``a`` and ``c`` (real components) and between the real values ``b`` and ``d`` (imaginary components), as described above for real-valued floating-point operands (i.e., ``a != c OR b != d``).
1521+
1522+
.. note::
1523+
For discussion of complex number equality, see :ref:`complex-numbers`.
1524+
15071525
Parameters
15081526
----------
15091527
x1: array

0 commit comments

Comments
 (0)