|
|
Functions | |
| array | setunique (const array &input) |
| unique values | |
| void | setunique (array &values, array &indices, array &locations, const array &input) |
| array | setunion (const array &A, const array &B) |
| union of two vectors | |
| void | setunion (array &U, array &IA, array &IB, const array &A, const array &B) |
| union of two vectors and their indices | |
| array | setintersect (const array &A, const array &B) |
| intersection of two vectors | |
| void | setintersect (array &U, array &IA, array &IB, const array &A, const array &B) |
| intersection of two vectors and their indices | |
| array af::setunique | ( | const array & | input | ) |
| 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
| [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 |
| array af::setunion | ( | const array & | A, |
| const array & | B | ||
| ) |
| void af::setunion | ( | array & | U, |
| array & | IA, | ||
| array & | IB, | ||
| const array & | A, | ||
| const array & | B | ||
| ) |
union of two vectors and their indices
array a = array(seq(5));
array b = array(seq(5))-2*constant(1,5);
print(a); // 0 1 2 3 4
print(b); // -2 -1 0 1 2
array u, idxa, idxb;
setunion(u, idxa, idxb, a, b);
print(u); // -2 -1 0 1 2 3 4
print(idxa); // 0 1 2 3 4
print(idxb); // 0 1
| [out] | U | values found in either A or B |
| [out] | IA | indices of values present in A |
| [out] | IB | indices of values present in B but not in A |
| [in] | A | |
| [in] | B |
| array af::setintersect | ( | const array & | A, |
| const array & | B | ||
| ) |
| void af::setintersect | ( | array & | U, |
| array & | IA, | ||
| array & | IB, | ||
| const array & | A, | ||
| const array & | B | ||
| ) |
intersection of two vectors and their indices
array a = array(seq(5));
array b = array(seq(5))-2*constant(1,5);
print(a); // 0 1 2 3 4
print(b); // -2 -1 0 1 2
array i, idxa, idxb;
setintersect(i, idxa, idxb, a, b);
print(i); // 0 1 2
print(idxa); // 0 1 2
print(idxb); // 2 3 4
| [out] | U | values found in both A and B |
| [out] | IA | The indices of values in A present in B |
| [out] | IB | The indices of values in B present in A |
| [in] | A | |
| [in] | B |