Parma Polyhedra库:顶点枚举和浮点算术

Parma Polyhedra Library: Vertex Enumeration and Floating-Point Arithmetic

本文关键字:枚举 Polyhedra 顶点 Parma      更新时间:2023-10-16

我正在使用Parma Polyhedra库(PPL(进行给定的多面体的顶点枚举。这已经在这里讨论。但是,我不知道如何在计算中使用有理数而不是整数。

下面的代码生成一个线段[0.3,3.7](凸在1个维度中(,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;
    }

ppl期望整数在其相反的定义中。您将必须使用共同点扩展您的不平等。