| 97 | |
| 98 | template<af_op_t op> |
| 99 | static af_err af_unary_complex(af_array *out, const af_array in) { |
| 100 | try { |
| 101 | const ArrayInfo &in_info = getInfo(in); |
| 102 | |
| 103 | af_dtype in_type = in_info.getType(); |
| 104 | af_array res; |
| 105 | |
| 106 | // Convert all inputs to floats / doubles |
| 107 | af_dtype type = implicit(in_type, f32); |
| 108 | if (in_type == f16) { type = f16; } |
| 109 | if (in_info.ndims() == 0) { return af_retain_array(out, in); } |
| 110 | |
| 111 | switch (type) { |
| 112 | case f32: res = unaryOp<float, op>(in); break; |
| 113 | case f64: res = unaryOp<double, op>(in); break; |
| 114 | case c32: res = unaryOpCplx<cfloat, float, op>(in); break; |
| 115 | case c64: res = unaryOpCplx<cdouble, double, op>(in); break; |
| 116 | case f16: res = unaryOp<half, op>(in); break; |
| 117 | default: TYPE_ERROR(1, in_type); break; |
| 118 | } |
| 119 | |
| 120 | std::swap(*out, res); |
| 121 | } |
| 122 | CATCHALL; |
| 123 | return AF_SUCCESS; |
| 124 | } |
| 125 | |
| 126 | #define UNARY_FN(name, opcode) \ |
| 127 | af_err af_##name(af_array *out, const af_array in) { \ |
nothing calls this directly
no test coverage detected