[PPL-devel] [GIT] ppl/ppl(termination): New Linear_Expression methods.
Roberto Bagnara
bagnara at cs.unipr.it
Thu Mar 18 15:26:42 CET 2010
Module: ppl/ppl
Branch: termination
Commit: a1178929241483912d8f0839edf1f512a552653c
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=a1178929241483912d8f0839edf1f512a552653c
Author: Roberto Bagnara <bagnara at cs.unipr.it>
Date: Thu Mar 18 18:22:12 2010 +0400
New Linear_Expression methods.
Methods bool Linear_Expression::is_zero() const and
bool Linear_Expression::all_homogeneous_terms_are_zero() const
return true if and only if `*this' is 0, and if and only if all the
homogeneous terms of `*this' are 0, respectively.
---
NEWS | 8 ++++++++
TODO | 3 +++
src/Linear_Expression.defs.hh | 9 +++++++++
src/Linear_Expression.inlines.hh | 10 ++++++++++
src/Linear_Row.cc | 9 +++++++++
src/Linear_Row.defs.hh | 6 ++++++
6 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/NEWS b/NEWS
index 1c71776..eea5229 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,14 @@ o The C and Java interfaces now support timeout computation facilities.
o New configuration option `--with-gmp-build=DIR' allows to use a
non-installed build of GMP in DIR.
+o New methods
+
+ bool Linear_Expression::is_zero() const
+ bool Linear_Expression::all_homogeneous_terms_are_zero() const
+
+ return true if and only if `*this' is 0, and if and only if all the
+ homogeneous terms of `*this' are 0, respectively.
+
Deprecated and removed methods
------------------------------
diff --git a/TODO b/TODO
index ddebb7f..1b37708 100644
--- a/TODO
+++ b/TODO
@@ -2,6 +2,9 @@
Enhancements for PPL 0.11
=========================
+- Interface Linear_Expression::is_zero()
+ and Linear_Expression::all_homogeneous_terms_are_zero()
+ for all the non-C++ interfaces.
- Handle std::logic_error (now thrown in case watchdogs are not
available) in all the interfaces.
- Make all the *affine*image() methods uniform as far as the
diff --git a/src/Linear_Expression.defs.hh b/src/Linear_Expression.defs.hh
index b4ce1e0..5e4c81d 100644
--- a/src/Linear_Expression.defs.hh
+++ b/src/Linear_Expression.defs.hh
@@ -322,6 +322,15 @@ public:
//! Returns the inhomogeneous term of \p *this.
Coefficient_traits::const_reference inhomogeneous_term() const;
+ //! Returns <CODE>true</CODE> if and only if \p *this is \f$0\f$.
+ bool is_zero() const;
+
+ /*! \brief
+ Returns <CODE>true</CODE> if and only if all the homogeneous
+ terms of \p *this are \f$0\f$.
+ */
+ bool all_homogeneous_terms_are_zero() const;
+
//! Initializes the class.
static void initialize();
diff --git a/src/Linear_Expression.inlines.hh b/src/Linear_Expression.inlines.hh
index 70b9252..d587be2 100644
--- a/src/Linear_Expression.inlines.hh
+++ b/src/Linear_Expression.inlines.hh
@@ -82,6 +82,16 @@ Linear_Expression::inhomogeneous_term() const {
return Linear_Row::inhomogeneous_term();
}
+inline bool
+Linear_Expression::is_zero() const {
+ return Linear_Row::is_zero();
+}
+
+inline bool
+Linear_Expression::all_homogeneous_terms_are_zero() const {
+ return Linear_Row::all_homogeneous_terms_are_zero();
+}
+
inline const Linear_Expression&
Linear_Expression::zero() {
PPL_ASSERT(zero_p != 0);
diff --git a/src/Linear_Row.cc b/src/Linear_Row.cc
index 294a16c..6bccb92 100644
--- a/src/Linear_Row.cc
+++ b/src/Linear_Row.cc
@@ -122,6 +122,15 @@ PPL::Linear_Row::linear_combine(const Linear_Row& y, const dimension_type k) {
}
bool
+PPL::Linear_Row::is_zero() const {
+ const Linear_Row& x = *this;
+ for (dimension_type i = x.size(); i-- > 0; )
+ if (x[i] != 0)
+ return false;
+ return true;
+}
+
+bool
PPL::Linear_Row::all_homogeneous_terms_are_zero() const {
const Linear_Row& x = *this;
for (dimension_type i = x.size(); --i > 0; )
diff --git a/src/Linear_Row.defs.hh b/src/Linear_Row.defs.hh
index 0c887de..5163224 100644
--- a/src/Linear_Row.defs.hh
+++ b/src/Linear_Row.defs.hh
@@ -360,6 +360,12 @@ public:
void linear_combine(const Linear_Row& y, dimension_type k);
/*! \brief
+ Returns <CODE>true</CODE> if and only if all the
+ terms of \p *this are \f$0\f$.
+ */
+ bool is_zero() const;
+
+ /*! \brief
Returns <CODE>true</CODE> if and only if all the homogeneous
terms of \p *this are \f$0\f$.
*/
More information about the PPL-devel
mailing list