A high-performance general-purpose compute library

Find the intersection of two sets. More...

Functions

AFAPI array setIntersect (const array &first, const array &second, const bool is_unique=false)
C++ Interface for finding the intersection of two arrays.

AFAPI af_err af_set_intersect (af_array *out, const af_array first, const af_array second, const bool is_unique)
C Interface for finding the intersection of two arrays.

AFAPI array setintersect (const array &first, const array &second, const bool is_unique=false)

Detailed Description

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:

// input data
int h_setA[4] = {1, 2, 3, 3};
int h_setB[4] = {3, 3, 4, 5};
af::array setA(4, h_setA);
af::array setB(4, h_setB);
af::array setA_B = setIntersect(setA, setB);
// setA_B == { 3 };
A multi dimensional data container.
Definition: array.h:37
AFAPI array setIntersect(const array &first, const array &second, const bool is_unique=false)
C++ Interface for finding the intersection of two arrays.

The function can be sped up if it is known that each input is sorted in increasing order and its values are unique.

// input data
int h_setA[4] = {1, 2, 3, 4};
int h_setB[4] = {2, 3, 4, 5};
af::array setA(4, h_setA);
af::array setB(4, h_setB);
const bool is_unique = true;
// is_unique flag specifies if inputs are unique,
// allows algorithm to skip internal calls to setUnique
// inputs must be unique and sorted in increasing order
af::array setA_B = setIntersect(setA, setB, is_unique);
// setA_B == { 2, 3, 4 };

◆ af_set_intersect()

 AFAPI af_err af_set_intersect ( af_array * out, const af_array first, const af_array second, const bool is_unique )

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 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

◆ setintersect()

 AFAPI array 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: