|
LMMP 4.3.0
Lamina High-Precision Arithmetic Library
|
#include "lmmp/numth.h"#include "lmmp/lmmpn.h"#include "impl/longlong.h"#include "impl/trialdiv.h"宏定义 | |
| #define | MONT63_MAX ((ulong)(0x7fffffffffffffff)) |
| Copyright (C) 2026 HJimmyK (Jericho Knox) | |
函数 | |
| mp_limb_t | lmmp_mod_4chunk_1_ (mp_srcptr numa, mp_size_t na, mp_limb_t d, mp_limb_t dinv, mp_limb_t r2, mp_limb_t base, mp_limb_t mi) |
| 4 链折叠取模:r = [numa,na] mod d | |
| mp_limb_t | lmmp_mod_8chunk_1_ (mp_srcptr numa, mp_size_t na, mp_limb_t d, mp_limb_t dinv, mp_limb_t r2, mp_limb_t base, mp_limb_t mi) |
| 8 链折叠取模:r = [numa,na] mod d | |
| static ulong | mont63_mul (ulong a, ulong b, ulong m, ulong m_inv) |
| 蒙域乘:a*b*R^-1 mod m(R=B) | |
| static ulong | mont63_reduce (u128 t, ulong m, ulong m_inv) |
| 蒙域约化 REDC | |
| #define MONT63_MAX ((ulong)(0x7fffffffffffffff)) |
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
在文件 mod_chunk.c 第 31 行定义.
| mp_limb_t lmmp_mod_4chunk_1_ | ( | mp_srcptr | numa, |
| mp_size_t | na, | ||
| mp_limb_t | d, | ||
| mp_limb_t | dinv, | ||
| mp_limb_t | r2, | ||
| mp_limb_t | base, | ||
| mp_limb_t | mi ) |
4 链折叠取模:r = [numa,na] mod d
| numa | 被除数(长度为 na 个limb) |
| na | 被除数的 limb 长度 |
| d | 除数(单个 limb) |
| dinv | 除数的逆元(d*dinv==1 mod 2^64) |
| r2 | 蒙域预处理(r2=B^2 mod d) |
| base | 蒙域预处理(base=B mod d) |
| mi | 蒙域预处理(mi=-dinv mod 2^64) |
在文件 mod_chunk.c 第 52 行定义.
引用了 c0, c1, k, lmmp_mod_4chunk_1_(), lmmp_param_assert, MONT63_MAX, mont63_mul(), r2, s , 以及 t.
被这些函数引用 lmmp_mod_4chunk_1_(), lmmp_trialdiv_() , 以及 trialdiv_leg_4_().
| mp_limb_t lmmp_mod_8chunk_1_ | ( | mp_srcptr | numa, |
| mp_size_t | na, | ||
| mp_limb_t | d, | ||
| mp_limb_t | dinv, | ||
| mp_limb_t | r2, | ||
| mp_limb_t | base, | ||
| mp_limb_t | mi ) |
8 链折叠取模:r = [numa,na] mod d
| numa | 被除数(长度为 na 个limb) |
| na | 被除数的 limb 长度 |
| d | 除数(单个 limb) |
| dinv | 除数的逆元(d*dinv==1 mod 2^64) |
| r2 | 蒙域预处理(r2=B^2 mod d) |
| base | 蒙域预处理(base=B mod d) |
| mi | 蒙域预处理(mi=-dinv mod 2^64) |
在文件 mod_chunk.c 第 114 行定义.
引用了 c0, c1, k, lmmp_mod_8chunk_1_(), lmmp_param_assert, MONT63_MAX, mont63_mul(), r2, s , 以及 t.
被这些函数引用 lmmp_mod_8chunk_1_(), lmmp_trialdiv_() , 以及 trialdiv_leg_8_().
蒙域乘:a*b*R^-1 mod m(R=B)
在文件 mod_chunk.c 第 48 行定义.
引用了 mont63_mul() , 以及 mont63_reduce().