From 9a0a59d5c85c4a1d2469f43e9d2b433e156810ba Mon Sep 17 00:00:00 2001 From: Tim King Date: Wed, 15 Feb 2012 21:52:16 +0000 Subject: This commit merges into trunk the branch branches/arithmetic/integers2 from r2650 to r2779. - This excludes revision 2777. This revision had some strange performance implications and was delaying the merge. - This includes the new DioSolver. The DioSolver can discover conflicts, produce substitutions, and produce cuts. - The DioSolver can be disabled at command line using --disable-dio-solver. - This includes a number of changes to the arithmetic normal form. - The Integer class features a number of new number theoretic function. - This commit includes a few rather loud warning. I will do my best to take care of them today. --- src/util/rational_gmp_imp.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/util/rational_gmp_imp.h') diff --git a/src/util/rational_gmp_imp.h b/src/util/rational_gmp_imp.h index 37c3c8364..4635ce881 100644 --- a/src/util/rational_gmp_imp.h +++ b/src/util/rational_gmp_imp.h @@ -169,6 +169,14 @@ public: return mpq_sgn(d_value.get_mpq_t()); } + Rational abs() const { + if(sgn() < 0){ + return -(*this); + }else{ + return *this; + } + } + Integer floor() const { mpz_class q; mpz_fdiv_q(q.get_mpz_t(), d_value.get_num_mpz_t(), d_value.get_den_mpz_t()); @@ -244,6 +252,10 @@ public: return (*this); } + bool isIntegral() const{ + return getDenominator() == 1; + } + /** Returns a string representing the rational in the given base. */ std::string toString(int base = 10) const { return d_value.get_str(base); -- cgit v1.2.3