MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / af_set_unique

Function af_set_unique

src/api/c/set.cpp:32–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32af_err af_set_unique(af_array* out, const af_array in, const bool is_sorted) {
33 try {
34 const ArrayInfo& in_info = getInfo(in);
35
36 if (in_info.isEmpty() || in_info.isScalar()) {
37 return af_retain_array(out, in);
38 }
39
40 ARG_ASSERT(1, in_info.isVector());
41
42 af_dtype type = in_info.getType();
43
44 af_array res;
45 switch (type) {
46 case f32: res = setUnique<float>(in, is_sorted); break;
47 case f64: res = setUnique<double>(in, is_sorted); break;
48 case s32: res = setUnique<int>(in, is_sorted); break;
49 case u32: res = setUnique<uint>(in, is_sorted); break;
50 case s16: res = setUnique<short>(in, is_sorted); break;
51 case u16: res = setUnique<ushort>(in, is_sorted); break;
52 case s64: res = setUnique<intl>(in, is_sorted); break;
53 case u64: res = setUnique<uintl>(in, is_sorted); break;
54 case b8: res = setUnique<char>(in, is_sorted); break;
55 case s8: res = setUnique<schar>(in, is_sorted); break;
56 case u8: res = setUnique<uchar>(in, is_sorted); break;
57 default: TYPE_ERROR(1, type);
58 }
59
60 std::swap(*out, res);
61 }
62 CATCHALL;
63
64 return AF_SUCCESS;
65}
66
67template<typename T>
68static inline af_array setUnion(const af_array first, const af_array second,

Callers 2

uniqueTestFunction · 0.50
setUniqueFunction · 0.50

Calls 6

swapFunction · 0.85
isEmptyMethod · 0.80
isVectorMethod · 0.80
af_retain_arrayFunction · 0.70
isScalarMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected