equal
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
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x1
|
first input array. May have any data type. |
required | |
x2
|
second input array. Must be compatible with |
required |
Returns:
Name | Type | Description |
---|---|---|
out |
array
|
an array containing the element-wise results. The returned array is of data type of |
Special Cases
For real-valued floating-point operands,
- If
x1_i
isNaN
orx2_i
isNaN
, the result isFalse
. - If
x1_i
is+infinity
andx2_i
is+infinity
, the result isTrue
. - If
x1_i
is-infinity
andx2_i
is-infinity
, the result isTrue
. - If
x1_i
is-0
andx2_i
is either+0
or-0
, the result isTrue
. - If
x1_i
is+0
andx2_i
is either+0
or-0
, the result isTrue
. - If
x1_i
is a finite number,x2_i
is a finite number, andx1_i
equalsx2_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)
, and
- If
a
,b
,c
, ord
isNaN
, the result isFalse
. - In the remaining cases, the result is the logical AND of the equality comparison between the real values
a
andc
(real components) and between the real valuesb
andd
(imaginary components), as described above for real-valued floating-point operands (i.e.,a == c AND b == d
).
Examples:
>>> a = sparse.COO.from_numpy(np.array([[0, 1], [2, 0]]))
>>> b = sparse.COO.from_numpy(np.array([[0, 1], [1, 0]]))
>>> o = sparse.equal(a, b)
>>> o.todense()
array([[ True, True],
[ False, True]])
Source code in sparse/numba_backend/_common.py
2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 |
|