rename fullBit to isFullBit

dev
MITSUNARI Shigeo 9 years ago
parent 9df4ddc1cd
commit 95a40bb298
  1. 1
      include/mcl/fp.hpp
  2. 8
      include/mcl/op.hpp
  3. 8
      src/fp.cpp

@ -133,6 +133,7 @@ public:
{ {
Gmp::getStr(pstr, op_.mp); Gmp::getStr(pstr, op_.mp);
} }
static inline bool isFullBit() { return op_.isFullBit; }
/* /*
binary patter of p binary patter of p
@note the value of p is zero @note the value of p is zero

@ -80,11 +80,11 @@ struct Op {
void3u fp_sub; void3u fp_sub;
void3u fp_mul; void3u fp_mul;
bool fullBit; // true if bitSize % uniSize == 0 bool isFullBit; // true if bitSize % uniSize == 0
/* /*
same fp_add, fp_sub if fullBit same fp_add, fp_sub if isFullBit
*/ */
void3u fp_addNC; // assume no carry if !fullBit void3u fp_addNC; // assume no carry if !isFullBit
void3u fp_subNC; // assume x > y void3u fp_subNC; // assume x > y
// for Montgomery // for Montgomery
bool useMont; bool useMont;
@ -129,7 +129,7 @@ struct Op {
: N(0), bitSize(0) : N(0), bitSize(0)
, fp_isZero(0), fp_clear(0), fp_copy(0) , fp_isZero(0), fp_clear(0), fp_copy(0)
, fp_neg(0), fp_sqr(0), fp_add(0), fp_sub(0), fp_mul(0) , fp_neg(0), fp_sqr(0), fp_add(0), fp_sub(0), fp_mul(0)
, fullBit(true), fp_addNC(0), fp_subNC(0) , isFullBit(true), fp_addNC(0), fp_subNC(0)
, useMont(false), fp_preInv(0) , useMont(false), fp_preInv(0)
, rp(0), mont(0) , rp(0), mont(0)
, fp_negP(0), fp_sqrPreP(0), fp_invOp(0), fp_addP(0), fp_subP(0), fp_mulPreP(0), fp_modP(0) , fp_negP(0), fp_sqrPreP(0), fp_invOp(0), fp_addP(0), fp_subP(0), fp_mulPreP(0), fp_modP(0)

@ -254,7 +254,7 @@ struct OpeFunc {
if (mode == FP_LLVM || mode == FP_LLVM_MONT) { \ if (mode == FP_LLVM || mode == FP_LLVM_MONT) { \
fp_addP = mcl_fp_add ## n ##S; \ fp_addP = mcl_fp_add ## n ##S; \
fp_subP = mcl_fp_sub ## n ##S; \ fp_subP = mcl_fp_sub ## n ##S; \
if (!fullBit) { \ if (!isFullBit) { \
fp_addNC = mcl_fp_addNC ## n; \ fp_addNC = mcl_fp_addNC ## n; \
fp_subNC = mcl_fp_subNC ## n; \ fp_subNC = mcl_fp_subNC ## n; \
} \ } \
@ -269,7 +269,7 @@ struct OpeFunc {
if (n <= 256) { \ if (n <= 256) { \
fpDbl_addP = mcl_fpDbl_add ## n; \ fpDbl_addP = mcl_fpDbl_add ## n; \
fpDbl_subP = mcl_fpDbl_sub ## n; \ fpDbl_subP = mcl_fpDbl_sub ## n; \
if (!fullBit) { \ if (!isFullBit) { \
fpDbl_addNC = mcl_fp_addNC ## n2; \ fpDbl_addNC = mcl_fp_addNC ## n2; \
fpDbl_subNC = mcl_fp_subNC ## n2; \ fpDbl_subNC = mcl_fp_subNC ## n2; \
} \ } \
@ -297,7 +297,7 @@ struct OpeFunc {
fpDbl_addP = OpeFunc<n>::fpDbl_addPC; \ fpDbl_addP = OpeFunc<n>::fpDbl_addPC; \
fpDbl_subP = OpeFunc<n>::fpDbl_subPC; \ fpDbl_subP = OpeFunc<n>::fpDbl_subPC; \
} \ } \
if (fullBit) { \ if (isFullBit) { \
fp_addNC = fp_add; \ fp_addNC = fp_add; \
fp_subNC = fp_sub; \ fp_subNC = fp_sub; \
fpDbl_addNC = fpDbl_add; \ fpDbl_addNC = fpDbl_add; \
@ -386,7 +386,7 @@ void Op::init(const std::string& mstr, int base, size_t maxBitSize, Mode mode)
bool isMinus = fp::strToMpzArray(&bitSize, p, maxBitSize, mp, mstr, base); bool isMinus = fp::strToMpzArray(&bitSize, p, maxBitSize, mp, mstr, base);
if (isMinus) throw cybozu::Exception("Op:init:mstr is minus") << mstr; if (isMinus) throw cybozu::Exception("Op:init:mstr is minus") << mstr;
if (mp == 0) throw cybozu::Exception("Op:init:mstr is zero") << mstr; if (mp == 0) throw cybozu::Exception("Op:init:mstr is zero") << mstr;
fullBit = (bitSize % UnitBitSize) == 0; isFullBit = (bitSize % UnitBitSize) == 0;
const size_t roundBit = (bitSize + UnitBitSize - 1) & ~(UnitBitSize - 1); const size_t roundBit = (bitSize + UnitBitSize - 1) & ~(UnitBitSize - 1);
switch (roundBit) { switch (roundBit) {

Loading…
Cancel
Save