| 157 | } |
| 158 | |
| 159 | af_err af_scan(af_array* out, const af_array in, const int dim, af_binary_op op, |
| 160 | bool inclusive_scan) { |
| 161 | try { |
| 162 | ARG_ASSERT(2, dim >= 0); |
| 163 | ARG_ASSERT(2, dim < 4); |
| 164 | |
| 165 | const ArrayInfo& in_info = getInfo(in); |
| 166 | |
| 167 | if (dim >= static_cast<int>(in_info.ndims())) { |
| 168 | *out = retain(in); |
| 169 | return AF_SUCCESS; |
| 170 | } |
| 171 | |
| 172 | af_dtype type = in_info.getType(); |
| 173 | af_array res; |
| 174 | |
| 175 | switch (type) { |
| 176 | case f32: |
| 177 | res = scan_op<float, float>(in, dim, op, inclusive_scan); |
| 178 | break; |
| 179 | case f64: |
| 180 | res = scan_op<double, double>(in, dim, op, inclusive_scan); |
| 181 | break; |
| 182 | case c32: |
| 183 | res = scan_op<cfloat, cfloat>(in, dim, op, inclusive_scan); |
| 184 | break; |
| 185 | case c64: |
| 186 | res = scan_op<cdouble, cdouble>(in, dim, op, inclusive_scan); |
| 187 | break; |
| 188 | case u32: |
| 189 | res = scan_op<uint, uint>(in, dim, op, inclusive_scan); |
| 190 | break; |
| 191 | case s32: |
| 192 | res = scan_op<int, int>(in, dim, op, inclusive_scan); |
| 193 | break; |
| 194 | case u64: |
| 195 | res = scan_op<uintl, uintl>(in, dim, op, inclusive_scan); |
| 196 | break; |
| 197 | case s64: |
| 198 | res = scan_op<intl, intl>(in, dim, op, inclusive_scan); |
| 199 | break; |
| 200 | case u16: |
| 201 | res = scan_op<ushort, uint>(in, dim, op, inclusive_scan); |
| 202 | break; |
| 203 | case s16: |
| 204 | res = scan_op<short, int>(in, dim, op, inclusive_scan); |
| 205 | break; |
| 206 | case u8: |
| 207 | res = scan_op<uchar, uint>(in, dim, op, inclusive_scan); |
| 208 | break; |
| 209 | case s8: |
| 210 | res = scan_op<schar, int>(in, dim, op, inclusive_scan); |
| 211 | break; |
| 212 | case b8: |
| 213 | res = scan_op<char, uint>(in, dim, op, inclusive_scan); |
| 214 | break; |
| 215 | default: TYPE_ERROR(1, type); |
| 216 | } |