本文整理汇总了C++中BigUInt::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ BigUInt::resize方法的具体用法?C++ BigUInt::resize怎么用?C++ BigUInt::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigUInt
的用法示例。
在下文中一共展示了BigUInt::resize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
friend BigUInt operator + (const BigUInt &left, const BigUInt &right) {
BigUInt result;
unsigned int i;
if (left.m_data.size() > right.m_data.size()) {
result.resize(left.m_data.size());
for (i=0; i < right.m_data.size(); ++i) {
result.m_data[i] = left.m_data[i] + right.m_data[i];
}
for (; i< left.m_data.size(); ++i) {
result.m_data[i] = left.m_data[i];
}
} else {
result.resize(right.m_data.size());
for (i=0; i < left.m_data.size(); ++i) {
result.m_data[i] = left.m_data[i] + right.m_data[i];
}
for (; i< right.m_data.size(); ++i) {
result.m_data[i] = right.m_data[i];
}
}
result.normalize();
return result;
}
示例2: exponentiate_uint_mod
void exponentiate_uint_mod(const BigUInt &operand, const BigUInt &exponent,
const BigUInt &modulus, BigUInt &destination, const MemoryPoolHandle &pool)
{
if (operand.significant_bit_count() > modulus.significant_bit_count())
{
throw invalid_argument("operand is not reduced");
}
if (operand.is_zero() && exponent == 0)
{
throw invalid_argument("undefined operation");
}
if (!pool)
{
throw invalid_argument("pool is uninitialized");
}
if (operand.is_zero())
{
destination.set_zero();
return;
}
if (destination.bit_count() != modulus.significant_bit_count())
{
destination.resize(modulus.significant_bit_count());
}
ConstPointer operand_ptr = duplicate_uint_if_needed(operand, modulus.uint64_count(), false, pool);
util::exponentiate_uint_mod(operand_ptr.get(), exponent.data(), exponent.uint64_count(), Modulus(modulus.data(), modulus.uint64_count(), pool), destination.data(), pool);
}
示例3: multOffset
static BigUInt multOffset(const BigUInt &left, int value, int offset) {
BigUInt result;
result.resize(offset + left.m_data.size());
for (unsigned int i=0; i < left.m_data.size(); ++i) {
result.m_data[i+offset] = left.m_data[i] * value;
}
result.normalize();
return result;
}
示例4: poly_eval_uint_mod
void poly_eval_uint_mod(const BigPoly &poly_to_evaluate, const BigUInt &value, const BigUInt &modulus,
BigUInt &destination, const MemoryPoolHandle &pool)
{
if (poly_to_evaluate.significant_coeff_bit_count() > modulus.significant_bit_count())
{
throw invalid_argument("poly_to_evaluate is not reduced");
}
if (value.significant_bit_count() > modulus.significant_bit_count())
{
throw invalid_argument("value is not reduced");
}
if (!pool)
{
throw invalid_argument("pool is uninitialized");
}
int poly_to_eval_coeff_uint64_count = poly_to_evaluate.coeff_uint64_count();
int modulus_bit_count = modulus.significant_bit_count();
if (poly_to_evaluate.is_zero())
{
destination.set_zero();
}
if (value.is_zero())
{
destination.resize(modulus_bit_count);
modulo_uint(poly_to_evaluate.data(), poly_to_eval_coeff_uint64_count,
Modulus(modulus.data(), modulus.uint64_count(), pool),
destination.data(), pool);
return;
}
ConstPointer value_ptr = duplicate_uint_if_needed(value, modulus.uint64_count(), false, pool);
destination.resize(modulus_bit_count);
util::poly_eval_uint_mod(poly_to_evaluate.data(), poly_to_evaluate.coeff_count(), value_ptr.get(),
Modulus(modulus.data(), modulus.uint64_count(), pool), destination.data(), pool);
}