A high-performance general-purpose compute library

Functions

array setUnion (const array &first, const array &second, const bool is_unique=false)
 C++ Interface to evaluate the union of two arrays.
 
af_err af_set_union (af_array *out, const af_array first, const af_array second, const bool is_unique)
 C Interface to evaluate the union of two arrays.
 
AFAPI array setunion (const array &first, const array &second, const bool is_unique=false)
 C++ Interface to evaluate the union of two arrays.
 

Detailed Description

Evaluate the union of two arrays.

The inputs must be one-dimensional arrays. Batching is not currently supported.

An example:

// input data
int h_setA[4] = {1, 2, 3, 3};
int h_setB[4] = {3, 4, 5, 5};
af::array setA(4, h_setA);
af::array setB(4, h_setB);
af::array setAB = setUnion(setA, setB);
// setAB == { 1, 2, 3, 4, 5 };

The function can be sped up if the 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 setAB = setUnion(setA, setB, is_unique);
// setAB == { 1, 2, 3, 4, 5 };

Function Documentation

◆ af_set_union()

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

C Interface to evaluate the union of two arrays.

Parameters
[out]outunion, values in increasing order
[in]firstinput array
[in]secondinput array
[in]is_uniqueif true, skip calling unique internally
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ setUnion()

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

C++ Interface to evaluate the union of two arrays.

Parameters
[in]firstinput array
[in]secondinput array
[in]is_uniqueif true, skip calling setUnique internally
Returns
union, values in increasing order

◆ setunion()

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

C++ Interface to evaluate the union of two arrays.

Parameters
[in]firstinput array
[in]secondinput array
[in]is_uniqueif true, skip calling setUnique internally
Returns
union, values in increasing order
Deprecated
Use setUnion instead