我正在使用 Parma Polyhedra Library ( PPL ) 对给定的多面体进行顶点枚举。此处已对此进行了讨论。但是,我无法弄清楚如何在计算中使用有理数而不是整数。
下面的代码生成一条线段 [0.3,3.7](一维凸多面体),PPL 返回两个整数 {0,3},但我想要有理数 {0.3,3.7}。我如何建议 PPL 使用有理数(浮点运算)?
#include <cstddef>
#include <stdio.h>
#include "ppl.hh"
using namespace Parma_Polyhedra_Library;
int main() {
Variable x(0);
C_Polyhedron ph(1);
ph.refine_with_constraint( x <= 3.7);
ph.refine_with_constraint( x >= 0.3);
Generator_System gs = ph.generators();
for(Generator_System::const_iterator it = gs.begin(); it != gs.end(); it++) {
const Generator& g = *it;
std::cout << g.coefficient(x) << std::endl;
}
return 0;
}