2 * Copyright 2011 Leiden University. All rights reserved.
3 * Copyright 2012-2014 Ecole Normale Superieure. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials provided
15 * with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY LEIDEN UNIVERSITY ''AS IS'' AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LEIDEN UNIVERSITY OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * The views and conclusions contained in the software and documentation
30 * are those of the authors and should not be interpreted as
31 * representing official policies, either expressed or implied, of
37 /* Return the piecewise affine expression "set ? 1 : 0" defined on "dom".
39 static __isl_give isl_pw_aff
*indicator_function(__isl_take isl_set
*set
,
40 __isl_take isl_set
*dom
)
43 pa
= isl_set_indicator_function(set
);
44 pa
= isl_pw_aff_intersect_domain(pa
, isl_set_coalesce(dom
));
48 /* Return the result of applying the comparison operator "type"
51 * In particular, construct an isl_pw_aff that is equal to 1
52 * on the subset of the shared domain of "pa1" and "pa2" where
53 * the comparison holds and 0 on the other part of the shared domain.
55 __isl_give isl_pw_aff
*pet_comparison(enum pet_op_type type
,
56 __isl_take isl_pw_aff
*pa1
, __isl_take isl_pw_aff
*pa2
)
62 dom
= isl_pw_aff_domain(isl_pw_aff_copy(pa1
));
63 dom
= isl_set_intersect(dom
, isl_pw_aff_domain(isl_pw_aff_copy(pa2
)));
67 cond
= isl_pw_aff_lt_set(pa1
, pa2
);
70 cond
= isl_pw_aff_le_set(pa1
, pa2
);
73 cond
= isl_pw_aff_gt_set(pa1
, pa2
);
76 cond
= isl_pw_aff_ge_set(pa1
, pa2
);
79 cond
= isl_pw_aff_eq_set(pa1
, pa2
);
82 cond
= isl_pw_aff_ne_set(pa1
, pa2
);
85 isl_die(isl_pw_aff_get_ctx(pa1
), isl_error_internal
,
86 "not a comparison operator", cond
= NULL
);
91 cond
= isl_set_coalesce(cond
);
92 res
= indicator_function(cond
, dom
);