| 67 | } |
| 68 | |
| 69 | af_err af_cplx(af_array *out, const af_array in) { |
| 70 | try { |
| 71 | const ArrayInfo &info = getInfo(in); |
| 72 | af_dtype type = info.getType(); |
| 73 | |
| 74 | if (type == c32 || type == c64) { |
| 75 | AF_ERROR("Inputs to cplx2 can not be of complex type", AF_ERR_ARG); |
| 76 | } |
| 77 | if (info.ndims() == 0) { return af_retain_array(out, in); } |
| 78 | |
| 79 | af_array tmp; |
| 80 | AF_CHECK(af_constant(&tmp, 0, info.ndims(), info.dims().get(), type)); |
| 81 | |
| 82 | af_array res; |
| 83 | switch (type) { |
| 84 | case f32: res = cplx<cfloat, float>(in, tmp, info.dims()); break; |
| 85 | case f64: res = cplx<cdouble, double>(in, tmp, info.dims()); break; |
| 86 | |
| 87 | default: TYPE_ERROR(0, type); |
| 88 | } |
| 89 | |
| 90 | AF_CHECK(af_release_array(tmp)); |
| 91 | |
| 92 | std::swap(*out, res); |
| 93 | } |
| 94 | CATCHALL; |
| 95 | return AF_SUCCESS; |
| 96 | } |
| 97 | |
| 98 | af_err af_real(af_array *out, const af_array in) { |
| 99 | try { |
nothing calls this directly
no test coverage detected