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

Function setUnion

src/backend/cpu/set.cpp:54–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52
53template<typename T>
54Array<T> setUnion(const Array<T> &first, const Array<T> &second,
55 const bool is_unique) {
56 Array<T> uFirst = first;
57 Array<T> uSecond = second;
58
59 if (!is_unique) {
60 // FIXME: Perhaps copy + unique would do ?
61 uFirst = setUnique(first, false);
62 uSecond = setUnique(second, false);
63 }
64
65 dim_t first_elements = uFirst.elements();
66 dim_t second_elements = uSecond.elements();
67 dim_t elements = first_elements + second_elements;
68
69 Array<T> out = createEmptyArray<T>(af::dim4(elements));
70
71 T *ptr = out.get();
72 T *last = set_union(uFirst.get(), uFirst.get() + first_elements,
73 uSecond.get(), uSecond.get() + second_elements, ptr);
74
75 auto dist = static_cast<dim_t>(distance(ptr, last));
76 dim4 dims(dist, 1, 1, 1);
77 out.resetDims(dims);
78
79 return out;
80}
81
82template<typename T>
83Array<T> setIntersect(const Array<T> &first, const Array<T> &second,

Callers

nothing calls this directly

Calls 6

setUniqueFunction · 0.70
dim4Class · 0.70
distanceFunction · 0.50
elementsMethod · 0.45
getMethod · 0.45
resetDimsMethod · 0.45

Tested by

no test coverage detected