[PPL-devel] [GIT] ppl/ppl(termination): All_affine_ranking_functions_PR* functions,

Patricia Hill p.m.hill at leeds.ac.uk
Thu Mar 18 18:03:02 CET 2010


Module: ppl/ppl
Branch: termination
Commit: 9c9130e247463a5500fabf77b26852d9587e30c3
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=9c9130e247463a5500fabf77b26852d9587e30c3

Author: Patricia Hill <p.m.hill at leeds.ac.uk>
Date:   Thu Mar 18 17:00:03 2010 +0000

All_affine_ranking_functions_PR* functions,
for the C and Prolog interfaces now take an NNC polyhedron
as the last argument and not a C one.
Interface Linear_Expression::is_zero()
and Linear_Expression::all_homogeneous_terms_are_zero()
added to the C and Prolog interfaces.

---

 interfaces/C/ppl_c_header.h                        |   14 +++++++++++
 interfaces/C/ppl_c_implementation_common.cc        |   13 ++++++++++
 interfaces/C/ppl_interface_generator_c_cc_code.m4  |   12 ++++-----
 .../ppl_interface_generator_prolog_cc_code.m4      |    4 +-
 interfaces/Prolog/ppl_prolog_common.cc             |   24 ++++++++++++++++++++
 interfaces/Prolog/ppl_prolog_common.defs.hh        |    6 +++++
 interfaces/ppl_interface_generator_common_dat.m4   |    4 +++
 7 files changed, 68 insertions(+), 9 deletions(-)

diff --git a/interfaces/C/ppl_c_header.h b/interfaces/C/ppl_c_header.h
index d899321..a6c24e8 100644
--- a/interfaces/C/ppl_c_header.h
+++ b/interfaces/C/ppl_c_header.h
@@ -1013,6 +1013,20 @@ PPL_PROTO((ppl_const_Linear_Expression_t le, ppl_Coefficient_t n));
 int
 ppl_Linear_Expression_OK PPL_PROTO((ppl_const_Linear_Expression_t le));
 
+/*! \relates ppl_Linear_Expression_tag \brief
+    Returns <CODE>true</CODE> if and only if \p *this is \f$0\f$.
+*/
+int
+ppl_Linear_Expression_is_zero PPL_PROTO((ppl_const_Linear_Expression_t le));
+
+/*! \relates ppl_Linear_Expression_tag \brief
+    Returns <CODE>true</CODE> if and only if all the homogeneous
+    terms of \p *this are \f$0\f$.
+*/
+int
+ppl_Linear_Expression_all_homogeneous_terms_are_zero
+PPL_PROTO((ppl_const_Linear_Expression_t le));
+
 /*@}*/ /* Functions that Do Not Modify the Linear Expression */
 
 /*! \brief \name Functions that May Modify the Linear Expression */
diff --git a/interfaces/C/ppl_c_implementation_common.cc b/interfaces/C/ppl_c_implementation_common.cc
index 8884870..3380207 100644
--- a/interfaces/C/ppl_c_implementation_common.cc
+++ b/interfaces/C/ppl_c_implementation_common.cc
@@ -616,6 +616,19 @@ ppl_Linear_Expression_OK(ppl_const_Linear_Expression_t le) try {
 }
 CATCH_ALL
 
+int
+ppl_Linear_Expression_is_zero(ppl_const_Linear_Expression_t le) try {
+  return to_const(le)->is_zero() ? 1 : 0;
+}
+CATCH_ALL
+
+int
+ppl_Linear_Expression_all_homogeneous_terms_are_zero
+  (ppl_const_Linear_Expression_t le) try {
+  return to_const(le)->all_homogeneous_terms_are_zero() ? 1 : 0;
+}
+CATCH_ALL
+
 /* Interface for Constraint. */
 
 int
diff --git a/interfaces/C/ppl_interface_generator_c_cc_code.m4 b/interfaces/C/ppl_interface_generator_c_cc_code.m4
index ec9efca..3cef2d7 100644
--- a/interfaces/C/ppl_interface_generator_c_cc_code.m4
+++ b/interfaces/C/ppl_interface_generator_c_cc_code.m4
@@ -1226,9 +1226,8 @@ ppl_all_affine_ranking_functions_ at TERMINATION_ID@_ at TOPOLOGY@@CLASS@
  ppl_Polyhedron_t ph) try {
   const @TOPOLOGY@@CPP_CLASS@& ppset
     = *static_cast<const @TOPOLOGY@@CPP_CLASS@*>(to_const(pset));
-  all_affine_ranking_functions_ at TERMINATION_ID@(ppset,
-                                                *static_cast<C_Polyhedron*>
-                                                    (to_nonconst(ph)));
+  all_affine_ranking_functions_ at TERMINATION_ID@
+    (ppset, *static_cast<@A_TERMINATION_ID at Polyhedron*> (to_nonconst(ph)));
   return 0;
 }
 CATCH_ALL
@@ -1245,10 +1244,9 @@ ppl_all_affine_ranking_functions_ at TERMINATION_ID@_ at TOPOLOGY@@CLASS at _2
     = *static_cast<const @TOPOLOGY@@CPP_CLASS@*>(to_const(pset_before));
   const @TOPOLOGY@@CPP_CLASS@& ppset_after
     = *static_cast<const @TOPOLOGY@@CPP_CLASS@*>(to_const(pset_after));
