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

Function af_median

src/api/c/median.cpp:182–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182af_err af_median(af_array* out, const af_array in, const dim_t dim) {
183 try {
184 ARG_ASSERT(2, (dim >= 0 && dim <= 4));
185
186 af_array output = 0;
187 const ArrayInfo& info = getInfo(in);
188
189 ARG_ASSERT(1, info.ndims() > 0);
190 af_dtype type = info.getType();
191 switch (type) {
192 case f64: output = median<double>(in, dim); break;
193 case f32: output = median<float>(in, dim); break;
194 case s32: output = median<int>(in, dim); break;
195 case u32: output = median<uint>(in, dim); break;
196 case s16: output = median<short>(in, dim); break;
197 case u16: output = median<ushort>(in, dim); break;
198 case s8: output = median<schar>(in, dim); break;
199 case u8: output = median<uchar>(in, dim); break;
200 default: TYPE_ERROR(1, type);
201 }
202 std::swap(*out, output);
203 }
204 CATCHALL;
205 return AF_SUCCESS;
206}

Callers 1

medianFunction · 0.50

Calls 3

swapFunction · 0.85
ndimsMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected