Strong Exception Guarantee
| 223 | |
| 224 | // Strong Exception Guarantee |
| 225 | af_err af_iota(af_array *result, const unsigned ndims, const dim_t *const dims, |
| 226 | const unsigned t_ndims, const dim_t *const tdims, |
| 227 | const af_dtype type) { |
| 228 | try { |
| 229 | af_array out; |
| 230 | AF_CHECK(af_init()); |
| 231 | |
| 232 | if (ndims == 0) { return af_create_handle(result, 0, nullptr, type); } |
| 233 | |
| 234 | DIM_ASSERT(1, ndims > 0 && ndims <= 4); |
| 235 | DIM_ASSERT(3, t_ndims > 0 && t_ndims <= 4); |
| 236 | |
| 237 | dim4 d = verifyDims(ndims, dims); |
| 238 | dim4 t = verifyDims(t_ndims, tdims); |
| 239 | |
| 240 | switch (type) { |
| 241 | case f32: out = iota_<float>(d, t); break; |
| 242 | case f64: out = iota_<double>(d, t); break; |
| 243 | case s32: out = iota_<int>(d, t); break; |
| 244 | case u32: out = iota_<uint>(d, t); break; |
| 245 | case s64: out = iota_<intl>(d, t); break; |
| 246 | case u64: out = iota_<uintl>(d, t); break; |
| 247 | case s16: out = iota_<short>(d, t); break; |
| 248 | case u16: out = iota_<ushort>(d, t); break; |
| 249 | case s8: out = iota_<schar>(d, t); break; |
| 250 | case u8: out = iota_<uchar>(d, t); break; |
| 251 | case f16: out = iota_<half>(d, t); break; |
| 252 | default: TYPE_ERROR(4, type); |
| 253 | } |
| 254 | std::swap(*result, out); |
| 255 | } |
| 256 | CATCHALL |
| 257 | return AF_SUCCESS; |
| 258 | } |
| 259 | |
| 260 | template<typename T> |
| 261 | static inline af_array diagCreate(const af_array in, const int num) { |
no test coverage detected