extract out shared isl_qpolynomial_{take,restore}_local
[isl.git] / isl_multi_intersect.c
blobf8f6430775016651d2f3b585a143a8c07e1b4c56
1 /*
2 * Copyright 2011 Sven Verdoolaege
3 * Copyright 2012-2013 Ecole Normale Superieure
5 * Use of this software is governed by the MIT license
7 * Written by Sven Verdoolaege,
8 * Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
9 */
11 #include <isl_multi_macro.h>
13 /* Intersect the parameter domain "dom1" with "dom2".
14 * That is, intersect the parameters of "dom2" with "dom1".
16 * Even though "dom1" is known to only involve parameter constraints,
17 * it may be of type isl_union_set, so explicitly convert it
18 * to an isl_set first.
20 static __isl_give DOM *FN(MULTI(BASE),params_domain_intersect)(DOM *dom1,
21 __isl_take DOM *dom2)
23 isl_set *params;
25 params = FN(DOM,params)(dom1);
26 dom2 = FN(DOM,intersect_params)(dom2, params);
28 return dom2;
31 /* Intersect the domain of "multi" with "domain".
33 * If "multi" has an explicit domain, then only this domain
34 * needs to be intersected.
36 __isl_give MULTI(BASE) *FN(MULTI(BASE),intersect_domain)(
37 __isl_take MULTI(BASE) *multi, __isl_take DOM *domain)
39 if (FN(MULTI(BASE),check_compatible_domain)(multi, domain) < 0)
40 domain = FN(DOM,free)(domain);
41 return FN(FN(MULTI(BASE),apply),DOMBASE)(multi, domain,
42 &FN(EL,intersect_domain),
43 &FN(DOM,intersect),
44 &FN(MULTI(BASE),params_domain_intersect));
47 /* Intersect the parameter domain of "multi" with "domain".
49 * If "multi" has an explicit domain, then only this domain
50 * needs to be intersected.
52 __isl_give MULTI(BASE) *FN(MULTI(BASE),intersect_params)(
53 __isl_take MULTI(BASE) *multi, __isl_take isl_set *domain)
55 return FN(MULTI(BASE),apply_set)(multi, domain,
56 &FN(EL,intersect_params),
57 &FN(DOM,intersect_params),
58 &FN(DOM,intersect_params));