[PPL-devel] [GIT] ppl/ppl(master): Added helper function least_significant_one_mask().

Enea Zaffanella zaffanella at cs.unipr.it
Sat Feb 25 16:14:06 CET 2012


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

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Sat Feb 25 16:08:48 2012 +0100

Added helper function least_significant_one_mask().

---

 src/globals.defs.hh    |    3 +++
 src/globals.inlines.hh |    8 +++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/globals.defs.hh b/src/globals.defs.hh
index 2c54772..a7e46a3 100644
--- a/src/globals.defs.hh
+++ b/src/globals.defs.hh
@@ -497,6 +497,9 @@ template <typename RA_Container>
 typename RA_Container::const_iterator
 nth_iter(const RA_Container& cont, dimension_type n);
 
+dimension_type
+least_significant_one_mask(dimension_type i);
+
 } // namespace Parma_Polyhedra_Library
 
 // By default, use sparse matrices both for MIP_Problem and PIP_Problem.
diff --git a/src/globals.inlines.hh b/src/globals.inlines.hh
index d176bb0..0d27ddb 100644
--- a/src/globals.inlines.hh
+++ b/src/globals.inlines.hh
@@ -39,7 +39,8 @@ not_a_dimension() {
 inline int32_t
 hash_code_from_dimension(dimension_type dim) {
   const dimension_type divisor = 1U << (32 - 1);
-  return static_cast<int32_t>(dim % divisor);
+  dim = dim % divisor;
+  return static_cast<int32_t>(dim);
 }
 
 inline const Weightwatch_Traits::Threshold&
@@ -142,6 +143,11 @@ nth_iter(const RA_Container& cont, dimension_type n) {
   return cont.begin() + static_cast<diff_t>(n);
 }
 
+inline dimension_type
+least_significant_one_mask(const dimension_type i) {
+  return i & (~i + 1U);
+}
+
 } // namespace Parma_Polyhedra_Library
 
 #endif // !defined(PPL_globals_inlines_hh)




More information about the PPL-devel mailing list