2 * Copyright 2013 Ecole Normale Superieure
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
10 /* Apply "fn" to each of the elements of "multi" with as second argument "v".
12 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),fn_val
)(
13 __isl_take
MULTI(BASE
) *multi
,
14 __isl_give EL
*(*fn
)(__isl_take EL
*el
, __isl_take isl_val
*v
),
15 __isl_take isl_val
*v
)
20 n
= FN(MULTI(BASE
),size
)(multi
);
24 for (i
= 0; i
< n
; ++i
) {
27 el
= FN(MULTI(BASE
),take_at
)(multi
, i
);
28 el
= fn(el
, isl_val_copy(v
));
29 multi
= FN(MULTI(BASE
),restore_at
)(multi
, i
, el
);
36 FN(MULTI(BASE
),free
)(multi
);
41 #define TYPE MULTI(BASE)
42 #include "isl_type_check_match_range_multi_val.c"
44 /* Elementwise apply "fn" to "multi" and "mv".
46 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),fn_multi_val
)(
47 __isl_take
MULTI(BASE
) *multi
,
48 __isl_give EL
*(*fn
)(__isl_take EL
*el
, __isl_take isl_val
*v
),
49 __isl_take isl_multi_val
*mv
)
54 n
= FN(MULTI(BASE
),size
)(multi
);
55 if (n
< 0 || FN(MULTI(BASE
),check_match_range_multi_val
)(multi
, mv
) < 0)
58 for (i
= 0; i
< n
; ++i
) {
62 v
= isl_multi_val_get_val(mv
, i
);
63 el
= FN(MULTI(BASE
),take_at
)(multi
, i
);
65 multi
= FN(MULTI(BASE
),restore_at
)(multi
, i
, el
);
68 isl_multi_val_free(mv
);
71 isl_multi_val_free(mv
);
72 return FN(MULTI(BASE
),free
)(multi
);