LMMP 4.3.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
divexact.h 文件参考
#include "lmmp/lmmpn.h"
divexact.h 的引用(Include)关系图:
此图展示该文件被哪些文件直接或间接地引用了:

浏览该文件的源代码.

函数

void lmmp_divexact_by15_ (mp_ptr dst, mp_srcptr numa, mp_size_t na)
 精确除以15([dst,na] = [numa,na] / 15)
void lmmp_divexact_by3_ (mp_ptr dst, mp_srcptr numa, mp_size_t na)
 Copyright (C) 2026 HJimmyK (Jericho Knox)
void lmmp_divexact_by9_ (mp_ptr dst, mp_srcptr numa, mp_size_t na)
 精确除以9([dst,na] = [numa,na] / 9)
mp_limb_t lmmp_divexact_odd_pi_ (mp_ptr dst, mp_srcptr numa, mp_size_t na, mp_limb_t d, mp_limb_t di, unsigned shr)
 通用奇除数精确除,可带 2^shr 因子: [dst,na] = [numa,na] / (d*2^shr),其中 d 为奇数、di = d^(-1) mod B

函数说明

◆ lmmp_divexact_by15_()

void lmmp_divexact_by15_ ( mp_ptr dst,
mp_srcptr numa,
mp_size_t na )

精确除以15([dst,na] = [numa,na] / 15)

参数
dst结果存储位置
numa被除数
na被除数长度
警告
eqsep(dst,numa), na>0, dst!=NULL, numa!=NULL

在文件 divexact_by.c 第 66 行定义.

66 {
67 mp_limb_t c = 0;
68 mp_limb_t l, q, s, t, carry;
69 mp_size_t i = 0;
70 do {
71 s = numa[i];
72 l = s - c;
73 c = l > s;
74 q = l * MODLIMB_INVERSE_15;
75 dst[i] = q;
76 // carry from 15*q = (q<<4) - q
77 t = q << 4;
78 carry = (q >> (LIMB_BITS - 4)) - (t < q);
79 c += carry;
80 } while (++i < na);
81}
#define MODLIMB_INVERSE_15
uint64_t mp_size_t
定义 lmmp.h:93
uint64_t mp_limb_t
定义 lmmp.h:92
#define LIMB_BITS
定义 lmmp.h:102
#define t
#define s

引用了 LIMB_BITS, lmmp_divexact_by15_(), MODLIMB_INVERSE_15, s , 以及 t.

被这些函数引用 lmmp_divexact_by15_() , 以及 lmmp_toom_interp7_().

函数调用图:
这是这个函数的调用关系图:

◆ lmmp_divexact_by3_()

void lmmp_divexact_by3_ ( mp_ptr dst,
mp_srcptr numa,
mp_size_t na )

Copyright (C) 2026 HJimmyK (Jericho Knox)

This file is part of LMMP.

LMMP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see https://www.gnu.org/licenses/.

SPDX-License-Identifier: LGPL-3.0-or-later

精确除以3([dst,na] = [numa,na] / 3)

参数
dst结果存储位置
numa被除数
na被除数长度
警告
eqsep(dst,numa), na>0, dst!=NULL, numa!=NULL

在文件 divexact_by.c 第 28 行定义.

28 {
29 mp_limb_t c = 0;
30 mp_limb_t l, q, s;
31 mp_size_t i = 0;
32 do {
33 s = numa[i];
34 l = s - c;
35 c = l > s;
36 q = l * MODLIMB_INVERSE_3;
37 dst[i] = q;
38 l = q + q;
39 c += l < q;
40 l += q;
41 c += l < q;
42 } while (++i < na);
43}
#define MODLIMB_INVERSE_3
Copyright (C) 2026 HJimmyK (Jericho Knox)

引用了 lmmp_divexact_by3_(), MODLIMB_INVERSE_3 , 以及 s.

被这些函数引用 lmmp_divexact_by3_(), lmmp_toom_interp5_(), lmmp_toom_interp6_() , 以及 lmmp_toom_interp7_().

函数调用图:
这是这个函数的调用关系图:

◆ lmmp_divexact_by9_()

