Skip to content

Commit 9f71594

Browse files
committed
fix module loops
1 parent af706e5 commit 9f71594

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

code/ndarray_operators.c

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -274,23 +274,30 @@ mp_obj_t ndarray_binary_modulo(ndarray_obj_t *lhs, ndarray_obj_t *rhs,
274274
MODULO_FLOAT_LOOP(results, mp_float_t, uint8_t, mp_float_t, larray, lstrides, rarray, rstrides);
275275
}
276276
} else if(lhs->dtype == NDARRAY_INT8) {
277-
if(rhs->dtype == NDARRAY_INT8) {
277+
if(rhs->dtype == NDARRAY_UINT8) {
278+
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_INT16);
279+
BINARY_LOOP(results, int16_t, int8_t, uint8_t, larray, lstrides, rarray, rstrides, %);
280+
} else if(rhs->dtype == NDARRAY_INT8) {
278281
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_INT8);
279282
BINARY_LOOP(results, int8_t, int8_t, int8_t, larray, lstrides, rarray, rstrides, %);
280283
} else if(rhs->dtype == NDARRAY_UINT16) {
281284
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_INT16);
282-
BINARY_LOOP(results, int16_t, int8_t, uint16_t, larray, lstrides, rarray, rstrides, %);
285+
BINARY_LOOP(results, int16_t, int8_t, int16_t, larray, lstrides, rarray, rstrides, %);
283286
} else if(rhs->dtype == NDARRAY_INT16) {
284287
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_INT16);
285288
BINARY_LOOP(results, int16_t, int8_t, int16_t, larray, lstrides, rarray, rstrides, %);
286289
} else if(rhs->dtype == NDARRAY_FLOAT) {
287290
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_FLOAT);
288291
MODULO_FLOAT_LOOP(results, mp_float_t, int8_t, mp_float_t, larray, lstrides, rarray, rstrides);
289-
} else {
290-
return ndarray_binary_op(MP_BINARY_OP_ADD, MP_OBJ_FROM_PTR(rhs), MP_OBJ_FROM_PTR(lhs));
291292
}
292293
} else if(lhs->dtype == NDARRAY_UINT16) {
293-
if(rhs->dtype == NDARRAY_UINT16) {
294+
if(rhs->dtype == NDARRAY_UINT8) {
295+
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_UINT8);
296+
BINARY_LOOP(results, uint16_t, uint16_t, uint8_t, larray, lstrides, rarray, rstrides, %);
297+
} else if(rhs->dtype == NDARRAY_INT8) {
298+
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_FLOAT);
299+
BINARY_LOOP(results, mp_float_t, uint16_t, int8_t, larray, lstrides, rarray, rstrides, %);
300+
} else if(rhs->dtype == NDARRAY_UINT16) {
294301
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_UINT16);
295302
BINARY_LOOP(results, uint16_t, uint16_t, uint16_t, larray, lstrides, rarray, rstrides, %);
296303
} else if(rhs->dtype == NDARRAY_INT16) {
@@ -299,25 +306,40 @@ mp_obj_t ndarray_binary_modulo(ndarray_obj_t *lhs, ndarray_obj_t *rhs,
299306
} else if(rhs->dtype == NDARRAY_FLOAT) {
300307
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_FLOAT);
301308
MODULO_FLOAT_LOOP(results, mp_float_t, uint16_t, mp_float_t, larray, lstrides, rarray, rstrides);
302-
} else {
303-
return ndarray_binary_op(MP_BINARY_OP_ADD, MP_OBJ_FROM_PTR(rhs), MP_OBJ_FROM_PTR(lhs));
304309
}
305310
} else if(lhs->dtype == NDARRAY_INT16) {
306-
if(rhs->dtype == NDARRAY_INT16) {
311+
if(rhs->dtype == NDARRAY_UINT8) {
312+
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_INT16);
313+
BINARY_LOOP(results, int16_t, int16_t, uint8_t, larray, lstrides, rarray, rstrides, %);
314+
} else if(rhs->dtype == NDARRAY_INT8) {
315+
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_INT16);
316+
BINARY_LOOP(results, int16_t, int16_t, int8_t, larray, lstrides, rarray, rstrides, %);
317+
} else if(rhs->dtype == NDARRAY_UINT16) {
318+
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_FLOAT);
319+
BINARY_LOOP(results, mp_float_t, int16_t, uint16_t, larray, lstrides, rarray, rstrides, %);
320+
} else if(rhs->dtype == NDARRAY_INT16) {
307321
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_INT16);
308322
BINARY_LOOP(results, int16_t, int16_t, int16_t, larray, lstrides, rarray, rstrides, %);
309323
} else if(rhs->dtype == NDARRAY_FLOAT) {
310324
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_FLOAT);
311325
MODULO_FLOAT_LOOP(results, mp_float_t, int16_t, mp_float_t, larray, lstrides, rarray, rstrides);
312-
} else {
313-
return ndarray_binary_op(MP_BINARY_OP_ADD, MP_OBJ_FROM_PTR(rhs), MP_OBJ_FROM_PTR(lhs));
314326
}
315327
} else if(lhs->dtype == NDARRAY_FLOAT) {
316-
if(rhs->dtype == NDARRAY_FLOAT) {
328+
if(rhs->dtype == NDARRAY_UINT8) {
329+
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_FLOAT);
330+
MODULO_FLOAT_LOOP(results, mp_float_t, mp_float_t, uint8_t, larray, lstrides, rarray, rstrides);
331+
} else if(rhs->dtype == NDARRAY_INT8) {
332+
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_FLOAT);
333+
MODULO_FLOAT_LOOP(results, mp_float_t, mp_float_t, int8_t, larray, lstrides, rarray, rstrides);
334+
} else if(rhs->dtype == NDARRAY_UINT16) {
335+
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_FLOAT);
336+
MODULO_FLOAT_LOOP(results, mp_float_t, mp_float_t, uint16_t, larray, lstrides, rarray, rstrides);
337+
} else if(rhs->dtype == NDARRAY_INT16) {
338+
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_FLOAT);
339+
MODULO_FLOAT_LOOP(results, mp_float_t, mp_float_t, int16_t, larray, lstrides, rarray, rstrides);
340+
} else if(rhs->dtype == NDARRAY_FLOAT) {
317341
results = ndarray_new_dense_ndarray(ndim, shape, NDARRAY_FLOAT);
318342
MODULO_FLOAT_LOOP(results, mp_float_t, mp_float_t, mp_float_t, larray, lstrides, rarray, rstrides);
319-
} else {
320-
return ndarray_binary_op(MP_BINARY_OP_ADD, MP_OBJ_FROM_PTR(rhs), MP_OBJ_FROM_PTR(lhs));
321343
}
322344
}
323345

0 commit comments

Comments
 (0)