set_intersect
- arrayfire.set_intersect(x: Array, y: Array, /, *, is_unique: bool = False) Array
Calculates the intersection of two ArrayFire arrays, returning elements common to both arrays.
Parameters
- xArray
The first input 1D ArrayFire array.
- yArray
The second input 1D ArrayFire array.
- is_uniquebool, optional, keyword-only, default: False
Specifies whether both input arrays contain unique elements. If set to True, the function assumes that the arrays do not have repeated elements, which can optimize the intersection operation.
Returns
- Array
An ArrayFire array containing the intersection of x and y. The returned array includes elements that are common to both input arrays. If is_unique is True, the function assumes no duplicates within each input array, potentially enhancing performance.
Examples
>>> import arrayfire as af >>> a = af.Array([1, 2, 3, 4, 5]) >>> b = af.Array([4, 5, 6, 7, 8]) >>> af.set_intersect(a, b) [2 1 1 1] 4.0000 5.0000
Note
Both x and y must be 1D arrays.
The is_unique parameter can be used to optimize the intersection calculation when both input arrays are known to contain unique elements.