set xi_a in Fp::init

dev
MITSUNARI Shigeo 6 years ago
parent 951f57111c
commit b087e6f1f4
  1. 8
      include/mcl/fp.hpp
  2. 3
      include/mcl/op.hpp
  3. 8
      src/fp.cpp

@ -120,10 +120,10 @@ public:
} }
printf("\n"); 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); assert(maxBitSize <= MCL_MAX_BIT_SIZE);
*pb = op_.init(_p, maxBitSize, mode); *pb = op_.init(_p, maxBitSize, xi_a, mode);
if (!*pb) return; if (!*pb) return;
{ // set oneRep { // set oneRep
FpT& one = *reinterpret_cast<FpT*>(op_.oneRep); FpT& one = *reinterpret_cast<FpT*>(op_.oneRep);
@ -151,12 +151,12 @@ public:
#endif #endif
*pb = true; *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; mpz_class p;
gmp::setStr(pb, p, mstr); gmp::setStr(pb, p, mstr);
if (!*pb) return; if (!*pb) return;
init(pb, p, mode); init(pb, p, mode, xi_a);
} }
static inline size_t getModulo(char *buf, size_t bufSize) static inline size_t getModulo(char *buf, size_t bufSize)
{ {

@ -341,8 +341,7 @@ struct Op {
*/ */
fp_mul(y, x, R2, p); fp_mul(y, x, R2, p);
} }
bool init(const mpz_class& p, size_t maxBitSize, Mode mode, size_t mclMaxBitSize = MCL_MAX_BIT_SIZE); bool init(const mpz_class& p, size_t maxBitSize, int xi_a, Mode mode, size_t mclMaxBitSize = MCL_MAX_BIT_SIZE);
void initFp2(int xi_a);
#ifdef MCL_USE_XBYAK #ifdef MCL_USE_XBYAK
static FpGenerator* createFpGenerator(); static FpGenerator* createFpGenerator();
static void destroyFpGenerator(FpGenerator *fg); static void destroyFpGenerator(FpGenerator *fg);

@ -362,7 +362,7 @@ static bool initForMont(Op& op, const Unit *p, Mode mode)
return true; 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; if (mclMaxBitSize != MCL_MAX_BIT_SIZE) return false;
#ifdef MCL_USE_VINT #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; mp = _p;
bitSize = gmp::getBitSize(mp); bitSize = gmp::getBitSize(mp);
pmod4 = gmp::getUnit(mp, 0) % 4; pmod4 = gmp::getUnit(mp, 0) % 4;
this->xi_a = xi_a;
/* /*
priority : MCL_USE_XBYAK > MCL_USE_LLVM > none priority : MCL_USE_XBYAK > MCL_USE_LLVM > none
Xbyak > llvm_mont > llvm > gmp_mont > gmp 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) #pragma warning(pop)
#endif #endif
void Op::initFp2(int _xi_a)
{
this->xi_a = _xi_a;
}
} } // mcl::fp } } // mcl::fp

Loading…
Cancel
Save