void lmmp_divexact_by9_ ( mp_ptr dst,
mp_srcptr numa,
mp_size_t na )

精确除以9([dst,na] = [numa,na] / 9)

参数
dst结果存储位置
numa被除数
na被除数长度
警告
eqsep(dst,numa), na>0, dst!=NULL, numa!=NULL

在文件 divexact_by.c 第 47 行定义.

47 {
48 mp_limb_t c = 0;
49 mp_limb_t l, q, s, t, carry;
50 mp_size_t i = 0;
51 do {
52 s = numa[i];
53 l = s - c;
54 c = l > s;
55 q = l * MODLIMB_INVERSE_9;
56 dst[i] = q;
57 // carry from 9*q = (q<<3) + q
58 t = q << 3;
59 carry = (q >> (LIMB_BITS - 3)) + ((t + q) < t);
60 c += carry;
61 } while (++i < na);
62}
#define MODLIMB_INVERSE_9

引用了 LIMB_BITS, lmmp_divexact_by9_(), MODLIMB_INVERSE_9, s , 以及 t.

被这些函数引用 lmmp_divexact_by9_() , 以及 lmmp_toom_interp7_().

函数调用图:
这是这个函数的调用关系图:

◆ lmmp_divexact_odd_pi_()

mp_limb_t lmmp_divexact_odd_pi_ ( mp_ptr dst,
mp_srcptr numa,
mp_size_t na,
mp_limb_t d,
mp_limb_t di,
unsigned shr )

通用奇除数精确除,可带 2^shr 因子: [dst,na] = [numa,na] / (d*2^shr),其中 d 为奇数、di = d^(-1) mod B

Copyright (C) 2026 HJimmyK (Jericho Knox)

参数
dst结果存储位置
numa被除数
na被除数长度
d奇除数(单 limb)
did 模 B 的乘法逆元
shr2 的幂因子指数(0 <= shr < LIMB_BITS)
返回
残差(精确除时为 0)
警告
eqsep(dst,numa), na>0, d 为奇数, d*di == 1 (mod B)
注解
2^shr 因子按"被除数位流右移 shr 位后除奇部 d"处理,结果仅在 低 64*na-shr 位上有定义(顶部 shr 位不定)

通用奇除数精确除,可带 2^shr 因子: [dst,na] = [numa,na] / (d*2^shr),其中 d 为奇数、di = d^(-1) mod B

This file is part of LMMP.

LMMP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see https://www.gnu.org/licenses/.

SPDX-License-Identifier: LGPL-3.0-or-later

在文件 divexact_odd.c 第 27 行定义.

27 {
28 mp_limb_t c, l, u, un, lo;
29 mp_size_t i;
30
31 lmmp_param_assert(na > 0);
32 lmmp_param_assert((d & 1) != 0);
34 lmmp_param_assert(d * di == 1);
35
36 if (shr != 0) {
37 c = 0;
38 u = numa[0];
39 for (i = 1; i < na; i++) {
40 un = numa[i];
41 u = (u >> shr) | (un << (LIMB_BITS - shr));
42 l = u - c;
43 c = l > u;
44 l *= di;
45 dst[i - 1] = l;
46 u = un;
47 _umul64to128_(l, d, &lo, &un);
48 c += un;
49 }
50 u >>= shr;
51 l = u - c;
52 c = l > u;
53 l *= di;
54 dst[na - 1] = l;
55 } else {
56 c = 0;
57 i = 0;
58 do {
59 u = numa[i];
60 l = u - c;
61 c = l > u;
62 l *= di;
63 dst[i] = l;
64 _umul64to128_(l, d, &lo, &un);
65 c += un;
66 } while (++i < na);
67 }
68 return c;
69}
#define lmmp_param_assert(x)
定义 lmmp.h:509
static void _umul64to128_(uint64_t a, uint64_t b, uint64_t *low, uint64_t *high)
#define lo

引用了 _umul64to128_(), LIMB_BITS, lmmp_divexact_odd_pi_(), lmmp_param_assert , 以及 lo.

被这些函数引用 lmmp_divexact_odd_pi_(), lmmp_toom_interp12_() , 以及 lmmp_toom_interp16_().

函数调用图:
这是这个函数的调用关系图: