[PPL-devel] Bug in ppl_new_LinExpression_with_dimension
Roberto Bagnara
bagnara at cs.unipr.it
Sat Oct 16 23:22:28 CEST 2004
Pedro Vasconcelos wrote:
> While experimenting with the Haskell PPL binding, I noticed that the C
> interface function "ppl_new_LinExpression_with_dimension" always creates
> an expression with one plus the specified dimension. The following code
> illustrates the problem:
>
> #include <ppl_c.h>
>
> main () {
> ppl_LinExpression_t e;
> ppl_dimension_type dim_in=3, dim_out;;
>
> ppl_initialize();
>
> ppl_new_LinExpression_with_dimension(&e, dim_in);
> dim_out = ppl_LinExpression_space_dimension(e);
> printf("%d, %d\n", dim_in, dim_out); /* 3, 4 rather than 3,3 as expected */
>
> ppl_finalize();
> }
>
> Looking at the source code interface/C/ppl_c.cc, it becomes clear that
> the expression created has a single Variable(d), therefore dimension d+1:
>
> int
> ppl_new_LinExpression_with_dimension(ppl_LinExpression_t* ple,
> ppl_dimension_type d) try {
> *ple = to_nonconst(new LinExpression(0*Variable(d))); /* <----- should be Variable(d-1) */
> return 0;
> }
> CATCH_ALL
>
> This is of course trivial to correct, but I thought it best to report so
> that it gets corrected in the newer releases.
Dear Pedro,
thanks a lot for your report. You spotted a genuine bug in the
C interface. The fix is almost as you indicate, with the exception
that the case where d == 0 must also be handled properly. The
patch I applied to the CVS head version is the following:
http://www.cs.unipr.it/cgi-bin/cvsweb.cgi/ppl/interfaces/C/ppl_c.cc.diff?cvsroot=ppl&r1=1.110&r2=1.111
(notice that the interface of ppl_new_LinExpression_with_dimension
has changed since the release of PPL 0.6.1).
All the best,
Roberto
--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it
More information about the PPL-devel
mailing list