61 for (
k = 0; eb > x[
k++];);
65#define getbit(p, bi) ((p[(bi - 1) / LIMB_BITS] >> (bi - 1) % LIMB_BITS) & 1)
80 if (nbits_in_r < nbits)
81 r += p[i + 1] << nbits_in_r;
103 unsigned windowsize, this_windowsize;
122 if (windowsize > 1) {
136 i = (1 << (windowsize - 1)) - 1;
143 expbits =
getbits(ep, ebi, windowsize);
160 while (
getbit(ep, ebi) == 0) {
163 flipflop = !flipflop;
171 expbits =
getbits(ep, ebi, windowsize);
172 this_windowsize =
LMMP_MIN(windowsize, ebi);
175 this_windowsize -= cnt;
176 ebi -= this_windowsize;
178 while (this_windowsize > 1) {
181 this_windowsize -= 2;
184 if (this_windowsize != 0)
188 flipflop = !flipflop;
220 unsigned windowsize =
win_size(ebi);
223 unsigned this_windowsize;
229 if (windowsize > 1) {
232 pp[i] = pp[i - 1] *
b2;
234 expbits =
getbits(ep, ebi, windowsize);
240 u = pp[expbits >> 1];
246 while (
getbit(ep, ebi) == 0) {
255 expbits =
getbits(ep, ebi, windowsize);
256 this_windowsize =
LMMP_MIN(windowsize, ebi);
259 this_windowsize -= cnt;
260 ebi -= this_windowsize;
262 while (this_windowsize > 1) {
265 this_windowsize -= 2;
268 if (this_windowsize != 0)
270 u *= pp[expbits >> 1];
281 u128 u = _u128load(bp);
290 unsigned windowsize =
win_size(ebi);
293 unsigned this_windowsize;
299 if (windowsize > 1) {
300 u128
b2 =
_umul128to128_(_u128high(u), _u128low(u), _u128high(u), _u128low(u));
302 pp[i] =
_umul128to128_(_u128high(pp[i - 1]), _u128low(pp[i - 1]), _u128high(
b2), _u128low(
b2));
304 expbits =
getbits(ep, ebi, windowsize);
310 u = pp[expbits >> 1];
316 while (
getbit(ep, ebi) == 0) {
317 u =
_umul128to128_(_u128high(u), _u128low(u), _u128high(u), _u128low(u));
325 expbits =
getbits(ep, ebi, windowsize);
326 this_windowsize =
LMMP_MIN(windowsize, ebi);
329 this_windowsize -= cnt;
330 ebi -= this_windowsize;
332 while (this_windowsize > 1) {
333 u =
_umul128to128_(_u128high(u), _u128low(u), _u128high(u), _u128low(u));
334 u =
_umul128to128_(_u128high(u), _u128low(u), _u128high(u), _u128low(u));
335 this_windowsize -= 2;
338 if (this_windowsize != 0)
339 u =
_umul128to128_(_u128high(u), _u128low(u), _u128high(u), _u128low(u));
340 u =
_umul128to128_(_u128high(u), _u128low(u), _u128high(pp[expbits >> 1]), _u128low(pp[expbits >> 1]));
static void lmmp_mullo_n_(mp_ptr restrict dst, mp_srcptr restrict numa, mp_srcptr restrict numb, mp_size_t n, mp_ptr restrict tp)
#define LMMP_SWAP(x, y, type)
交换两个变量的值
#define lmmp_copy(dst, src, n)
#define lmmp_debug_assert(x)
const mp_limb_t * mp_srcptr
#define LMMP_MIN(l, o)
返回两个数中的较小值
#define lmmp_param_assert(x)
#define MULLO_DC_THRESHOLD
void lmmp_mullo_dc_(mp_ptr dst, mp_srcptr numa, mp_srcptr numb, mp_ptr tp, mp_size_t n)
低位乘法 [dst,n] = [numa,n] * [numb,n] mod B^n
void lmmp_sqrlo_dc_(mp_ptr dst, mp_srcptr numa, mp_ptr tp, mp_size_t n)
低位平方 [dst,n] = [numa,n]^2 mod B^n
void lmmp_mullo_fft_(mp_ptr dst, mp_srcptr numa, mp_srcptr numb, mp_size_t n, mp_ptr scratch)
低位FFT乘法 [dst,n] = [numa,n] * [numb,n] mod B^n
#define ctz_shr_u64(r, x, cnt)
Copyright (C) 2026 HJimmyK (Jericho Knox)
static __uint128_t _umul128to128_(uint64_t a_high, uint64_t a_low, uint64_t b_high, uint64_t b_low)
void lmmp_powlo_(mp_ptr dst, mp_srcptr bp, mp_size_t n, mp_srcptr ep, mp_size_t en)
计算 [bp,n]^[ep,en] mod B^n,并将结果写入 [dst,n]
void lmmp_powlo_2_(mp_ptr dst, mp_srcptr bp, mp_srcptr ep, mp_size_t en)
计算 [bp,2]^[ep,en] mod B^2,并将结果写入 [dst,2](lmmp_powlo_ 的 2 limb 特化)
void lmmp_powlo_1_(mp_ptr dst, mp_srcptr bp, mp_srcptr ep, mp_size_t en)
计算 [bp,1]^[ep,en] mod B,并将结果写入 [dst,1](lmmp_powlo_ 的 1 limb 特化)
static mp_size_t win_size(mp_size_t eb)
static mp_bitcnt_t count_bits(mp_srcptr p, mp_size_t n)
static mp_limb_t getbits(const mp_limb_t *p, mp_bitcnt_t bi, mp_bitcnt_t nbits)
static void lmmp_sqrlo_n_(mp_ptr restrict dst, mp_srcptr restrict numa, mp_size_t n, mp_ptr restrict tp)
Copyright (C) 2026 HJimmyK (Jericho Knox)
#define restrict
Copyright (C) 2026 HJimmyK (Jericho Knox)
#define TALLOC_TYPE(n, type)