| 145 | } |
| 146 | |
| 147 | af_err af_identity(af_array *out, const unsigned ndims, const dim_t *const dims, |
| 148 | const af_dtype type) { |
| 149 | try { |
| 150 | af_array result; |
| 151 | AF_CHECK(af_init()); |
| 152 | |
| 153 | if (ndims == 0) { return af_create_handle(out, 0, nullptr, type); } |
| 154 | |
| 155 | dim4 d = verifyDims(ndims, dims); |
| 156 | |
| 157 | switch (type) { |
| 158 | case f32: result = identity_<float>(d); break; |
| 159 | case c32: result = identity_<cfloat>(d); break; |
| 160 | case f64: result = identity_<double>(d); break; |
| 161 | case c64: result = identity_<cdouble>(d); break; |
| 162 | case s32: result = identity_<int>(d); break; |
| 163 | case u32: result = identity_<uint>(d); break; |
| 164 | case s8: result = identity_<schar>(d); break; |
| 165 | case u8: result = identity_<uchar>(d); break; |
| 166 | case u64: result = identity_<uintl>(d); break; |
| 167 | case s64: result = identity_<intl>(d); break; |
| 168 | case u16: result = identity_<ushort>(d); break; |
| 169 | case s16: |
| 170 | result = identity_<short>(d); |
| 171 | break; |
| 172 | // Removed because of bool type. Functions implementations |
| 173 | // exist. |
| 174 | case b8: result = identity_<char>(d); break; |
| 175 | case f16: result = identity_<half>(d); break; |
| 176 | default: TYPE_ERROR(3, type); |
| 177 | } |
| 178 | std::swap(*out, result); |
| 179 | } |
| 180 | CATCHALL |
| 181 | return AF_SUCCESS; |
| 182 | } |
| 183 | |
| 184 | template<typename T> |
| 185 | static inline af_array range_(const dim4 &d, const int seq_dim) { |
no test coverage detected