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

Function setIntersect

src/backend/oneapi/set.cpp:88–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86
87template<typename T>
88Array<T> setIntersect(const Array<T> &first, const Array<T> &second,
89 const bool is_unique) {
90 Array<T> unique_first = first;
91 Array<T> unique_second = second;
92
93 if (!is_unique) {
94 unique_first = setUnique(first, false);
95 unique_second = setUnique(second, false);
96 }
97
98 size_t out_size =
99 std::max(unique_first.elements(), unique_second.elements());
100 Array<T> out = createEmptyArray<T>(dim4(out_size, 1, 1, 1));
101
102 auto dpl_policy = ::oneapi::dpl::execution::make_device_policy(getQueue());
103
104 auto first_begin = ::oneapi::dpl::begin(*unique_first.get());
105 auto first_end = first_begin + unique_first.elements();
106
107 auto second_begin = ::oneapi::dpl::begin(*unique_second.get());
108 auto second_end = second_begin + unique_second.elements();
109
110 auto out_begin = ::oneapi::dpl::begin(*out.get());
111
112 auto out_end = std::set_intersection(dpl_policy, first_begin, first_end,
113 second_begin, second_end, out_begin);
114 out.resetDims(dim4(std::distance(out_begin, out_end), 1, 1, 1));
115 return out;
116}
117
118#define INSTANTIATE(T) \
119 template Array<T> setUnique<T>(const Array<T> &in, const bool is_sorted); \

Callers

nothing calls this directly

Calls 9

beginFunction · 0.85
setUniqueFunction · 0.70
maxFunction · 0.70
dim4Class · 0.50
getQueueFunction · 0.50
distanceFunction · 0.50
elementsMethod · 0.45
getMethod · 0.45
resetDimsMethod · 0.45

Tested by

no test coverage detected