@@ -259,49 +259,51 @@ void TYPE_divide_unsigned(char **args, npy_intp const *dimensions, npy_intp cons
259
259
260
260
// Indexed division for signed integers
261
261
template <typename T>
262
- int TYPE_divide_indexed (char * const *args, npy_intp const *dimensions, npy_intp const *steps, NpyAuxData *NPY_UNUSED (func)) {
262
+ int TYPE_divide_indexed (char * const *args, npy_intp const *dimensions,
263
+ npy_intp const *steps, NpyAuxData *NPY_UNUSED (func)) {
263
264
char *ip1 = args[0 ];
264
265
char *indxp = args[1 ];
265
266
char *value = args[2 ];
266
267
npy_intp is1 = steps[0 ], isindex = steps[1 ], isb = steps[2 ];
267
268
npy_intp shape = steps[3 ];
268
269
npy_intp n = dimensions[0 ];
269
- npy_intp i;
270
- T *indexed;
271
- for (i = 0 ; i < n; i++, indxp += isindex, value += isb) {
270
+
271
+ for (npy_intp i = 0 ; i < n; i++, indxp += isindex, value += isb) {
272
272
npy_intp indx = *(npy_intp *)indxp;
273
273
if (indx < 0 ) {
274
274
indx += shape;
275
275
}
276
- indexed = (T *)(ip1 + is1 * indx);
277
- *indexed = floor_div (*indexed, *(T *)value);
276
+ T* indexed = reinterpret_cast <T*>(ip1 + is1 * indx);
277
+ T divisor = *reinterpret_cast <T*>(value);
278
+ *indexed = floor_div (*indexed, divisor);
278
279
}
279
280
return 0 ;
280
281
}
281
282
282
283
// Indexed division for unsigned integers
283
284
template <typename T>
284
- int TYPE_divide_unsigned_indexed (char * const *args, npy_intp const *dimensions, npy_intp const *steps, NpyAuxData *NPY_UNUSED (func)) {
285
+ int TYPE_divide_unsigned_indexed (char * const *args, npy_intp const *dimensions,
286
+ npy_intp const *steps, NpyAuxData *NPY_UNUSED (func)) {
285
287
char *ip1 = args[0 ];
286
288
char *indxp = args[1 ];
287
289
char *value = args[2 ];
288
290
npy_intp is1 = steps[0 ], isindex = steps[1 ], isb = steps[2 ];
289
291
npy_intp shape = steps[3 ];
290
292
npy_intp n = dimensions[0 ];
291
- npy_intp i;
292
- T *indexed;
293
- for (i = 0 ; i < n; i++, indxp += isindex, value += isb) {
293
+
294
+ for (npy_intp i = 0 ; i < n; i++, indxp += isindex, value += isb) {
294
295
npy_intp indx = *(npy_intp *)indxp;
295
296
if (indx < 0 ) {
296
297
indx += shape;
297
298
}
298
- indexed = (T *)(ip1 + is1 * indx);
299
- T in2 = *(T *)value;
300
- if (HWY_UNLIKELY (in2 == 0 )) {
299
+ T* indexed = reinterpret_cast <T*>(ip1 + is1 * indx);
300
+ T divisor = *reinterpret_cast <T*>(value);
301
+
302
+ if (HWY_UNLIKELY (divisor == 0 )) {
301
303
npy_set_floatstatus_divbyzero ();
302
304
*indexed = 0 ;
303
305
} else {
304
- *indexed = *indexed / in2 ;
306
+ *indexed = *indexed / divisor ;
305
307
}
306
308
}
307
309
return 0 ;
0 commit comments