[PPL-devel] [GIT] ppl/ppl(master): Bit_Matrix, Sparse_Matrix: rename the {rows, columns}_erase_to_end() methods into remove_trailing_{rows, columns}(), changing the argument's meaning.

Marco Poletti poletti.marco at gmail.com
Mon Sep 20 20:22:29 CEST 2010


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

Author: Marco Poletti <poletti.marco at gmail.com>
Date:   Mon Sep 20 20:20:16 2010 +0200

Bit_Matrix, Sparse_Matrix: rename the {rows,columns}_erase_to_end() methods into remove_trailing_{rows,columns}(), changing the argument's meaning.

---

 src/Bit_Matrix.defs.hh      |    8 ++++----
 src/Bit_Matrix.inlines.hh   |   18 +++++++++---------
 src/Linear_System.cc        |    2 +-
 src/Polyhedron_widenings.cc |    5 +++--
 src/conversion.cc           |    7 ++++---
 src/simplify.cc             |    2 +-
 6 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/src/Bit_Matrix.defs.hh b/src/Bit_Matrix.defs.hh
index b7c0629..97191ce 100644
--- a/src/Bit_Matrix.defs.hh
+++ b/src/Bit_Matrix.defs.hh
@@ -102,11 +102,11 @@ public:
   */
   void add_recycled_row(Bit_Row& row);
 
-  //! Erases the rows from the \p first_to_erase -th to the last one.
-  void rows_erase_to_end(dimension_type first_to_erase);
+  //! Removes the last \p n rows.
+  void remove_trailing_rows(dimension_type n);
 
-  //! Erases the columns from the \p first_to_erase -th to the last one.
-  void columns_erase_to_end(dimension_type first_to_erase);
+  //! Removes the last \p n columns.
+  void remove_trailing_columns(dimension_type n);
 
   //! Resizes the matrix copying the old contents.
   void resize(dimension_type new_n_rows, dimension_type new_n_columns);
diff --git a/src/Bit_Matrix.inlines.hh b/src/Bit_Matrix.inlines.hh
index fade705..a4d8c59 100644
--- a/src/Bit_Matrix.inlines.hh
+++ b/src/Bit_Matrix.inlines.hh
@@ -57,21 +57,21 @@ Bit_Matrix::~Bit_Matrix() {
 }
 
 inline void
