|
|
@ -752,7 +752,7 @@ public: |
|
|
|
typedef _Buffer Buffer; |
|
|
|
typedef _Buffer Buffer; |
|
|
|
typedef typename Buffer::Unit Unit; |
|
|
|
typedef typename Buffer::Unit Unit; |
|
|
|
static const size_t unitBitSize = sizeof(Unit) * 8; |
|
|
|
static const size_t unitBitSize = sizeof(Unit) * 8; |
|
|
|
static const int invalidVar = -2147483648; // abs(invalidVar) is not defined
|
|
|
|
static const int invalidVar = -2147483647 - 1; // abs(invalidVar) is not defined
|
|
|
|
private: |
|
|
|
private: |
|
|
|
Buffer buf_; |
|
|
|
Buffer buf_; |
|
|
|
size_t size_; |
|
|
|
size_t size_; |
|
|
@ -796,6 +796,7 @@ private: |
|
|
|
size_t zn = xn; |
|
|
|
size_t zn = xn; |
|
|
|
z.buf_.alloc(zn); |
|
|
|
z.buf_.alloc(zn); |
|
|
|
Unit c = local::sub1(&z.buf_[0], &x[0], xn, y); |
|
|
|
Unit c = local::sub1(&z.buf_[0], &x[0], xn, y); |
|
|
|
|
|
|
|
(void)c; |
|
|
|
assert(!c); |
|
|
|
assert(!c); |
|
|
|
z.trim(zn); |
|
|
|
z.trim(zn); |
|
|
|
} |
|
|
|
} |
|
|
@ -891,6 +892,12 @@ public: |
|
|
|
{ |
|
|
|
{ |
|
|
|
setStr(str); |
|
|
|
setStr(str); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
VintT(const VintT& rhs) |
|
|
|
|
|
|
|
: buf_(rhs.buf_) |
|
|
|
|
|
|
|
, size_(rhs.size_) |
|
|
|
|
|
|
|
, isNeg_(rhs.isNeg_) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
VintT& operator=(int x) |
|
|
|
VintT& operator=(int x) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (x == invalidVar) throw cybozu::Exception("VintT:operator=:invalidVar"); |
|
|
|
if (x == invalidVar) throw cybozu::Exception("VintT:operator=:invalidVar"); |
|
|
@ -900,18 +907,25 @@ public: |
|
|
|
size_ = 1; |
|
|
|
size_ = 1; |
|
|
|
return *this; |
|
|
|
return *this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
VintT& operator=(const VintT& rhs) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
buf_ = rhs.buf_; |
|
|
|
|
|
|
|
size_ = rhs.size_; |
|
|
|
|
|
|
|
isNeg_ = rhs.isNeg_; |
|
|
|
|
|
|
|
return *this; |
|
|
|
|
|
|
|
} |
|
|
|
#if CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11 |
|
|
|
#if CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11 |
|
|
|
VintT(VintT&& rhs) |
|
|
|
VintT(VintT&& rhs) |
|
|
|
: buf_(rhs.buf_) |
|
|
|
: buf_(rhs.buf_) |
|
|
|
, size_(rhs.size_) |
|
|
|
, size_(rhs.size_) |
|
|
|
, neg_(rhs.neg_) |
|
|
|
, isNeg_(rhs.isNeg_) |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
VintT& operator=(VintT&& rhs) |
|
|
|
VintT& operator=(VintT&& rhs) |
|
|
|
{ |
|
|
|
{ |
|
|
|
buf_ = std::move(rhs.buf_); |
|
|
|
buf_ = std::move(rhs.buf_); |
|
|
|
size_ = rhs.size_; |
|
|
|
size_ = rhs.size_; |
|
|
|
neg_ = rhs.neg_; |
|
|
|
isNeg_ = rhs.isNeg_; |
|
|
|
return *this; |
|
|
|
return *this; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -1313,9 +1327,8 @@ public: |
|
|
|
if (x.size() < y.size()) { |
|
|
|
if (x.size() < y.size()) { |
|
|
|
std::swap(px, py); |
|
|
|
std::swap(px, py); |
|
|
|
} |
|
|
|
} |
|
|
|
size_t xn CYBOZU_UNUSED = px->size(); |
|
|
|
|
|
|
|
size_t yn = py->size(); |
|
|
|
size_t yn = py->size(); |
|
|
|
assert(xn >= yn); |
|
|
|
assert(px->size() >= yn); |
|
|
|
z.buf_.alloc(yn); |
|
|
|
z.buf_.alloc(yn); |
|
|
|
for (size_t i = 0; i < yn; i++) { |
|
|
|
for (size_t i = 0; i < yn; i++) { |
|
|
|
z.buf_[i] = x.buf_[i] & y.buf_[i]; |
|
|
|
z.buf_[i] = x.buf_[i] & y.buf_[i]; |
|
|
@ -1428,7 +1441,7 @@ public: |
|
|
|
if (x == 1 || x == nm1) { |
|
|
|
if (x == 1 || x == nm1) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
for (uint32_t i = 1; i < r; i++) { |
|
|
|
for (uint32_t j = 1; j < r; j++) { |
|
|
|
sqr(x, x); |
|
|
|
sqr(x, x); |
|
|
|
x %= n; |
|
|
|
x %= n; |
|
|
|
if (x == 1) return false; |
|
|
|
if (x == 1) return false; |
|
|
|