|
LMMP 4.3.0
Lamina High-Precision Arithmetic Library
|
#include "impl/inlines.h"#include "impl/longlong.h"#include "mparam.h"#include "lmmp/lmmpn.h"#include "lmmp/numth.h"宏定义 | |
| #define | abound0 ll_trial_primes[i][2] |
| #define | abound1 ll_trial_primes[i][3] |
| #define | ainv0 ll_trial_primes[i][0] |
| #define | ainv1 ll_trial_primes[i][1] |
| #define | bbound0 ll_trial_primes[i + 1][2] |
| #define | bbound1 ll_trial_primes[i + 1][3] |
| #define | binv0 ll_trial_primes[i + 1][0] |
| #define | binv1 ll_trial_primes[i + 1][1] |
| #define | FAST_TRIAL_BOUND (MP_ULONG_MAX - 137) |
函数 | |
| static int | bitlen_2 (u128 x) |
| static u128 | factor_2adic (u128 x, slong *t) |
| static int | is2_notrial_i_ (mp_limb_t lo, mp_limb_t hi) |
| static int | is_square_2 (u128 n) |
| static int | jacobi_D (uint Dabs, int Dneg, u128 n) |
| static int | jacobi_small (ulong b, ulong A) |
| static int | ll_le (u128 a, u128 b) |
| static void | ll_small_2_powmod (ulong y[2], u128 d, int ebits, ulong n1, ulong n0, ulong minv1, ulong minv0) |
| static int | ll_small_is_prime_mr (u128 n, u128 minv, u128 d, int ebits, slong t, int nb) |
| static void | ll_small_mul1_ (ulong *r1, ulong *r0, ulong a1, ulong a0, ulong b) |
| static void | ll_small_powmod_2ch_ (ulong y1[2], ulong y2[2], ulong b1, ulong b2, u128 d, int ebits, ulong n1, ulong n0, ulong minv1, ulong minv0) |
| static void | ll_small_powmod_3_ (ulong y1[2], ulong y2[2], ulong y3[2], ulong b1, ulong b2, ulong b3, u128 d, int ebits, ulong n1, ulong n0, ulong minv1, ulong minv0) |
| static void | ll_small_preinv (u128 *minv, u128 n) |
| static void | ll_small_reduce2_precise (ulong *r1, ulong *r0, ulong x1, ulong x0, ulong n1, ulong n0, ulong minv1) |
| static int | ll_small_sprp_stage2 (ulong y1, ulong y0, slong t, ulong nm1_1, ulong nm1_0, ulong n1, ulong n0, ulong minv1, ulong minv0) |
| static void | ll_small_sqrmod (ulong *r1, ulong *r0, ulong a1, ulong a0, ulong n1, ulong n0, ulong minv1, ulong minv0) |
| static void | ll_small_sqrmod_sloppy (ulong *r1, ulong *r0, ulong a1, ulong a0, ulong n1, ulong n0, ulong minv1, ulong minv0) |
| int | lmmp_is_prime_2_ (mp_limb_t lo, mp_limb_t hi) |
| 判断 128 位素数 | |
| int | lmmp_is_prime_2_notrial_ (mp_limb_t lo, mp_limb_t hi) |
| 判断 128 位素数(无试除法) | |
| static u128 | mont2_dbl (u128 a, u128 n) |
| static int | mont2_lucas_strong_ (u128 n, u128 ninv, u128 R2) |
| static u128 | mont2_mul_2 (u128 a, u128 b, u128 n, u128 ninv) |
| static u128 | mont2_neg (u128 a, u128 n) |
| static u128 | mont2_powmod_2_ (u128 d, int ebits, u128 R2, u128 n, u128 ninv) |
| static void | mont2_preinv (u128 *ninv, u128 *R2, u128 n) |
| static u128 | mont2_redc (u128 thi, u128 tlo, u128 n, u128 ninv) |
| static u128 | mont2_redc_mul_1 (u128 a, ulong b, u128 n, u128 ninv) |
| static int | mont2_sprp_stage2 (u128 y, slong t, u128 one, u128 m_1, u128 n, u128 ninv) |
| static u128 | mont2_sqr (u128 a, u128 n, u128 ninv) |
| static u128 | mont2_sub (u128 a, u128 b, u128 n) |
| static u128 | mont2_to_mont1 (ulong x, u128 R2, u128 n, u128 ninv) |
| static u128 | mont2_to_mont2 (u128 a, u128 R2, u128 n, u128 ninv) |
| static void | mul_128 (u128 a, u128 b, u128 *hi, u128 *lo) |
| static void | sqr_128 (u128 a, u128 *hi, u128 *lo) |
变量 | |
| static const ulong | ll_trial_primes [32][4] |
| Copyright (C) 2026 HJimmyK (Jericho Knox) | |
| #define abound0 ll_trial_primes[i][2] |
被这些函数引用 lmmp_is_prime_2_().
| #define abound1 ll_trial_primes[i][3] |
被这些函数引用 lmmp_is_prime_2_().
| #define ainv0 ll_trial_primes[i][0] |
被这些函数引用 lmmp_is_prime_2_().
| #define ainv1 ll_trial_primes[i][1] |
被这些函数引用 lmmp_is_prime_2_().
| #define bbound0 ll_trial_primes[i + 1][2] |
被这些函数引用 lmmp_is_prime_2_().
| #define bbound1 ll_trial_primes[i + 1][3] |
被这些函数引用 lmmp_is_prime_2_().
| #define binv0 ll_trial_primes[i + 1][0] |
被这些函数引用 lmmp_is_prime_2_().
| #define binv1 ll_trial_primes[i + 1][1] |
被这些函数引用 lmmp_is_prime_2_().
| #define FAST_TRIAL_BOUND (MP_ULONG_MAX - 137) |
在文件 is_prime_2.c 第 73 行定义.
被这些函数引用 lmmp_is_prime_2_().
|
inlinestatic |
在文件 is_prime_2.c 第 222 行定义.
引用了 bitlen_2() , 以及 lmmp_leading_zeros_.
被这些函数引用 bitlen_2(), is2_notrial_i_() , 以及 mont2_lucas_strong_().
|
inlinestatic |
在文件 is_prime_2.c 第 228 行定义.
引用了 factor_2adic(), lmmp_tailing_zeros_ , 以及 t.
被这些函数引用 factor_2adic(), is2_notrial_i_() , 以及 mont2_lucas_strong_().
在文件 is_prime_2.c 第 687 行定义.
引用了 _sub_ddmmss, bitlen_2(), factor_2adic(), is2_notrial_i_(), ll_small_2_powmod(), ll_small_is_prime_mr(), ll_small_preinv(), ll_small_sprp_stage2(), LMMP_NOINLINE, lo, mont2_lucas_strong_(), mont2_powmod_2_(), mont2_preinv(), mont2_sprp_stage2(), mont2_to_mont1(), mont2_to_mont2(), n , 以及 t.
被这些函数引用 is2_notrial_i_(), lmmp_is_prime_2_() , 以及 lmmp_is_prime_2_notrial_().
|
inlinestatic |
在文件 is_prime_2.c 第 532 行定义.
引用了 is_square_2(), lmmp_debug_assert, lmmp_leading_zeros_, lmmp_shl_(), lmmp_sqrt_2_(), lo , 以及 n.
被这些函数引用 is_square_2() , 以及 mont2_lucas_strong_().
|
inlinestatic |
在文件 is_prime_2.c 第 263 行定义.
引用了 A, jacobi_D(), jacobi_small() , 以及 n.
被这些函数引用 jacobi_D() , 以及 mont2_lucas_strong_().
在文件 is_prime_2.c 第 238 行定义.
引用了 A, jacobi_small(), lmmp_tailing_zeros_ , 以及 s.
被这些函数引用 jacobi_D() , 以及 jacobi_small().
|
inlinestatic |
在文件 is_prime_2.c 第 75 行定义.
引用了 ll_le().
被这些函数引用 ll_le() , 以及 lmmp_is_prime_2_().
|
static |
在文件 is_prime_2.c 第 380 行定义.
引用了 _add_ssaaaa, k, ll_small_2_powmod(), ll_small_reduce2_precise(), ll_small_sqrmod_sloppy(), r0 , 以及 r1.
被这些函数引用 is2_notrial_i_() , 以及 ll_small_2_powmod().
|
static |
在文件 is_prime_2.c 第 508 行定义.
引用了 _sub_ddmmss, ll_small_is_prime_mr(), ll_small_powmod_2ch_(), ll_small_powmod_3_(), ll_small_sprp_stage2(), n , 以及 t.
被这些函数引用 is2_notrial_i_() , 以及 ll_small_is_prime_mr().
在文件 is_prime_2.c 第 372 行定义.
引用了 _umullo128x64_(), a0, a1, ll_small_mul1_(), r0, r1 , 以及 t.
被这些函数引用 ll_small_mul1_(), ll_small_powmod_2ch_() , 以及 ll_small_powmod_3_().
|
static |
在文件 is_prime_2.c 第 464 行定义.
引用了 b1, b2, ll_small_mul1_(), ll_small_powmod_2ch_(), ll_small_reduce2_precise() , 以及 ll_small_sqrmod_sloppy().
被这些函数引用 ll_small_is_prime_mr() , 以及 ll_small_powmod_2ch_().
|
static |
在文件 is_prime_2.c 第 411 行定义.
引用了 b1, b2, b3, ll_small_mul1_(), ll_small_powmod_3_(), ll_small_reduce2_precise() , 以及 ll_small_sqrmod_sloppy().
被这些函数引用 ll_small_is_prime_mr() , 以及 ll_small_powmod_3_().
|
static |
在文件 is_prime_2.c 第 324 行定义.
引用了 ll_small_preinv(), lmmp_div_2_() , 以及 n.
被这些函数引用 is2_notrial_i_() , 以及 ll_small_preinv().
|
inlinestatic |
在文件 is_prime_2.c 第 360 行定义.
引用了 _sub_ddmmss, _umul64to64hi_(), _umullo128x64_(), ll_small_reduce2_precise(), r0, r1 , 以及 t.
被这些函数引用 ll_small_2_powmod(), ll_small_powmod_2ch_(), ll_small_powmod_3_() , 以及 ll_small_reduce2_precise().
|
inlinestatic |
在文件 is_prime_2.c 第 393 行定义.
引用了 ll_small_sprp_stage2(), ll_small_sqrmod() , 以及 t.
被这些函数引用 is2_notrial_i_(), ll_small_is_prime_mr() , 以及 ll_small_sprp_stage2().
|
inlinestatic |
在文件 is_prime_2.c 第 348 行定义.
引用了 _sub_ddmmss, a0, a1, ll_small_sqrmod(), ll_small_sqrmod_sloppy(), r0 , 以及 r1.
被这些函数引用 ll_small_sprp_stage2() , 以及 ll_small_sqrmod().
|
inlinestatic |
在文件 is_prime_2.c 第 333 行定义.
引用了 _sub_ddmmss, _umul128to128_(), _umulhi128_sloppy_(), _usqr128to192_(), a0, a1, ll_small_sqrmod_sloppy(), r0, r1, s , 以及 t.
被这些函数引用 ll_small_2_powmod(), ll_small_powmod_2ch_(), ll_small_powmod_3_(), ll_small_sqrmod() , 以及 ll_small_sqrmod_sloppy().
判断 128 位素数
| lo | 待判断数的低 64 位 |
| hi | 待判断数的高 64 位 |
在文件 is_prime_2.c 第 739 行定义.
引用了 _umul128to128_(), abound0, abound1, ainv0, ainv1, bbound0, bbound1, binv0, binv1, FAST_TRIAL_BOUND, is2_notrial_i_(), ll_le(), lmmp_is_prime_2_(), lmmp_param_assert , 以及 lo.
被这些函数引用 bench_is_prime_2(), check_prime_2_agreement(), ipn_proth_i_(), lmmp_is_prime_2_(), lmmp_is_prothprime_(), lmmp_powmod_(), pool_2() , 以及 TEST_CASE().
判断 128 位素数(无试除法)
| lo | 待判断数的低 64 位 |
| hi | 待判断数的高 64 位 |
在文件 is_prime_2.c 第 733 行定义.
引用了 is2_notrial_i_(), lmmp_is_prime_2_notrial_(), lmmp_param_assert , 以及 lo.
被这些函数引用 bench_is_prime_2_notrial(), check_prime_2_agreement(), lmmp_is_prime_2_notrial_() , 以及 lmmp_powmod_().
|
inlinestatic |
在文件 is_prime_2.c 第 202 行定义.
引用了 mont2_dbl(), n , 以及 s.
被这些函数引用 mont2_dbl(), mont2_lucas_strong_() , 以及 mont2_powmod_2_().
|
static |
在文件 is_prime_2.c 第 568 行定义.
引用了 bitlen_2(), factor_2adic(), is_square_2(), jacobi_D(), mont2_dbl(), mont2_lucas_strong_(), mont2_mul_2(), mont2_neg(), mont2_sqr(), mont2_sub(), mont2_to_mont1(), mont2_to_mont2(), n, r5 , 以及 s.
被这些函数引用 is2_notrial_i_() , 以及 mont2_lucas_strong_().
|
inlinestatic |
在文件 is_prime_2.c 第 175 行定义.
引用了 mont2_mul_2(), mont2_redc(), mul_128() , 以及 n.
被这些函数引用 lmmp_powmod_2_(), mont2_lucas_strong_(), mont2_mul_2(), mont2_mul_2() , 以及 mont2_to_mont2().
|
inlinestatic |
在文件 is_prime_2.c 第 217 行定义.
引用了 mont2_neg() , 以及 n.
被这些函数引用 mont2_lucas_strong_() , 以及 mont2_neg().
|
static |
在文件 is_prime_2.c 第 294 行定义.
引用了 k, mont2_dbl(), mont2_powmod_2_(), mont2_sqr(), mont2_to_mont1() , 以及 n.
被这些函数引用 is2_notrial_i_() , 以及 mont2_powmod_2_().
|
static |
在文件 is_prime_2.c 第 671 行定义.
引用了 lmmp_binvert_2_(), lmmp_div_2_(), mont2_preinv() , 以及 n.
被这些函数引用 is2_notrial_i_() , 以及 mont2_preinv().
|
inlinestatic |
在文件 is_prime_2.c 第 124 行定义.
引用了 c1, lo, mont2_redc(), mul_128() , 以及 n.
被这些函数引用 lmmp_powmod_2_(), mont2_mul_2(), mont2_mul_2(), mont2_redc(), mont2_redc(), mont2_redc_mul_1(), mont2_sqr() , 以及 mont2_sqr().
|
inlinestatic |
在文件 is_prime_2.c 第 183 行定义.
引用了 lo, mont2_redc(), mont2_redc_mul_1() , 以及 n.
被这些函数引用 mont2_redc_mul_1() , 以及 mont2_to_mont1().
|
inlinestatic |
在文件 is_prime_2.c 第 280 行定义.
引用了 mont2_sprp_stage2(), mont2_sqr(), n , 以及 t.
被这些函数引用 is2_notrial_i_() , 以及 mont2_sprp_stage2().
|
inlinestatic |
在文件 is_prime_2.c 第 169 行定义.
引用了 mont2_redc(), mont2_sqr(), n , 以及 sqr_128().
被这些函数引用 lmmp_powmod_2_(), mont2_lucas_strong_(), mont2_powmod_2_(), mont2_sprp_stage2(), mont2_sqr() , 以及 mont2_sqr().
|
inlinestatic |
在文件 is_prime_2.c 第 211 行定义.
引用了 mont2_sub() , 以及 n.
被这些函数引用 mont2_lucas_strong_() , 以及 mont2_sub().
|
inlinestatic |
在文件 is_prime_2.c 第 192 行定义.
引用了 mont2_redc_mul_1(), mont2_to_mont1() , 以及 n.
被这些函数引用 is2_notrial_i_(), mont2_lucas_strong_(), mont2_powmod_2_() , 以及 mont2_to_mont1().
|
inlinestatic |
在文件 is_prime_2.c 第 196 行定义.
引用了 mont2_mul_2(), mont2_to_mont2() , 以及 n.
被这些函数引用 is2_notrial_i_(), mont2_lucas_strong_() , 以及 mont2_to_mont2().
|
inlinestatic |
在文件 is_prime_2.c 第 79 行定义.
引用了 _umul128to256_(), a0, a1, b0, b1, lo , 以及 mul_128().
被这些函数引用 mont2_mul_2(), mont2_mul_2(), mont2_redc(), mont2_redc(), mul_128() , 以及 mul_128().
|
inlinestatic |
在文件 is_prime_2.c 第 102 行定义.
引用了 _usqr128to256_(), a0, a1, lo , 以及 sqr_128().
被这些函数引用 mont2_sqr(), mont2_sqr(), sqr_128() , 以及 sqr_128().
|
static |
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
在文件 is_prime_2.c 第 35 行定义.