From 7b2d72d4b504bc1ee011526c23492bd0417e4644 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 25 Apr 2016 15:15:09 +0900 Subject: [PATCH] rename Fp::Dbl to FpDbl --- include/mcl/fp.hpp | 3 +-- include/mcl/fp_tower.hpp | 25 ++++++++++++------------- test/fp_tower_test.cpp | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index 3f913aa..ce33248 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -60,11 +60,10 @@ class FpT : public fp::Operator > { static fp::Op op_; template friend class FpT; Unit v_[maxSize]; +public: template friend class FpDblT; template friend class Fp2T; template friend struct Fp6T; -public: - class Dbl; // return pointer to array v_[] const Unit *getUnit() const { return v_; } static inline size_t getUnitSize() { return op_.N; } diff --git a/include/mcl/fp_tower.hpp b/include/mcl/fp_tower.hpp index 29aa978..5bf1417 100644 --- a/include/mcl/fp_tower.hpp +++ b/include/mcl/fp_tower.hpp @@ -10,10 +10,9 @@ namespace mcl { -template -class FpT::Dbl { +template +class FpDblT { typedef fp::Unit Unit; - typedef FpT Fp; Unit v_[Fp::maxSize * 2]; public: static inline size_t getUnitSize() { return Fp::op_.N * 2; } @@ -28,11 +27,11 @@ public: // QQQ : does not check range of x strictly(use for debug) void setMpz(const mpz_class& x) { - if (x < 0) throw cybozu::Exception("Dbl:_setMpz:negative is not supported") << x; + if (x < 0) throw cybozu::Exception("FpDblT:_setMpz:negative is not supported") << x; const size_t xn = gmp::getUnitSize(x); const size_t N2 = getUnitSize(); if (xn > N2) { - throw cybozu::Exception("Dbl:setMpz:too large") << x; + throw cybozu::Exception("FpDblT:setMpz:too large") << x; } memcpy(v_, gmp::getUnit(x), xn * sizeof(Unit)); memset(v_ + xn, 0, (N2 - xn) * sizeof(Unit)); @@ -41,16 +40,16 @@ public: { gmp::setArray(x, v_, Fp::op_.N * 2); } - static inline void add(Dbl& z, const Dbl& x, const Dbl& y) { Fp::op_.fpDbl_add(z.v_, x.v_, y.v_); } - static inline void sub(Dbl& z, const Dbl& x, const Dbl& y) { Fp::op_.fpDbl_sub(z.v_, x.v_, y.v_); } - static inline void addNC(Dbl& z, const Dbl& x, const Dbl& y) { Fp::op_.fpDbl_addNC(z.v_, x.v_, y.v_); } - static inline void subNC(Dbl& z, const Dbl& x, const Dbl& y) { Fp::op_.fpDbl_subNC(z.v_, x.v_, y.v_); } + static inline void add(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_add(z.v_, x.v_, y.v_); } + static inline void sub(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_sub(z.v_, x.v_, y.v_); } + static inline void addNC(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_addNC(z.v_, x.v_, y.v_); } + static inline void subNC(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_subNC(z.v_, x.v_, y.v_); } /* mul(z, x, y) = mulPre(xy, x, y) + mod(z, xy) */ - static inline void mulPre(Dbl& xy, const Fp& x, const Fp& y) { Fp::op_.fpDbl_mulPre(xy.v_, x.v_, y.v_); } - static inline void sqrPre(Dbl& xx, const Fp& x) { Fp::op_.fpDbl_sqrPre(xx.v_, x.v_); } - static inline void mod(Fp& z, const Dbl& xy) { Fp::op_.fpDbl_mod(z.v_, xy.v_); } + static inline void mulPre(FpDblT& xy, const Fp& x, const Fp& y) { Fp::op_.fpDbl_mulPre(xy.v_, x.v_, y.v_); } + static inline void sqrPre(FpDblT& xx, const Fp& x) { Fp::op_.fpDbl_sqrPre(xx.v_, x.v_); } + static inline void mod(Fp& z, const FpDblT& xy) { Fp::op_.fpDbl_mod(z.v_, xy.v_); } }; /* @@ -61,7 +60,7 @@ public: template class Fp2T : public fp::Operator > { typedef fp::Unit Unit; - typedef typename Fp::Dbl FpDbl; + typedef FpDblT FpDbl; static Fp xi_a_; public: Fp a, b; diff --git a/test/fp_tower_test.cpp b/test/fp_tower_test.cpp index aa60f5a..8ad6e9e 100644 --- a/test/fp_tower_test.cpp +++ b/test/fp_tower_test.cpp @@ -9,7 +9,7 @@ typedef mcl::FpT Fp; typedef mcl::Fp2T Fp2; -typedef Fp::Dbl FpDbl; +typedef mcl::FpDblT FpDbl; typedef mcl::Fp6T Fp6; typedef mcl::Fp12T Fp12;