diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index 44aab76..9fd6d74 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -120,10 +120,10 @@ public: } printf("\n"); } - static inline void init(bool *pb, const mpz_class& _p, fp::Mode mode = fp::FP_AUTO) + static inline void init(bool *pb, const mpz_class& _p, fp::Mode mode = fp::FP_AUTO, int xi_a = 0) { assert(maxBitSize <= MCL_MAX_BIT_SIZE); - *pb = op_.init(_p, maxBitSize, mode); + *pb = op_.init(_p, maxBitSize, xi_a, mode); if (!*pb) return; { // set oneRep FpT& one = *reinterpret_cast(op_.oneRep); @@ -151,12 +151,12 @@ public: #endif *pb = true; } - static inline void init(bool *pb, const char *mstr, fp::Mode mode = fp::FP_AUTO) + static inline void init(bool *pb, const char *mstr, fp::Mode mode = fp::FP_AUTO, int xi_a = 0) { mpz_class p; gmp::setStr(pb, p, mstr); if (!*pb) return; - init(pb, p, mode); + init(pb, p, mode, xi_a); } static inline size_t getModulo(char *buf, size_t bufSize) { diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp index afbc8a4..a3b482f 100644 --- a/include/mcl/op.hpp +++ b/include/mcl/op.hpp @@ -341,8 +341,7 @@ struct Op { */ fp_mul(y, x, R2, p); } - bool init(const mpz_class& p, size_t maxBitSize, Mode mode, size_t mclMaxBitSize = MCL_MAX_BIT_SIZE); - void initFp2(int xi_a); + bool init(const mpz_class& p, size_t maxBitSize, int xi_a, Mode mode, size_t mclMaxBitSize = MCL_MAX_BIT_SIZE); #ifdef MCL_USE_XBYAK static FpGenerator* createFpGenerator(); static void destroyFpGenerator(FpGenerator *fg); diff --git a/src/fp.cpp b/src/fp.cpp index 473b26c..907d76d 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -362,7 +362,7 @@ static bool initForMont(Op& op, const Unit *p, Mode mode) return true; } -bool Op::init(const mpz_class& _p, size_t maxBitSize, Mode mode, size_t mclMaxBitSize) +bool Op::init(const mpz_class& _p, size_t maxBitSize, int xi_a, Mode mode, size_t mclMaxBitSize) { if (mclMaxBitSize != MCL_MAX_BIT_SIZE) return false; #ifdef MCL_USE_VINT @@ -384,6 +384,7 @@ bool Op::init(const mpz_class& _p, size_t maxBitSize, Mode mode, size_t mclMaxBi mp = _p; bitSize = gmp::getBitSize(mp); pmod4 = gmp::getUnit(mp, 0) % 4; + this->xi_a = xi_a; /* priority : MCL_USE_XBYAK > MCL_USE_LLVM > none Xbyak > llvm_mont > llvm > gmp_mont > gmp @@ -653,10 +654,5 @@ int64_t getInt64(bool *pb, fp::Block& b, const fp::Op& op) #pragma warning(pop) #endif -void Op::initFp2(int _xi_a) -{ - this->xi_a = _xi_a; -} - } } // mcl::fp