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

Function af_abs

src/api/c/complex.cpp:178–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178af_err af_abs(af_array *out, const af_array in) {
179 try {
180 const ArrayInfo &in_info = getInfo(in);
181 af_dtype in_type = in_info.getType();
182 af_array res;
183
184 // Convert all inputs to floats / doubles
185 af_dtype type = implicit(in_type, f32);
186 if (in_type == f16) { type = f16; }
187 if (in_info.ndims() == 0) { return af_retain_array(out, in); }
188
189 switch (type) {
190 // clang-format off
191 case f32: res = getHandle(detail::abs<float, float>(castArray<float>(in))); break;
192 case f64: res = getHandle(detail::abs<double, double>(castArray<double>(in))); break;
193 case c32: res = getHandle(detail::abs<float, cfloat>(castArray<cfloat>(in))); break;
194 case c64: res = getHandle(detail::abs<double, cdouble>(castArray<cdouble>(in))); break;
195 case f16: res = getHandle(detail::abs<half, half>(getArray<half>(in))); break;
196 // clang-format on
197 default: TYPE_ERROR(1, in_type); break;
198 }
199
200 std::swap(*out, res);
201 }
202 CATCHALL;
203 return AF_SUCCESS;
204}

Callers 1

af_powFunction · 0.85

Calls 6

implicitFunction · 0.85
swapFunction · 0.85
af_retain_arrayFunction · 0.70
getHandleFunction · 0.70
getTypeMethod · 0.45
ndimsMethod · 0.45

Tested by

no test coverage detected