aboutsummaryrefslogtreecommitdiff
path: root/cbits
diff options
context:
space:
mode:
Diffstat (limited to 'cbits')
-rw-r--r--cbits/arith.c10
-rw-r--r--cbits/arith_lists.h62
2 files changed, 39 insertions, 33 deletions
diff --git a/cbits/arith.c b/cbits/arith.c
index f19b01e..ee248a4 100644
--- a/cbits/arith.c
+++ b/cbits/arith.c
@@ -20,6 +20,8 @@
// Shorter names, due to CPP used both in function names and in C types.
+typedef int8_t i8;
+typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
@@ -248,6 +250,8 @@ void oxarrays_stats_print_all(void) {
#define GEN_ABS(x) \
_Generic((x), \
+ i8: abs, \
+ i16: abs, \
int: abs, \
long: labs, \
long long: llabs, \
@@ -490,7 +494,9 @@ static void print_shape(FILE *stream, i64 rank, const i64 *shape) {
if (rank == 0) return arr[0]; \
typ result = 0; \
TARRAY_WALK_NOINNER(again, rank, shape, strides, { \
- REDUCE_BODY_CODE(op, typ, shape[rank - 1], strides[rank - 1], arr, arrlinidx, result); \
+ typ dest = 0; \
+ REDUCE_BODY_CODE(op, typ, shape[rank - 1], strides[rank - 1], arr, arrlinidx, dest); \
+ result = result op dest; \
}); \
return result; \
}
@@ -738,7 +744,7 @@ enum redop_tag_t {
* Generate all the functions *
*****************************************************************************/
-#define INT_TYPES_XLIST X(i32) X(i64)
+#define INT_TYPES_XLIST X(i8) X(i16) X(i32) X(i64)
#define FLOAT_TYPES_XLIST X(double) X(float)
#define NUM_TYPES_XLIST INT_TYPES_XLIST FLOAT_TYPES_XLIST
diff --git a/cbits/arith_lists.h b/cbits/arith_lists.h
index 432765c..dc9ad1a 100644
--- a/cbits/arith_lists.h
+++ b/cbits/arith_lists.h
@@ -2,38 +2,38 @@ LIST_BINOP(BO_ADD, 1, +)
LIST_BINOP(BO_SUB, 2, -)
LIST_BINOP(BO_MUL, 3, *)
-LIST_IBINOP(IB_QUOT, 1, quot)
-LIST_IBINOP(IB_REM, 2, rem)
+LIST_IBINOP(IB_QUOT, 11, quot)
+LIST_IBINOP(IB_REM, 12, rem)
-LIST_FBINOP(FB_DIV, 1, /)
-LIST_FBINOP(FB_POW, 2, **)
-LIST_FBINOP(FB_LOGBASE, 3, logBase)
-LIST_FBINOP(FB_ATAN2, 4, atan2)
+LIST_FBINOP(FB_DIV, 21, /)
+LIST_FBINOP(FB_POW, 22, **)
+LIST_FBINOP(FB_LOGBASE, 23, logBase)
+LIST_FBINOP(FB_ATAN2, 24, atan2)
-LIST_UNOP(UO_NEG, 1,)
-LIST_UNOP(UO_ABS, 2,)
-LIST_UNOP(UO_SIGNUM, 3,)
+LIST_UNOP(UO_NEG, 31,)
+LIST_UNOP(UO_ABS, 32,)
+LIST_UNOP(UO_SIGNUM, 33,)
-LIST_FUNOP(FU_RECIP, 1,)
-LIST_FUNOP(FU_EXP, 2,)
-LIST_FUNOP(FU_LOG, 3,)
-LIST_FUNOP(FU_SQRT, 4,)
-LIST_FUNOP(FU_SIN, 5,)
-LIST_FUNOP(FU_COS, 6,)
-LIST_FUNOP(FU_TAN, 7,)
-LIST_FUNOP(FU_ASIN, 8,)
-LIST_FUNOP(FU_ACOS, 9,)
-LIST_FUNOP(FU_ATAN, 10,)
-LIST_FUNOP(FU_SINH, 11,)
-LIST_FUNOP(FU_COSH, 12,)
-LIST_FUNOP(FU_TANH, 13,)
-LIST_FUNOP(FU_ASINH, 14,)
-LIST_FUNOP(FU_ACOSH, 15,)
-LIST_FUNOP(FU_ATANH, 16,)
-LIST_FUNOP(FU_LOG1P, 17,)
-LIST_FUNOP(FU_EXPM1, 18,)
-LIST_FUNOP(FU_LOG1PEXP, 19,)
-LIST_FUNOP(FU_LOG1MEXP, 20,)
+LIST_FUNOP(FU_RECIP, 41,)
+LIST_FUNOP(FU_EXP, 42,)
+LIST_FUNOP(FU_LOG, 43,)
+LIST_FUNOP(FU_SQRT, 44,)
+LIST_FUNOP(FU_SIN, 45,)
+LIST_FUNOP(FU_COS, 46,)
+LIST_FUNOP(FU_TAN, 47,)
+LIST_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