[PPL-devel] [GIT] ppl/ppl(pip): Another pass on the C interface for PIP_Problem related classes.
Enea Zaffanella
zaffanella at cs.unipr.it
Mon Oct 26 21:32:06 CET 2009
Module: ppl/ppl
Branch: pip
Commit: 250a996c0147a7d30475c068a8a8c7aeeb3b17e2
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=250a996c0147a7d30475c068a8a8c7aeeb3b17e2
Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date: Mon Oct 26 21:30:20 2009 +0100
Another pass on the C interface for PIP_Problem related classes.
Removed a few useless functions and added a few missing ones,
including input/output utilities; also slightly improved the documentation.
---
interfaces/C/ppl_c_header.h | 98 +++++++++------------------
interfaces/C/ppl_c_implementation_common.cc | 44 ++----------
2 files changed, 40 insertions(+), 102 deletions(-)
diff --git a/interfaces/C/ppl_c_header.h b/interfaces/C/ppl_c_header.h
index 9a14839..af77a18 100644
--- a/interfaces/C/ppl_c_header.h
+++ b/interfaces/C/ppl_c_header.h
@@ -694,11 +694,26 @@ PPL_TYPE_DECLARATION(MIP_Problem)
towards \extref{Parma_Polyhedra_Library::PIP_Problem, PIP_Problem}.
*/
PPL_TYPE_DECLARATION(PIP_Problem)
+
+/*! \interface ppl_PIP_Tree_Node_tag
+ \brief
+ Types and functions for PIP tree nodes.
+*/
PPL_TYPE_DECLARATION(PIP_Tree_Node)
PPL_TYPE_DECLARATION(PIP_Decision_Node)
PPL_TYPE_DECLARATION(PIP_Solution_Node)
+
+/*! \interface ppl_Artificial_Parameter_tag
+ \brief
+ Types and functions for PIP artificial parameters.
+*/
PPL_TYPE_DECLARATION(Artificial_Parameter)
PPL_TYPE_DECLARATION(Artificial_Parameter_Sequence)
+
+/*! \interface ppl_Artificial_Parameter_Sequence_const_iterator_tag
+ \brief
+ Types and functions for iterating on PIP artificial parameters.
+*/
PPL_TYPE_DECLARATION(Artificial_Parameter_Sequence_const_iterator)
@@ -2601,6 +2616,9 @@ PPL_PROTO((ppl_MIP_Problem_t mip, int value));
/*@}*/ /* Querying/Setting Control Parameters */
+/*! \brief \name Constructors, Assignment and Destructor */
+/*@{*/
+
/*! \relates ppl_PIP_Problem_tag \brief
Builds a trivial PIP problem of dimension \p d and writes an
handle to it at address \p pmip.
@@ -2782,7 +2800,7 @@ PPL_PROTO((ppl_const_PIP_Problem_t pip,
/*@}*/ /* Computing the Solution of the PIP_Problem */
-/*! \relates ppl_PIP_Problem_tag \brief
+/*! \relates ppl_PIP_Tree_Node_tag \brief
Writes to \p dpip_tree the solution node if \p spip_tree is
a solution node, and 0 otherwise.
*/
@@ -2791,7 +2809,7 @@ ppl_PIP_Tree_Node_as_solution
PPL_PROTO((ppl_const_PIP_Tree_Node_t spip_tree,
ppl_const_PIP_Solution_Node_t* dpip_tree));
-/*! \relates ppl_PIP_Problem_tag \brief
+/*! \relates ppl_PIP_Tree_Node_tag \brief
Writes to \p dpip_tree the decision node if \p spip_tree
is a decision node, and 0 otherwise.
*/
@@ -2800,7 +2818,7 @@ ppl_PIP_Tree_Node_as_decision
PPL_PROTO((ppl_const_PIP_Tree_Node_t spip_tree,
ppl_const_PIP_Decision_Node_t* dpip_tree));
-/*! \relates ppl_PIP_Problem_tag \brief
+/*! \relates ppl_PIP_Tree_Node_tag \brief
Writes to \p pcs the local system of parameter constraints
at the pip tree node \p pip_tree.
*/
@@ -2809,7 +2827,7 @@ ppl_PIP_Tree_Node_get_constraints
PPL_PROTO((ppl_const_PIP_Tree_Node_t pip_tree,
ppl_const_Constraint_System_t* pcs));
-/*! \relates ppl_PIP_Problem_tag \brief
+/*! \relates ppl_PIP_Tree_Node_tag \brief
Returns a positive integer if \p pip_tree is well formed, i.e., if it
satisfies all its implementation invariants; returns 0 and perhaps
makes some noise if \p pip_tree is broken. Useful for debugging purposes.
@@ -2817,14 +2835,7 @@ PPL_PROTO((ppl_const_PIP_Tree_Node_t pip_tree,
int
ppl_PIP_Tree_Node_OK PPL_PROTO((ppl_const_PIP_Tree_Node_t pip));
-/*! \relates ppl_PIP_Problem_tag \brief
- Invalidates the handle \p pip_tree: this makes sure the corresponding
- resources will eventually be released.
-*/
-int
-ppl_delete_PIP_Tree_Node PPL_PROTO((ppl_const_PIP_Tree_Node_t pip));
-
-/*! \relates ppl_PIP_Problem_tag \brief
+/*! \relates ppl_PIP_Tree_Node_tag \brief
Assigns to \p pit a const iterator "pointing" to the beginning of
the artificial parameter sequence in the pip tree node \p pip_tree.
*/
@@ -2833,7 +2844,7 @@ ppl_PIP_Tree_Node_begin
PPL_PROTO((ppl_const_PIP_Tree_Node_t pip_tree,
ppl_Artificial_Parameter_Sequence_const_iterator_t pit));
-/*! \relates ppl_PIP_Problem_tag \brief
+/*! \relates ppl_PIP_Tree_Node_tag \brief
Assigns to \p pit a const iterator "pointing" to the end of
the artificial parameter sequence in the pip tree node \p pip_tree.
*/
@@ -2842,7 +2853,7 @@ ppl_PIP_Tree_Node_end
PPL_PROTO((ppl_const_PIP_Tree_Node_t pip_tree,
ppl_Artificial_Parameter_Sequence_const_iterator_t pit));
-/*! \relates ppl_PIP_Problem_tag \brief
+/*! \relates ppl_PIP_Tree_Node_tag \brief
Insert in parameter set the parameter indices corresponding to local
artificials.
@@ -2863,21 +2874,7 @@ PPL_PROTO((ppl_const_PIP_Tree_Node_t pip_tree,
ppl_dimension_type space_dim,
ppl_dimension_type inserted));
-/*! \relates ppl_PIP_Problem_tag \brief
- Builds a trivial PIP problem of dimension \p d and writes an
- handle to it at address \p pmip.
-*/
-int
-ppl_new_PIP_Solution_Node PPL_PROTO((ppl_PIP_Solution_Node_t* ppip_sol));
-
-/*! \relates ppl_PIP_Problem_tag \brief
- Invalidates the handle \p pip_sol: this makes sure the corresponding
- resources will eventually be released.
-*/
-int
-ppl_delete_PIP_Solution_Node PPL_PROTO((ppl_const_PIP_Solution_Node_t pip_sol));
-
-/*! \relates ppl_PIP_Problem_tag \brief
+/*! \relates ppl_PIP_Tree_Node_tag \brief
Writes to \p le a parametric expression of the values of variable \p v.
The linear expression assigned to \p le only involves parameters.
@@ -2900,15 +2897,7 @@ PPL_PROTO((ppl_const_PIP_Solution_Node_t pip_sol,
size_t n,
ppl_Linear_Expression_t le));
-
-/*! \relates ppl_PIP_Problem_tag \brief
- Invalidates the handle \p pip_dec: this makes sure the corresponding
- resources will eventually be released.
-*/
-int
-ppl_delete_PIP_Decision_Node PPL_PROTO((ppl_const_PIP_Decision_Node_t pip_dec));
-
-/*! \relates ppl_PIP_Problem_tag \brief
+/*! \relates ppl_PIP_Tree_Node_tag \brief
Writes to \p pip_tree a const pointer to the \p b (true or false) branch
of \p pip_dec.
*/
@@ -2918,36 +2907,15 @@ PPL_PROTO((ppl_const_PIP_Decision_Node_t pip_dec,
int b,
ppl_const_PIP_Tree_Node_t* pip_tree));
-/*! \relates ppl_PIP_Problem_tag \brief
- Creates a new artificial parameter corresponding to the constant 0 in a
- zero-dimensional space; writes a handle for the new artificial
- parameter at address \p pap.
-*/
-int
-ppl_new_Artificial_Parameter PPL_PROTO((ppl_Artificial_Parameter_t* pap));
-
-/*! \relates ppl_PIP_Problem_tag \brief
- Builds an artificial parameter that is the result of
- integer division of the linear expression \p le by \p coeff;
- writes a handle for the newly created artificial parameter
- at address \p pap.
+/*! \relates ppl_Artificial_Parameter_tag \brief
+ Writes to \p le the linear expression in artificial parameter \p ap.
*/
int
-ppl_new_Artificial_Parameter_from_Linear_Expression
-PPL_PROTO((ppl_Artificial_Parameter_t* pap,
- ppl_const_Linear_Expression_t le,
- ppl_Coefficient_t coeff));
-
-/*! \relates ppl_PIP_Problem_tag \brief
- Builds an artificial parameter that is a copy of \p ap; writes a handle
- for the newly created artificial parameter at address \p pap.
-*/
-int
-ppl_new_Artificial_Parameter_from_Artificial_Parameter
-PPL_PROTO((ppl_Artificial_Parameter_t* pap,
- ppl_const_Artificial_Parameter_t ap));
+ppl_Artificial_Parameter_get_Linear_Expression
+PPL_PROTO((ppl_const_Artificial_Parameter_t ap,
+ ppl_const_Linear_Expression_t* le));
-/*! \relates ppl_PIP_Problem_tag \brief
+/*! \relates ppl_Artificial_Parameter_tag \brief
Writes to \p coeff the denominator in artificial parameter \p ap.
*/
int
diff --git a/interfaces/C/ppl_c_implementation_common.cc b/interfaces/C/ppl_c_implementation_common.cc
index e0988c3..68cf73a 100644
--- a/interfaces/C/ppl_c_implementation_common.cc
+++ b/interfaces/C/ppl_c_implementation_common.cc
@@ -2336,20 +2336,6 @@ ppl_PIP_Tree_Node_insert_artificials(ppl_const_PIP_Tree_Node_t pip_tree,
CATCH_ALL
int
-ppl_new_PIP_Solution_Node(ppl_PIP_Solution_Node_t* ppip_sol) try {
- *ppip_sol = to_nonconst(new PIP_Solution_Node());
- return 0;
-}
-CATCH_ALL
-
-int
-ppl_delete_PIP_Solution_Node(ppl_const_PIP_Solution_Node_t pip_sol) try {
- delete to_const(pip_sol);
- return 0;
-}
-CATCH_ALL
-
-int
ppl_PIP_Solution_Node_get_parametric_values
(ppl_const_PIP_Solution_Node_t pip_sol,
ppl_dimension_type v,
@@ -2395,30 +2381,12 @@ ppl_PIP_Decision_Node_get_child_node(ppl_const_PIP_Decision_Node_t pip_dec,
CATCH_ALL
int
-ppl_new_Artificial_Parameter(ppl_Artificial_Parameter_t* pap) try {
- *pap = to_nonconst(new Artificial_Parameter());
- return 0;
-}
-CATCH_ALL
-
-int
-ppl_new_Artificial_Parameter_from_Linear_Expression
-(ppl_Artificial_Parameter_t* pap,
- ppl_const_Linear_Expression_t le,
- ppl_const_Coefficient_t coef) try {
- const Linear_Expression& sle = *to_const(le);
- const Coefficient& scoef = *to_const(coef);
- *pap = to_nonconst(new Artificial_Parameter(sle, scoef));
- return 0;
-}
-CATCH_ALL
-
-int
-ppl_new_Artificial_Parameter_from_Artificial_Parameter
-(ppl_Artificial_Parameter_t* pap,
- ppl_const_Artificial_Parameter_t ap) try {
+ppl_Artificial_Parameter_get_Linear_Expression
+(ppl_const_Artificial_Parameter_t ap,
+ ppl_const_Linear_Expression_t* le) try {
const Artificial_Parameter& sap = *to_const(ap);
- *pap = to_nonconst(new Artificial_Parameter(sap));
+ const Linear_Expression& lle = static_cast<const Linear_Expression&>(sap);
+ *le = to_const(&lle);
return 0;
}
CATCH_ALL
@@ -2558,6 +2526,8 @@ DEFINE_OUTPUT_FUNCTIONS(MIP_Problem)
DEFINE_OUTPUT_FUNCTIONS(PIP_Problem)
+DEFINE_OUTPUT_FUNCTIONS(Artificial_Parameter)
+
char*
ppl_io_wrap_string(const char* src,
unsigned indent_depth,
More information about the PPL-devel
mailing list