not_equal¶
- not_equal(x1: array | int | float | complex | bool, x2: array | int | float | complex | bool, /) array¶
Computes the truth value of
x1_i != x2_ifor each elementx1_iof the input arrayx1with the respective elementx2_iof the input arrayx2.- Parameters:
x1 (Union[array, int, float, complex, bool]) – first input array. May have any data type.
x2 (Union[array, int, float, complex, bool]) – second input array. Must be compatible with
x1(see Broadcasting).
- Returns:
out (array) – an array containing the element-wise results. The returned array must have a data type of
bool.
Notes
At least one of
x1orx2must be an array.
Special Cases
For real-valued floating-point operands,
If
x1_iisNaNorx2_iisNaN, the result isTrue.If
x1_iis+infinityandx2_iis-infinity, the result isTrue.If
x1_iis-infinityandx2_iis+infinity, the result isTrue.If
x1_iis a finite number,x2_iis a finite number, andx1_idoes not equalx2_i, the result isTrue.In the remaining cases, the result is
False.
For complex floating-point operands, let
a = real(x1_i),b = imag(x1_i),c = real(x2_i),d = imag(x2_i), andIf
a,b,c, ordisNaN, the result isTrue.In the remaining cases, the result is the logical OR of the equality comparison between the real values
aandc(real components) and between the real valuesbandd(imaginary components), as described above for real-valued floating-point operands (i.e.,a != c OR b != d).
Note
For discussion of complex number equality, see Complex Numbers.
Note
Comparison of arrays without a corresponding promotable data type (see Type Promotion Rules) is undefined and thus implementation-dependent.
Changed in version 2022.12: Added complex data type support.
Changed in version 2024.12: Cross-kind comparisons are explicitly left unspecified.
Changed in version 2024.12: Added scalar argument support.