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

Function af_set_intersect

src/api/c/set.cpp:122–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122af_err af_set_intersect(af_array* out, const af_array first,
123 const af_array second, const bool is_unique) {
124 try {
125 const ArrayInfo& first_info = getInfo(first);
126 const ArrayInfo& second_info = getInfo(second);
127
128 // TODO(umar): fix for set intersect from union
129 if (first_info.isEmpty()) { return af_retain_array(out, first); }
130
131 if (second_info.isEmpty()) { return af_retain_array(out, second); }
132
133 ARG_ASSERT(1, (first_info.isVector() || first_info.isScalar()));
134 ARG_ASSERT(1, (second_info.isVector() || second_info.isScalar()));
135
136 af_dtype first_type = first_info.getType();
137 af_dtype second_type = second_info.getType();
138
139 ARG_ASSERT(1, first_type == second_type);
140
141 af_array res;
142 switch (first_type) {
143 case f32:
144 res = setIntersect<float>(first, second, is_unique);
145 break;
146 case f64:
147 res = setIntersect<double>(first, second, is_unique);
148 break;
149 case s32: res = setIntersect<int>(first, second, is_unique); break;
150 case u32: res = setIntersect<uint>(first, second, is_unique); break;
151 case s16:
152 res = setIntersect<short>(first, second, is_unique);
153 break;
154 case u16:
155 res = setIntersect<ushort>(first, second, is_unique);
156 break;
157 case s64: res = setIntersect<intl>(first, second, is_unique); break;
158 case u64:
159 res = setIntersect<uintl>(first, second, is_unique);
160 break;
161 case b8: res = setIntersect<char>(first, second, is_unique); break;
162 case s8: res = setIntersect<schar>(first, second, is_unique); break;
163 case u8: res = setIntersect<uchar>(first, second, is_unique); break;
164 default: TYPE_ERROR(1, first_type);
165 }
166
167 std::swap(*out, res);
168 }
169 CATCHALL;
170
171 return AF_SUCCESS;
172}

Callers 1

setIntersectFunction · 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