Find the intersection of two sets. The inputs must be one-dimensional arrays. Batching is not currently supported.
A simple example of finding the intersection of two sets using setIntersect() can be seen below:
int h_setA[4] = {1, 2, 3, 3};
int h_setB[4] = {3, 3, 4, 5};
The function can be sped up if it is known that each input is sorted in increasing order and its values are unique.
int h_setA[4] = {1, 2, 3, 4};
int h_setB[4] = {2, 3, 4, 5};
const bool is_unique = true;
◆ af_set_intersect()
C Interface for finding the intersection of two arrays.
- Parameters
-
[out] | out | will contain the intersection of first and second |
[in] | first | is the first input array |
[in] | second | is the second input array |
[in] | is_unique | if true, skips calling unique internally |
- Returns
- AF_SUCCESS if the execution completes properly
◆ setintersect()
AFAPI array af::setintersect |
( |
const array & |
first, |
|
|
const array & |
second, |
|
|
const bool |
is_unique = false |
|
) |
| |
C++ Interface for finding the intersection of two arrays.
- Parameters
-
[in] | first | is the first input array |
[in] | second | is the second input array |
[in] | is_unique | if true, skips calling unique internally |
- Returns
- unique values that are present in both
first
and second(intersection)
in increasing order
- Deprecated:
- Use setIntersect instead
◆ setIntersect()
AFAPI array af::setIntersect |
( |
const array & |
first, |
|
|
const array & |
second, |
|
|
const bool |
is_unique = false |
|
) |
| |
C++ Interface for finding the intersection of two arrays.
- Parameters
-
[in] | first | is the first input array |
[in] | second | is the second input array |
[in] | is_unique | if true, skips calling unique internally |
- Returns
- unique values that are present in both
first
and second(intersection)
in increasing order