summaryrefslogtreecommitdiff
path: root/src/util/rational_gmp_imp.h
diff options
context:
space:
mode:
authorTim King <taking@cs.nyu.edu>2013-04-26 17:10:21 -0400
committerMorgan Deters <mdeters@cs.nyu.edu>2013-04-26 17:10:21 -0400
commit9098391fe334d829ec4101f190b8f1fa21c30752 (patch)
treeb134fc1fe1c767a50013e1449330ca6a7ee18a3d /src/util/rational_gmp_imp.h
parenta9174ce4dc3939bbe14c9aa1fd11c79c7877eb16 (diff)
FCSimplex branch merge
Diffstat (limited to 'src/util/rational_gmp_imp.h')
-rw-r--r--src/util/rational_gmp_imp.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/util/rational_gmp_imp.h b/src/util/rational_gmp_imp.h
index 0916b523a..02ccc273c 100644
--- a/src/util/rational_gmp_imp.h
+++ b/src/util/rational_gmp_imp.h
@@ -156,7 +156,6 @@ public:
}
~Rational() {}
-
/**
* Returns the value of numerator of the Rational.
* Note that this makes a deep copy of the numerator.
@@ -173,6 +172,13 @@ public:
return Integer(d_value.get_den());
}
+ /** Return an exact rational for a double d. */
+ static Rational fromDouble(double d){
+ Rational q;
+ mpq_set_d(q.d_value.get_mpq_t(), d);
+ return q;
+ }
+
/**
* Get a double representation of this Rational, which is
* approximate: truncation may occur, overflow may result in
@@ -280,6 +286,10 @@ public:
d_value += y.d_value;
return (*this);
}
+ Rational& operator-=(const Rational& y){
+ d_value -= y.d_value;
+ return (*this);
+ }
Rational& operator*=(const Rational& y){
d_value *= y.d_value;
@@ -311,6 +321,11 @@ public:
return numeratorHash xor denominatorHash;
}
+ uint32_t complexity() const {
+ uint32_t numLen = getNumerator().length();
+ uint32_t denLen = getDenominator().length();
+ return numLen + denLen;
+ }
};/* class Rational */
struct RationalHashFunction {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback