[PPL-devel] Question about converting integers in PPL

Enea Zaffanella zaffanella at cs.unipr.it
Fri Jul 12 12:29:30 CEST 2002


Dear Martin,

the coefficients of the PPL are objects of class Integer,
which is defined as a shorthand for

namespace Parma_Polyhedra_Library {
   typedef mpz_class Integer;
}

"mpz_class" is the GMP wrapper class for the type mpz_t (see, e.g., 
http://www.swox.com/gmp/manual/C---Class-Interface.html#C++%20Class%20Interface).

Thus, the conversion can be done by writing something like

   Integer c = c1.coefficient(Variable(0));
   long c_long = c.get_si();

I am now wondering if it is worth to enrich the PPL user interface
with some methods to perform this kind of conversions directly,
perhaps throwing an exception when the conversion cannot be done safely.
However, I must reckon that I am not an expert as far as
GMP-related issues are concerned ...
it is maybe better to wait for Roberto's advice.

Ciao,
Enea.



Martin Rohde wrote:
> hello,
> 
> I have (simple) a question about using PPL 0.4:
> 
> I cannot find how to convert a coefficient (of a constraint or generator)
> to the normal integer type. In my code I do the following; c1 is a
> constraint which is defined earlier in the code. Now I try to convert a
> coefficient with
> 
> c1_int = mpz_get_si(c1.coefficient(Variable(0)))
> 
> but this doesn't work, probably because the coefficient is not of the
> regular gmp format (c1_int is a standard integer)
> 
> How can I convert coefficients to 'normal' integers (or double integers)?
> 
> Thank you for your help!
> 
> Martin Rohde
> 
> Delft University of Technology
> Kramers Laboratorium voor Fysische Technologie
> Tel 0031 +152787084
> Mail martin at klftfs01.tn.tudelft.nl
> 
> _______________________________________________
> PPL-devel mailing list
> PPL-devel at cs.unipr.it
> http://www.cs.unipr.it/mailman/listinfo/ppl-devel
> 
> 






More information about the PPL-devel mailing list