[PPL-devel] Bug in ppl_new_LinExpression_with_dimension
Pedro Vasconcelos
pbv at st-andrews.ac.uk
Sat Oct 16 22:21:56 CEST 2004
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.
Best regards,
Pedro
More information about the PPL-devel
mailing list