summaryrefslogtreecommitdiff
path: root/gmpxx.h
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2011-05-10 22:12:34 +0200
committerMarc Glisse <marc.glisse@inria.fr>2011-05-10 22:12:34 +0200
commitb672cadf0ce5c37ae3fa13324bd8b798c838b7ed (patch)
tree5f6ac6541e18e82500fd4c100f480b5ecb389367 /gmpxx.h
parentf2f538129f025bf4b1d0e3e35fdf0ad66f243ed8 (diff)
downloadgmp-b672cadf0ce5c37ae3fa13324bd8b798c838b7ed.tar.gz
Test stream input/output on mp*_class and not just mp*_t.
Simple optimization: c=-(a+b) becomes c=a+b;c=-c.
Diffstat (limited to 'gmpxx.h')
-rw-r--r--gmpxx.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/gmpxx.h b/gmpxx.h
index 1506a1c26..8abb8b272 100644
--- a/gmpxx.h
+++ b/gmpxx.h
@@ -1814,12 +1814,15 @@ inline std::istream & operator>>(std::istream &i, __gmp_expr<T, T> &expr)
return i >> expr.__get_mp();
}
+/*
+// you might want to uncomment this
inline std::istream & operator>>(std::istream &i, mpq_class &q)
{
i >> q.get_mpq_t();
- // q.canonicalize(); // you might want to uncomment this
+ q.canonicalize();
return i;
}
+*/
/**************** Functions for type conversion ****************/
@@ -1948,10 +1951,10 @@ private:
public:
__gmp_expr(const val_type &val) : expr(val) { }
void eval(typename __gmp_resolve_expr<T>::ptr_type p) const
- { __gmp_expr<T, T> temp(expr.val); Op::eval(p, temp.__get_mp()); }
+ { expr.val.eval(p); Op::eval(p, p); }
void eval(typename __gmp_resolve_expr<T>::ptr_type p,
mp_bitcnt_t prec) const
- { __gmp_expr<T, T> temp(expr.val, prec); Op::eval(p, temp.__get_mp()); }
+ { expr.val.eval(p, prec); Op::eval(p, p); }
const val_type & get_val() const { return expr.val; }
mp_bitcnt_t get_prec() const { return expr.val.get_prec(); }
};