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_iisNaNorx2_iisNaN, the result isFalse. - If
x1_iis+infinityandx2_iis+infinity, the result isTrue. - If
x1_iis-infinityandx2_iis-infinity, the result isTrue. - If
x1_iis-0andx2_iis either+0or-0, the result isTrue. - If
x1_iis+0andx2_iis either+0or-0, the result isTrue. - If
x1_iis a finite number,x2_iis a finite number, andx1_iequalsx2_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, ordisNaN, the result isFalse. - In the remaining cases, the result is the logical AND 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 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
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 2907 2908 2909 2910 2911 | |