From d55a10e31104d0b49c6c9af3d7ed9dadb9817683 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Sun, 7 Jun 2015 05:09:06 +0900 Subject: [PATCH] remove local:: --- include/mcl/fp.hpp | 8 ++++---- include/mcl/fp_base.hpp | 4 ---- src/fp.cpp | 18 +++++++++--------- test/base_test.cpp | 10 +++++----- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index cceb909..24ea9d8 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -144,7 +144,7 @@ public: mpz_class x; inFromStr(x, &isMinus, str, base); if (x >= op_.mp) throw cybozu::Exception("fp:FpT:fromStr:large str") << str << op_.mp; - fp::local::toArray(v_, op_.N, x.get_mpz_t()); + fp::toArray(v_, op_.N, x.get_mpz_t()); if (isMinus) { neg(*this, *this); } @@ -305,7 +305,7 @@ public: } bool isValid() const { - return fp::local::compareArray(v_, op_.p, op_.N) < 0; + return fp::compareArray(v_, op_.p, op_.N) < 0; } void fromBitVec(const cybozu::BitVector& bv) { @@ -314,7 +314,7 @@ public: } static inline size_t getModBitLen() { return op_.bitLen; } static inline size_t getBitVecSize() { return op_.bitLen; } - bool operator==(const FpT& rhs) const { return fp::local::isEqualArray(v_, rhs.v_, op_.N); } + bool operator==(const FpT& rhs) const { return fp::isEqualArray(v_, rhs.v_, op_.N); } bool operator!=(const FpT& rhs) const { return !operator==(rhs); } inline friend FpT operator+(const FpT& x, const FpT& y) { FpT z; add(z, x, y); return z; } inline friend FpT operator-(const FpT& x, const FpT& y) { FpT z; sub(z, x, y); return z; } @@ -358,7 +358,7 @@ public: fp::Block xb, yb; x.getBlock(xb); y.getBlock(yb); - return fp::local::compareArray(xb.p, yb.p, xb.n); + return fp::compareArray(xb.p, yb.p, xb.n); } /* wrapper function for generic p diff --git a/include/mcl/fp_base.hpp b/include/mcl/fp_base.hpp index 46f1b21..afd1357 100644 --- a/include/mcl/fp_base.hpp +++ b/include/mcl/fp_base.hpp @@ -139,8 +139,6 @@ T getMontgomeryCoeff(T pLow) return ret; } -namespace local { - inline int compareArray(const Unit* x, const Unit* y, size_t n) { for (size_t i = n - 1; i != size_t(-1); i--) { @@ -186,6 +184,4 @@ inline void toArray(Unit *y, size_t yn, const mpz_srcptr x) clearArray(y, xn, yn); } -} // mcl::fp::local - } } // mcl::fp diff --git a/src/fp.cpp b/src/fp.cpp index 33a5c89..9a58940 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -46,11 +46,11 @@ struct OpeFunc { } static inline void clearC(Unit *x) { - local::clearArray(x, 0, N); + clearArray(x, 0, N); } static inline void copyC(Unit *y, const Unit *x) { - local::copyArray(y, x, N); + copyArray(y, x, N); } static inline void addC(Unit *z, const Unit *x, const Unit *y, const Unit *p) { @@ -64,7 +64,7 @@ struct OpeFunc { if (mpz_cmp(mz, mp) >= 0) { mpz_sub(mz, mz, mp); } - local::toArray(z, N, mz); + toArray(z, N, mz); } static inline void subC(Unit *z, const Unit *x, const Unit *y, const Unit *p) { @@ -79,7 +79,7 @@ struct OpeFunc { set_mpz_t(mp, p); mpz_add(mz, mz, mp); } - local::toArray(z, N, mz); + toArray(z, N, mz); } static inline void mulPreC(Unit *z, const Unit *x, const Unit *y) { @@ -88,7 +88,7 @@ struct OpeFunc { set_mpz_t(mx, x); set_mpz_t(my, y); mpz_mul(mz, mx, my); - local::toArray(z, N * 2, mz); + toArray(z, N * 2, mz); } // x[N * 2] -> y[N] static inline void modC(Unit *y, const Unit *x, const Unit *p) @@ -98,7 +98,7 @@ struct OpeFunc { set_mpz_t(my, y); set_mpz_t(mp, p); mpz_mod(my, mx, mp); - local::clearArray(y, my->_mp_size, N); + clearArray(y, my->_mp_size, N); } static inline void invOp(Unit *y, const Unit *x, const Op& op) { @@ -107,11 +107,11 @@ struct OpeFunc { set_mpz_t(mx, x); set_mpz_t(mp, op.p); mpz_invert(my.get_mpz_t(), mx, mp); - local::toArray(y, N, my.get_mpz_t()); + toArray(y, N, my.get_mpz_t()); } static inline bool isZeroC(const Unit *x) { - return local::isZeroArray(x, N); + return isZeroArray(x, N); } static inline void negC(Unit *y, const Unit *x, const Unit *p) { @@ -159,7 +159,7 @@ inline void invOpForMont(Unit *y, const Unit *x, const Op& op) } static void fromRawGmp(Unit *y, size_t n, const mpz_class& x) { - local::toArray(y, n, x.get_mpz_t()); + toArray(y, n, x.get_mpz_t()); } static void initInvTbl(Op& op, size_t N) { diff --git a/test/base_test.cpp b/test/base_test.cpp index 29a177f..3b677f5 100644 --- a/test/base_test.cpp +++ b/test/base_test.cpp @@ -29,7 +29,7 @@ void setMpz(mpz_class& mx, const Unit *x, size_t n) } void getMpz(Unit *x, size_t n, const mpz_class& mx) { - mcl::fp::local::toArray(x, n, mx.get_mpz_t()); + mcl::fp::toArray(x, n, mx.get_mpz_t()); } struct Montgomery { @@ -105,7 +105,7 @@ void put(const char *msg, const Unit *x, size_t n) } void verifyEqual(const Unit *x, const Unit *y, size_t n, const char *file, int line) { - bool ok = mcl::fp::local::isEqualArray(x, y, n); + bool ok = mcl::fp::isEqualArray(x, y, n); CYBOZU_TEST_ASSERT(ok); if (ok) return; printf("%s:%d\n", file, line); @@ -161,7 +161,7 @@ void mulPreC(Unit *z, const Unit *x, const Unit *y, size_t n) set_mpz_t(mx, x, n); set_mpz_t(my, y, n); mpz_mul(mz, mx, my); - mcl::fp::local::toArray(z, n * 2, mz); + mcl::fp::toArray(z, n * 2, mz); #else mpz_class mx, my; setMpz(mx, x, n); @@ -178,7 +178,7 @@ void modC(Unit *y, const Unit *x, const Unit *p, size_t n) set_mpz_t(my, y, n); set_mpz_t(mp, p, n); mpz_mod(my, mx, mp); - mcl::fp::local::clearArray(y, my->_mp_size, n); + mcl::fp::clearArray(y, my->_mp_size, n); } void mul(Unit *z, const Unit *x, const Unit *y, const Unit *p, size_t n) @@ -191,7 +191,7 @@ void mul(Unit *z, const Unit *x, const Unit *y, const Unit *p, size_t n) set_mpz_t(mp, p, n); mpz_mul(mz, mx, my); mpz_mod(mz, mz, mp); - mcl::fp::local::toArray(z, n, mz); + mcl::fp::toArray(z, n, mz); } typedef mcl::fp::void3op void3op;