2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
11 /* Compute the maximal value attained by the piecewise quasipolynomial
12 * on its domain or zero if the domain is empty.
13 * In the worst case, the domain is scanned completely,
14 * so the domain is assumed to be bounded.
16 __isl_give isl_val
*FN(PW
,opt
)(__isl_take PW
*pw
, int max
)
25 opt
= isl_val_zero(FN(PW
,get_ctx
)(pw
));
30 opt
= FN(EL
,opt_on_domain
)(FN(EL
,copy
)(pw
->p
[0].FIELD
),
31 isl_set_copy(pw
->p
[0].set
), max
);
32 for (i
= 1; i
< pw
->n
; ++i
) {
34 opt_i
= FN(EL
,opt_on_domain
)(FN(EL
,copy
)(pw
->p
[i
].FIELD
),
35 isl_set_copy(pw
->p
[i
].set
), max
);
37 opt
= isl_val_max(opt
, opt_i
);
39 opt
= isl_val_min(opt
, opt_i
);
46 __isl_give isl_val
*FN(PW
,max
)(__isl_take PW
*pw
)
48 return FN(PW
,opt
)(pw
, 1);
51 __isl_give isl_val
*FN(PW
,min
)(__isl_take PW
*pw
)
53 return FN(PW
,opt
)(pw
, 0);