| 1 | /* |
| 2 | * Copyright 2014 INRIA Rocquencourt |
| 3 | * |
| 4 | * Use of this software is governed by the MIT license |
| 5 | * |
| 6 | * Written by Sven Verdoolaege, |
| 7 | * Inria Paris - Rocquencourt, Domaine de Voluceau - Rocquencourt, |
| 8 | * B.P. 105 - 78153 Le Chesnay, France |
| 9 | */ |
| 10 | |
| 11 | #define xFN(TYPE,NAME) TYPE ## _ ## NAME |
| 12 | #define FN(TYPE,NAME) xFN(TYPE,NAME) |
| 13 | |
| 14 | /* Return a map containing pairs of elements in the domains of "mpa1" and "mpa2" |
| 15 | * where the function value of "mpa1" lexicographically compares as "ORDER" |
| 16 | * to that of "mpa2". "space" is the space of the result. |
| 17 | * The parameters of "mpa1" and "mpa2" are assumed to have been aligned. |
| 18 | * |
| 19 | * "mpa1" is in the given lexicographic order compared to "mpa2" |
| 20 | * if, for some i, the i-th element of "mpa1" is in that order compared to |
| 21 | * the i-th element of "mpa2" while all previous elements are |
| 22 | * pairwise equal, where the order needs to be strict (not-equal) |
| 23 | * if i corresponds to anything but the last element. |
| 24 | * The strict version of "ORDER" is defined by "STRICT_ORDER", |
| 25 | * which is the same if "ORDER" itself is strict. |
| 26 | */ |
| 27 | static __isl_give isl_map *FN(FN(isl_multi_pw_aff_lex,ORDER),map_on_space)( |
| 28 | __isl_keep isl_multi_pw_aff *mpa1, __isl_keep isl_multi_pw_aff *mpa2, |
| 29 | __isl_take isl_space *space) |
| 30 | { |
| 31 | return isl_multi_pw_aff_lex_map_on_space(mpa1, mpa2, |
| 32 | strict_base: &FN(FN(isl_pw_aff,STRICT_ORDER),map), |
| 33 | base: &FN(FN(isl_pw_aff,ORDER),map), space); |
| 34 | } |
| 35 | |
| 36 | /* Return a map containing pairs of elements in the domains of "mpa1" and "mpa2" |
| 37 | * where the function value of "mpa1" lexicographically compares as "ORDER" |
| 38 | * to that of "mpa2". |
| 39 | */ |
| 40 | __isl_give isl_map *FN(FN(isl_multi_pw_aff_lex,ORDER),map)( |
| 41 | __isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2) |
| 42 | { |
| 43 | return isl_multi_pw_aff_order_map(mpa1, mpa2, |
| 44 | order: &FN(FN(isl_multi_pw_aff_lex,ORDER),map_on_space)); |
| 45 | } |
| 46 | |
| 47 | /* Return the subset of "map" where the domain and the range |
| 48 | * have "mpa" values that lexicographically compare as "ORDER". |
| 49 | */ |
| 50 | __isl_give isl_map *FN(FN(isl_map_lex,ORDER),at_multi_pw_aff)( |
| 51 | __isl_take isl_map *map, __isl_take isl_multi_pw_aff *mpa) |
| 52 | { |
| 53 | return isl_map_order_at_multi_pw_aff(map, mpa, |
| 54 | order: &FN(FN(isl_multi_pw_aff_lex,ORDER),map)); |
| 55 | } |
| 56 | |