-  all_affine_ranking_functions_ at TERMINATION_ID@_2(ppset_before,
-                                                  ppset_after,
-                                                *static_cast<C_Polyhedron*>
-                                                    (to_nonconst(ph)));
+  all_affine_ranking_functions_ at TERMINATION_ID@_2
+    (ppset_before, ppset_after,
+     *static_cast<@A_TERMINATION_ID at Polyhedron*>(to_nonconst(ph)));
   return 0;
 }
 CATCH_ALL
diff --git a/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4 b/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4
index 4135130..eda31cf 100644
--- a/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4
+++ b/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4
@@ -1324,7 +1324,7 @@ m4_define(`ppl_all_affine_ranking_functions_ at TERMINATION_ID@_ at TOPOLOGY@@CLASS at _c
   try {
     @TOPOLOGY@@CPP_CLASS@* pset = term_to_handle<@TOPOLOGY@@CPP_CLASS@ >(t_pset, where);
     PPL_CHECK(pset);
-    C_Polyhedron* ph = new C_Polyhedron();
+    @A_TERMINATION_ID at Polyhedron* ph = new @A_TERMINATION_ID at Polyhedron();
     Parma_Polyhedra_Library
       ::all_affine_ranking_functions_ at TERMINATION_ID@(*pset, *ph);
       Prolog_term_ref tmp = Prolog_new_term_ref();
@@ -1357,7 +1357,7 @@ m4_define(`ppl_all_affine_ranking_functions_ at TERMINATION_ID@_ at TOPOLOGY@@CLASS at _2
        = term_to_handle<@TOPOLOGY@@CPP_CLASS@ >(t_pset_after, where);
     PPL_CHECK(pset_before);
     PPL_CHECK(pset_after);
-    C_Polyhedron* ph = new C_Polyhedron();
+    @A_TERMINATION_ID at Polyhedron* ph = new @A_TERMINATION_ID at Polyhedron();
     Parma_Polyhedra_Library
       ::all_affine_ranking_functions_ at TERMINATION_ID@_2(*pset_before,
                                                         *pset_after,
diff --git a/interfaces/Prolog/ppl_prolog_common.cc b/interfaces/Prolog/ppl_prolog_common.cc
index 5a186e8..19c666f 100644
--- a/interfaces/Prolog/ppl_prolog_common.cc
+++ b/interfaces/Prolog/ppl_prolog_common.cc
@@ -1704,6 +1704,30 @@ ppl_Coefficient_max(Prolog_term_ref t_max) {
 }
 
 extern "C" Prolog_foreign_return_type
+ppl_Linear_Expression_is_zero(Prolog_term_ref t_le_expr) {
+  static const char* where = "ppl_Linear_Expression_is_zero/1";
+  try {
+    Linear_Expression le_expr = build_linear_expression(t_le_expr, where);
+    if (le_expr.is_zero())
+      return PROLOG_SUCCESS;
+  }
+  CATCH_ALL;
+}
+
+extern "C" Prolog_foreign_return_type
+ppl_Linear_Expression_all_homogeneous_terms_are_zero(Prolog_term_ref t_le_expr)
+{
+  static const char* where
+    = "ppl_Linear_Expression_all_homogeneous_terms_are_zero/1";
+  try {
+    Linear_Expression le_expr = build_linear_expression(t_le_expr, where);
+    if (le_expr.all_homogeneous_terms_are_zero())
+      return PROLOG_SUCCESS;
+  }
+  CATCH_ALL;
+}
+
+extern "C" Prolog_foreign_return_type
 ppl_new_MIP_Problem_from_space_dimension
 (Prolog_term_ref t_nd, Prolog_term_ref t_mip) {
   static const char* where = "ppl_MIP_Problem_from_space_dimension/2";
diff --git a/interfaces/Prolog/ppl_prolog_common.defs.hh b/interfaces/Prolog/ppl_prolog_common.defs.hh
index 33af32d..3511064 100644
--- a/interfaces/Prolog/ppl_prolog_common.defs.hh
+++ b/interfaces/Prolog/ppl_prolog_common.defs.hh
@@ -719,6 +719,12 @@ extern "C" Prolog_foreign_return_type
 ppl_Coefficient_max(Prolog_term_ref t_max);
 
 extern "C" Prolog_foreign_return_type
+ppl_Linear_Expression_is_zero(Prolog_term_ref t_bool);
+
+extern "C" Prolog_foreign_return_type
+ppl_Linear_Expression_all_homogeneous_terms_are_zero(Prolog_term_ref t_bool);
+
+extern "C" Prolog_foreign_return_type
 ppl_new_MIP_Problem_from_space_dimension
 (Prolog_term_ref t_nd, Prolog_term_ref t_mip);
 
diff --git a/interfaces/ppl_interface_generator_common_dat.m4 b/interfaces/ppl_interface_generator_common_dat.m4
index 64ae91f..57cd897 100644
--- a/interfaces/ppl_interface_generator_common_dat.m4
+++ b/interfaces/ppl_interface_generator_common_dat.m4
@@ -988,3 +988,7 @@ m4_define(`m4_Pointset_Powerset_membytes_replacements',
 
 dnl  The termination algorithms are either sourced from MS or PR.
 m4_define(`m4_termination_id_replacements', `MS, PR')
+
+dnl If sourced from MS, the last argument is C_Polyhedron,
+dnl If sourced from PR, the last argument is NNC_Polyhedron.
+m4_define(`m4_a_termination_id_replacements', `C_, NNC_')




More information about the PPL-devel mailing list