diff --git a/src/numerics/mpbq.h b/src/numerics/mpbq.h index febd2a55b..ce6649a4e 100644 --- a/src/numerics/mpbq.h +++ b/src/numerics/mpbq.h @@ -163,6 +163,7 @@ public: mpbq operator--(int) { mpbq r(*this); --(*this); return r; } friend void power(mpbq & a, mpbq const & b, unsigned k); + friend void _power(mpbq & a, mpbq const & b, unsigned k) { power(a, b, k); } /** \brief Return the magnitude of a = b/2^k. @@ -253,6 +254,8 @@ public: static void set_rounding(bool plus_inf) {} static void neg(mpbq & v) { v.neg(); } static void reset(mpbq & v) { v = 0; } + // v <- v^k + static void power(mpbq & v, unsigned k) { _power(v, v, k); } }; } diff --git a/src/numerics/mpq.h b/src/numerics/mpq.h index af388417a..00167346d 100644 --- a/src/numerics/mpq.h +++ b/src/numerics/mpq.h @@ -195,6 +195,7 @@ public: friend mpz ceil(mpq const & a); friend void power(mpq & a, mpq const & b, unsigned k); + friend void _power(mpq & a, mpq const & b, unsigned k) { power(a, b, k); } friend mpq power(mpq a, unsigned k) { power(a, a, k); return a; } friend std::ostream & operator<<(std::ostream & out, mpq const & v); @@ -222,6 +223,8 @@ public: static void neg(mpq & v) { v.neg(); } static void inv(mpq & v) { v.inv(); } static void reset(mpq & v) { v = 0; } + // v <- v^k + static void power(mpq & v, unsigned k) { _power(v, v, k); } }; } diff --git a/src/numerics/mpz.h b/src/numerics/mpz.h index f73d7c4cf..3d7657c06 100644 --- a/src/numerics/mpz.h +++ b/src/numerics/mpz.h @@ -202,6 +202,7 @@ public: unsigned power_of_two_multiple() const { return mpz_scan1(m_val, 0); } friend void power(mpz & a, mpz const & b, unsigned k) { mpz_pow_ui(a.m_val, b.m_val, k); } + friend void _power(mpz & a, mpz const & b, unsigned k) { power(a, b, k); } friend mpz power(mpz const & a, unsigned k) { mpz r; power(r, a, k); return r; } friend void rootrem(mpz & root, mpz & rem, mpz const & a, unsigned k) { mpz_rootrem(root.m_val, rem.m_val, a.m_val, k); } @@ -228,6 +229,8 @@ public: static void set_rounding(bool plus_inf) {} static void neg(mpz & v) { v.neg(); } static void reset(mpz & v) { v = 0; } + // v <- v^k + static void power(mpz & v, unsigned k) { _power(v, v, k); } }; } diff --git a/src/numerics/numeric_traits.h b/src/numerics/numeric_traits.h index 0dc70a35c..9106017ea 100644 --- a/src/numerics/numeric_traits.h +++ b/src/numerics/numeric_traits.h @@ -26,7 +26,7 @@ public: static void neg(double & v) { v = -v; } static void inv(double & v) { v = 1.0/v; } static void reset(double & v) { v = 0.0; } - // b <- b^k + // v <- v^k static void power(double & v, unsigned k) { double_power(v, k); } };