| 82 | } |
| 83 | |
| 84 | af_err af_constant_complex(af_array *result, const double real, |
| 85 | const double imag, const unsigned ndims, |
| 86 | const dim_t *const dims, af_dtype type) { |
| 87 | try { |
| 88 | af_array out; |
| 89 | AF_CHECK(af_init()); |
| 90 | |
| 91 | if (ndims <= 0) { return af_create_handle(result, 0, nullptr, type); } |
| 92 | dim4 d = verifyDims(ndims, dims); |
| 93 | |
| 94 | switch (type) { |
| 95 | case c32: out = createCplx<cfloat, float>(d, real, imag); break; |
| 96 | case c64: out = createCplx<cdouble, double>(d, real, imag); break; |
| 97 | default: TYPE_ERROR(5, type); |
| 98 | } |
| 99 | |
| 100 | std::swap(*result, out); |
| 101 | } |
| 102 | CATCHALL |
| 103 | return AF_SUCCESS; |
| 104 | } |
| 105 | |
| 106 | af_err af_constant_long(af_array *result, const intl val, const unsigned ndims, |
| 107 | const dim_t *const dims) { |