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

Function af_unary_complex

src/api/c/unary.cpp:99–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98template<af_op_t op>
99static 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) { \

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected