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

Function af_sort_by_key

src/api/c/sort.cpp:204–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204af_err af_sort_by_key(af_array *out_keys, af_array *out_values,
205 const af_array keys, const af_array values,
206 const unsigned dim, const bool isAscending) {
207 try {
208 const ArrayInfo &kinfo = getInfo(keys);
209 af_dtype ktype = kinfo.getType();
210
211 const ArrayInfo &vinfo = getInfo(values);
212
213 DIM_ASSERT(4, kinfo.dims() == vinfo.dims());
214 if (kinfo.elements() == 0) {
215 AF_CHECK(af_create_handle(out_keys, 0, nullptr, ktype));
216 AF_CHECK(af_create_handle(out_values, 0, nullptr, ktype));
217 return AF_SUCCESS;
218 }
219
220 TYPE_ASSERT(kinfo.isReal());
221
222 af_array oKey;
223 af_array oVal;
224
225 switch (ktype) {
226 case f32:
227 sort_by_key_tmplt<float>(&oKey, &oVal, keys, values, dim,
228 isAscending);
229 break;
230 case f64:
231 sort_by_key_tmplt<double>(&oKey, &oVal, keys, values, dim,
232 isAscending);
233 break;
234 case s32:
235 sort_by_key_tmplt<int>(&oKey, &oVal, keys, values, dim,
236 isAscending);
237 break;
238 case u32:
239 sort_by_key_tmplt<uint>(&oKey, &oVal, keys, values, dim,
240 isAscending);
241 break;
242 case s16:
243 sort_by_key_tmplt<short>(&oKey, &oVal, keys, values, dim,
244 isAscending);
245 break;
246 case u16:
247 sort_by_key_tmplt<ushort>(&oKey, &oVal, keys, values, dim,
248 isAscending);
249 break;
250 case s64:
251 sort_by_key_tmplt<intl>(&oKey, &oVal, keys, values, dim,
252 isAscending);
253 break;
254 case u64:
255 sort_by_key_tmplt<uintl>(&oKey, &oVal, keys, values, dim,
256 isAscending);
257 break;
258 case s8:
259 sort_by_key_tmplt<schar>(&oKey, &oVal, keys, values, dim,
260 isAscending);
261 break;

Callers 2

sortTestFunction · 0.50
sortFunction · 0.50

Calls 6

swapFunction · 0.85
isRealMethod · 0.80
af_create_handleFunction · 0.70
getTypeMethod · 0.45
dimsMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected