加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
isl_pw_opt_templ.c 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* Copyright 2010 INRIA Saclay
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
* Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
* 91893 Orsay, France
*/
/* Compute the maximal value attained by the piecewise quasipolynomial
* on its domain or zero if the domain is empty.
* In the worst case, the domain is scanned completely,
* so the domain is assumed to be bounded.
*/
__isl_give isl_val *FN(PW,opt)(__isl_take PW *pw, int max)
{
int i;
isl_val *opt;
if (!pw)
return NULL;
if (pw->n == 0) {
opt = isl_val_zero(FN(PW,get_ctx)(pw));
FN(PW,free)(pw);
return opt;
}
opt = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[0].FIELD),
isl_set_copy(pw->p[0].set), max);
for (i = 1; i < pw->n; ++i) {
isl_val *opt_i;
opt_i = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[i].FIELD),
isl_set_copy(pw->p[i].set), max);
if (max)
opt = isl_val_max(opt, opt_i);
else
opt = isl_val_min(opt, opt_i);
}
FN(PW,free)(pw);
return opt;
}
__isl_give isl_val *FN(PW,max)(__isl_take PW *pw)
{
return FN(PW,opt)(pw, 1);
}
__isl_give isl_val *FN(PW,min)(__isl_take PW *pw)
{
return FN(PW,opt)(pw, 0);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化