-Bit_Matrix::rows_erase_to_end(const dimension_type first_to_erase) {
-  // The first row to be erased cannot be greater
+Bit_Matrix::remove_trailing_rows(const dimension_type n) {
+  // The number of rows to be erased cannot be greater
   // than the actual number of the rows of the matrix.
-  PPL_ASSERT(first_to_erase <= rows.size());
-  if (first_to_erase < rows.size())
-    rows.erase(rows.begin() + first_to_erase, rows.end());
+  PPL_ASSERT(n <= rows.size());
+  if (n != 0)
+    rows.erase(rows.end() - n, rows.end());
   PPL_ASSERT(OK());
 }
 
 inline void
-Bit_Matrix::columns_erase_to_end(const dimension_type first_to_erase) {
-  // The first column to be erased cannot be greater
+Bit_Matrix::remove_trailing_columns(const dimension_type n) {
+  // The number of columns to be erased cannot be greater
   // than the actual number of the columns of the matrix.
-  PPL_ASSERT(first_to_erase <= row_size);
-  row_size = first_to_erase;
+  PPL_ASSERT(n <= row_size);
+  row_size -= n;
   PPL_ASSERT(OK());
 }
 
diff --git a/src/Linear_System.cc b/src/Linear_System.cc
index 9bc4893..3657206 100644
--- a/src/Linear_System.cc
+++ b/src/Linear_System.cc
@@ -530,7 +530,7 @@ PPL::Linear_System::sort_and_remove_with_sat(Bit_Matrix& sat) {
   sys.remove_trailing_rows(num_duplicates);
   sys.set_index_first_pending_row(new_first_pending_row);
   // ... and the corresponding rows of the saturation matrix.
-  sat.rows_erase_to_end(sat.num_rows() - num_duplicates);
+  sat.remove_trailing_rows(num_duplicates);
   PPL_ASSERT(sys.check_sorted());
   // Now the system is sorted.
   sys.set_sorted(true);
diff --git a/src/Polyhedron_widenings.cc b/src/Polyhedron_widenings.cc
index 716886b..d8927c8 100644
--- a/src/Polyhedron_widenings.cc
+++ b/src/Polyhedron_widenings.cc
@@ -97,13 +97,14 @@ PPL::Polyhedron
   // this is needed in order to widen the polyhedron and not the
   // corresponding homogenized polyhedral cone.
   const Constraint_System& y_cs = y.con_sys;
-  dimension_type num_rows = y_cs.num_rows();
+  const dimension_type old_num_rows = y_cs.num_rows();
+  dimension_type num_rows = old_num_rows;
   for (dimension_type i = 0; i < num_rows; ++i)
     if (y_cs[i].is_tautological()) {
       --num_rows;
       std::swap(tmp_sat_g[i], tmp_sat_g[num_rows]);
     }
-  tmp_sat_g.rows_erase_to_end(num_rows);
+  tmp_sat_g.remove_trailing_rows(old_num_rows - num_rows);
   tmp_sat_g.sort_rows();
 
   // A constraint in `con_sys' is copied to `cs_selected'
diff --git a/src/conversion.cc b/src/conversion.cc
index bf321e4..a7297ec 100644
--- a/src/conversion.cc
+++ b/src/conversion.cc
@@ -822,7 +822,7 @@ PPL::Polyhedron::conversion(Linear_System& source,
   if (source_num_redundant > 0) {
     PPL_ASSERT(source_num_redundant == source.num_rows() - source_num_rows);
     source.remove_trailing_rows(source_num_redundant);
-    sat.columns_erase_to_end(source_num_rows);
+    sat.remove_trailing_columns(source_num_redundant);
   }
   // If `start == 0', then `source' was sorted and remained so.
   // If otherwise `start > 0', then the two sub-system made by the
@@ -839,11 +839,12 @@ PPL::Polyhedron::conversion(Linear_System& source,
   // We may have identified some redundant rays in `dest',
   // which have been swapped at the end of the system.
   if (dest_num_rows < dest.num_rows()) {
-    dest.remove_trailing_rows(dest.num_rows() - dest_num_rows);
+    const dimension_type num_removed_rows = dest.num_rows() - dest_num_rows;
+    dest.remove_trailing_rows(num_removed_rows);
     // Be careful: we might have erased some of the non-pending rows.
     if (dest.first_pending_row() > dest_num_rows)
       dest.unset_pending_rows();
-    sat.rows_erase_to_end(dest_num_rows);
+    sat.remove_trailing_rows(num_removed_rows);
   }
   if (dest.is_sorted())
     // If the non-pending generators in `dest' are still declared to be
diff --git a/src/simplify.cc b/src/simplify.cc
index 7d24813..330f93b 100644
--- a/src/simplify.cc
+++ b/src/simplify.cc
@@ -295,7 +295,7 @@ PPL::Polyhedron::simplify(Linear_System& sys, Bit_Matrix& sat) {
   // moved to the bottom of `sys' and the corresponding `sat' rows.
   sys.remove_trailing_rows(old_num_rows - num_rows);
   sys.unset_pending_rows();
-  sat.rows_erase_to_end(num_rows);
+  sat.remove_trailing_rows(old_num_rows - num_rows);
   // At this point the first `num_lines_or_equalities' rows of 'sys'
   // represent the irredundant equalities, while the remaining rows
   // (i.e., those having indexes from `num_lines_or_equalities' to




More information about the PPL-devel mailing list