fused.cpp

来自「含有多种公开密钥算法、多种块加密、多种数据流加密、多种HASH函数、多种Chec」· C++ 代码 · 共 54 行

CPP
54
字号
/************************************************** Fused Arithmetic Operations Source File        ** (C) 1999-2002 The Botan Project                **************************************************/#include <botan/numthry.h>#include <botan/mp_core.h>#include <iostream>#include <iomanip>namespace Botan {/************************************************** Fused Multiply/Add Operation                   **************************************************/BigInt mul_add(const BigInt& a, const BigInt& b, const BigInt& c)   {   if(c.is_negative())      throw Invalid_Argument("mul_add: Third argument must be positive");   Sign sign = Positive;   if(a.sign() != b.sign())      sign = Negative;   const u32bit a_sw = a.sig_words();   const u32bit b_sw = b.sig_words();   const u32bit c_sw = c.sig_words();   BigInt z(sign, std::max(a.size() + b.size(), c_sw) + 1);   bigint_mul3(z.get_reg(), z.size(),               a.data(), a.size(), a_sw,               b.data(), b.size(), b_sw);   const u32bit z_size = std::max(z.sig_words(), c_sw);   bigint_add2(z.get_reg(), z_size, c.data(), c_sw);   return z;   }/************************************************** Fused Subtract/Multiply Operation              **************************************************/BigInt sub_mul(const BigInt& a, const BigInt& b, const BigInt& c)   {   if(a.is_negative() || b.is_negative())      throw Invalid_Argument("sub_mul: First two arguments must be positive");   BigInt x = a;   x -= b;   x *= c;   return x;   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?