当前位置: 首页>>代码示例>>C++>>正文


C++ BigUInt::pointer方法代码示例

本文整理汇总了C++中BigUInt::pointer方法的典型用法代码示例。如果您正苦于以下问题:C++ BigUInt::pointer方法的具体用法?C++ BigUInt::pointer怎么用?C++ BigUInt::pointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigUInt的用法示例。


在下文中一共展示了BigUInt::pointer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: invalid_argument

 BigUInt BigUInt::operator /(const BigUInt& operand2) const
 {
     int result_bits = significant_bit_count();
     int operand2_bits = operand2.significant_bit_count();
     if (operand2_bits == 0)
     {
         throw invalid_argument("operand2 must be positive");
     }
     if (operand2_bits > result_bits)
     {
         BigUInt zero(result_bits);
         return zero;
     }
     BigUInt result(result_bits);
     BigUInt remainder(result_bits);
     MemoryPool pool;
     int uint64_count = divide_round_up(result_bits, bits_per_uint64);
     if (uint64_count > operand2.uint64_count())
     {
         BigUInt operand2resized(result_bits);
         operand2resized = operand2;
         divide_uint_uint(value_, operand2resized.pointer(), uint64_count, result.pointer(), remainder.pointer(), pool);
     }
     else
     {
         divide_uint_uint(value_, operand2.pointer(), uint64_count, result.pointer(), remainder.pointer(), pool);
     }
     return result;
 }
开发者ID:0wnrepo,项目名称:sealcrypto,代码行数:29,代码来源:biguint.cpp

示例2: result

 BigUInt BigUInt::operator *(const BigUInt& operand2) const
 {
     int result_bits = significant_bit_count() + operand2.significant_bit_count();
     BigUInt result(result_bits);
     multiply_uint_uint(value_, uint64_count(), operand2.pointer(), operand2.uint64_count(), result.uint64_count(), result.pointer());
     return result;
 }
开发者ID:0wnrepo,项目名称:sealcrypto,代码行数:7,代码来源:biguint.cpp

示例3: multiply_plain

    ChooserPoly ChooserEvaluator::multiply_plain(const ChooserPoly &operand, int plain_max_coeff_count, const BigUInt &plain_max_abs_value)
    {
        if (operand.max_coeff_count_ <= 0 || operand.comp_ == nullptr)
        {
            throw invalid_argument("operand is not correctly initialized");
        }
        if (plain_max_coeff_count <= 0)
        {
            throw invalid_argument("plain_max_coeff_count must be positive");
        }
        if (plain_max_abs_value.is_zero())
        {
            return ChooserPoly(1, 0, new MultiplyPlainComputation(*operand.comp_, plain_max_coeff_count, plain_max_abs_value));
        }
        if (operand.max_abs_value_.is_zero())
        {
            return ChooserPoly(1, 0, new MultiplyPlainComputation(*operand.comp_, plain_max_coeff_count, plain_max_abs_value));
        }

        uint64_t growth_factor = min(operand.max_coeff_count_, plain_max_coeff_count);
        int prod_bit_count = operand.max_abs_value_.significant_bit_count() + plain_max_abs_value.significant_bit_count() + get_significant_bit_count(growth_factor) + 1;
        int prod_uint64_count = divide_round_up(prod_bit_count, bits_per_uint64);

        Pointer prod_max_abs_value(allocate_zero_uint(prod_uint64_count, pool_));
        ConstPointer wide_operand_max_abs_value(duplicate_uint_if_needed(operand.max_abs_value_.pointer(), operand.max_abs_value_.uint64_count(), prod_uint64_count, false, pool_));

        multiply_uint_uint(&growth_factor, 1, plain_max_abs_value.pointer(), plain_max_abs_value.uint64_count(), prod_uint64_count, prod_max_abs_value.get());
        ConstPointer temp_pointer(duplicate_uint_if_needed(prod_max_abs_value.get(), prod_uint64_count, prod_uint64_count, true, pool_));
        multiply_uint_uint(wide_operand_max_abs_value.get(), prod_uint64_count, temp_pointer.get(), prod_uint64_count, prod_uint64_count, prod_max_abs_value.get());

        return ChooserPoly(operand.max_coeff_count_ + plain_max_coeff_count - 1, BigUInt(prod_bit_count, prod_max_abs_value.get()), new MultiplyPlainComputation(*operand.comp_, plain_max_coeff_count, plain_max_abs_value));
    }
开发者ID:privategenocomputation,项目名称:privategenocomputation,代码行数:32,代码来源:chooser.cpp


注:本文中的BigUInt::pointer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。