* Add support for product in ALGO_REDUCE
This commit is contained in:
1 parent
d438d089fb
commit
5b8750ee2a
3 files changed
+10
-1
No files matched your search
@@ -935,6 +935,7 @@
|
||||
#define ALGOI_REDUCE_AND(a,b) ((a) &= (b))
|
||||
#define ALGOI_REDUCE_OR(a,b) ((a) |= (b))
|
||||
#define ALGOI_REDUCE_SUM(a,b) ((a) += (b))
|
||||
#define ALGOI_REDUCE_PRODUCT(a,b) ((a) *= (b))
|
||||
|
||||
/* Return the method associated to a reduce operation.
|
||||
It returns the special function handler if function is and, or, sum or add.
|
||||
@@ -945,7 +946,11 @@
|
||||
M_IF(M_KEYWORD_P(or, reduceFunc)) \
|
||||
(ALGOI_REDUCE_OR, \
|
||||
M_IF(M_KEYWORD_P(sum, reduceFunc)) \
|
||||
(ALGOI_REDUCE_SUM, reduceFunc) \
|
||||
(ALGOI_REDUCE_SUM, \
|
||||
M_IF(M_KEYWORD_P(product, reduceFunc)) \
|
||||
(ALGOI_REDUCE_PRODUCT, \
|
||||
reduceFunc) \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
|
||||
|
||||
@@ -817,6 +817,8 @@ extern void m_no_default_function(void) __attribute__((error("The requested op
|
||||
#define M_PATTERN_sum_add ,
|
||||
#define M_PATTERN_add_add ,
|
||||
#define M_PATTERN_add_sum ,
|
||||
#define M_PATTERN_product_product ,
|
||||
#define M_PATTERN_product_mul ,
|
||||
#define M_PATTERN_bool_bool ,
|
||||
|
||||
|
||||
|
||||
@@ -502,6 +502,8 @@ static void test_extract(void)
|
||||
assert (dst == 0);
|
||||
ALGO_REDUCE(dst, a, ARRAY_OPLIST(array_int), or);
|
||||
assert (dst == 127);
|
||||
ALGO_REDUCE(dst, a, ARRAY_OPLIST(array_int), product);
|
||||
assert (dst == 0);
|
||||
|
||||
array_int_clear(a);
|
||||
list_int_clear(l);
|
||||
|
||||
Reference in new issue
Block a user