| 1 | /* |
| 2 | * Copyright 2014 Ecole Normale Superieure |
| 3 | * |
| 4 | * Use of this software is governed by the MIT license |
| 5 | * |
| 6 | * Written by Sven Verdoolaege, |
| 7 | * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France |
| 8 | */ |
| 9 | |
| 10 | #include <isl_multi_macro.h> |
| 11 | |
| 12 | /* Apply "fn" to each of the base expressions of "multi". |
| 13 | */ |
| 14 | static __isl_give MULTI(BASE) *FN(MULTI(BASE),un_op)( |
| 15 | __isl_take MULTI(BASE) *multi, __isl_give EL *(*fn)(__isl_take EL *el)) |
| 16 | { |
| 17 | int i; |
| 18 | isl_size n; |
| 19 | |
| 20 | n = FN(MULTI(BASE),size)(multi); |
| 21 | if (n < 0) |
| 22 | return FN(MULTI(BASE),free)(multi); |
| 23 | |
| 24 | for (i = 0; i < n; ++i) { |
| 25 | EL *el; |
| 26 | |
| 27 | el = FN(MULTI(BASE),take_at)(multi, pos: i); |
| 28 | el = fn(el); |
| 29 | multi = FN(MULTI(BASE),restore_at)(multi, pos: i, el); |
| 30 | } |
| 31 | |
| 32 | return multi; |
| 33 | } |
| 34 | |