The C++ interface for setunique. More...

array setunique (const array &input)
 Unique values. More...
 
void setunique (array &values, array &indices, array &locations, const array &input)
 

Detailed Description

The C++ interface for setunique.

Returns the unique elements of a set.

Function Documentation

array af::setunique ( const array &  input)

Unique values.

array input = constant(1,5, 1);
input(1, 0) = 3;
input(2, 0) = 2;
input(3, 0) = 3;
print(input); // 1 3 2 3 1
array values = setunique(input);
print(values); // 1 2 3
Parameters
[in]inputtreated as vector
Returns
unique values
void af::setunique ( array &  values,
array &  indices,
array &  locations,
const array &  input 
)
array input = constant(1,5, 1);
input(1, 0) = 3;
input(2, 0) = 2;
input(3, 0) = 3;
print(input); // 1 3 2 3 1
array values, indices, locations;
setunique(values, indices, locations, input);
print(values); // 1 2 3
print(indices); // 0 2 1
print(locations); // 0 2 1 2 0
print(input(indices)); // 1 2 3 --> same as values
print(values(locations)); // 1 3 2 3 1 --> same as input

unique elements in a vector and their indicies

Parameters
[out]values,:The unique values from the input vector
[out]indices,:The index of the first instance of the unique value
[out]locations,:Location of each input element in the unique values vector
[in]input