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

Function af_unary

src/api/c/unary.cpp:72–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70
71template<af_op_t op>
72static af_err af_unary(af_array *out, const af_array in) {
73 try {
74 const ArrayInfo &in_info = getInfo(in);
75 ARG_ASSERT(1, in_info.isReal());
76
77 af_dtype in_type = in_info.getType();
78 af_array res;
79
80 // Convert all inputs to floats / doubles
81 af_dtype type = implicit(in_type, f32);
82 if (in_type == f16) { type = f16; }
83 if (in_info.ndims() == 0) { return af_retain_array(out, in); }
84
85 switch (type) {
86 case f16: res = unaryOp<half, op>(in); break;
87 case f32: res = unaryOp<float, op>(in); break;
88 case f64: res = unaryOp<double, op>(in); break;
89 default: TYPE_ERROR(1, in_type); break;
90 }
91
92 std::swap(*out, res);
93 }
94 CATCHALL;
95 return AF_SUCCESS;
96}
97
98template<af_op_t op>
99static af_err af_unary_complex(af_array *out, const af_array in) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected