LMMP 4.3.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
is_prime_2.c 文件参考
#include "prime_pool.h"
is_prime_2.c 的引用(Include)关系图:

浏览该文件的源代码.

函数

static double bench_is_prime_2 (uint bits, PrimePool kind, const bench_options *o)
static double bench_is_prime_2_notrial (uint bits, PrimePool kind, const bench_options *o)
int main (void)
static mp_ptr pool_2 (uint bits, mp_limb_t seed, PrimePool kind)
 Copyright (C) 2026 HJimmyK (Jericho Knox)
static void run_is_prime_2 (void)
static void run_is_prime_2_notrial (void)

函数说明

◆ bench_is_prime_2()

double bench_is_prime_2 ( uint bits,
PrimePool kind,
const bench_options * o )
static

在文件 is_prime_2.c 第 46 行定义.

46 {
47 if (bits < 65) bits = 65;
48 if (bits > 128) bits = 128;
49 mp_ptr a = pool_2(bits, 0xdeadbeefca01ull + bits, kind);
50 size_t idx = 0;
51 double us;
52 BENCH_MEASURE(us, o,
53 bench_sink += (mp_limb_t)lmmp_is_prime_2_(a[2 * (idx & (POOL - 1))],
54 a[2 * (idx & (POOL - 1)) + 1]);
55 idx++;
56 );
57 lmmp_free(a);
58 return us;
59}
mp_limb_t * mp_ptr
定义 lmmp.h:96
void lmmp_free(void *ptr)
内存释放函数(调用lmmp_heap_free_fn)
uint64_t mp_limb_t
定义 lmmp.h:92
int lmmp_is_prime_2_(mp_limb_t lo, mp_limb_t hi)
判断 128 位素数
static mp_ptr pool_2(uint bits, mp_limb_t seed, PrimePool kind)
Copyright (C) 2026 HJimmyK (Jericho Knox)
#define BENCH_MEASURE(result, options,...)
定义 perf.h:93
@ POOL

引用了 bench_is_prime_2(), BENCH_MEASURE, lmmp_free(), lmmp_is_prime_2_(), POOL , 以及 pool_2().

被这些函数引用 bench_is_prime_2() , 以及 run_is_prime_2().

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

◆ bench_is_prime_2_notrial()

double bench_is_prime_2_notrial ( uint bits,
PrimePool kind,
const bench_options * o )
static

在文件 is_prime_2.c 第 61 行定义.

61 {
62 if (bits < 65) bits = 65;
63 if (bits > 128) bits = 128;
64 mp_ptr a = pool_2(bits, 0xdeadbeefca02ull + bits, kind);
65 size_t idx = 0;
66 double us;
67 BENCH_MEASURE(us, o,
68 bench_sink += (mp_limb_t)lmmp_is_prime_2_notrial_(a[2 * (idx & (POOL - 1))],
69 a[2 * (idx & (POOL - 1)) + 1]);
70 idx++;
71 );
72 lmmp_free(a);
73 return us;
74}
int lmmp_is_prime_2_notrial_(mp_limb_t lo, mp_limb_t hi)
判断 128 位素数(无试除法)

引用了 bench_is_prime_2_notrial(), BENCH_MEASURE, lmmp_free(), lmmp_is_prime_2_notrial_(), POOL , 以及 pool_2().

被这些函数引用 bench_is_prime_2_notrial() , 以及 run_is_prime_2_notrial().

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

◆ main()

int main ( void )

在文件 is_prime_2.c 第 100 行定义.

100 {
101 setvbuf(stdout, NULL, _IONBF, 0);
103 puts("[numth/prime/is_prime_2]");
105 puts("[numth/prime/is_prime_2_notrial]");
108 return 0;
109}
void lmmp_global_init(void)
全局初始化函数(线程局部的)
void lmmp_global_deinit(void)
全局释放函数(线程局部的)
static void run_is_prime_2(void)
static void run_is_prime_2_notrial(void)

引用了 lmmp_global_deinit(), lmmp_global_init(), main(), run_is_prime_2() , 以及 run_is_prime_2_notrial().

函数调用图:

◆ pool_2()

mp_ptr pool_2 ( uint bits,
mp_limb_t seed,
PrimePool kind )
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 第 26 行定义.

26 {
27 if (bits < 65) bits = 65;
28 if (bits > 128) bits = 128;
29 uint hb = bits - 64;
30 mp_ptr a = alloc_limbs(2 * POOL);
31 for (int i = 0; i < POOL; i++) {
32 lmmp_seed_random_(a + 2 * i, 2, seed + i, 1);
33 a[2 * i + 1] &= ((mp_limb_t)-1) >> (64 - hb);
34 a[2 * i + 1] |= (mp_limb_t)1 << (hb - 1);
35 a[2 * i] |= 1;
36 if (kind == PRIME_POOL_COPRIME) {
37 /* 步进只改低 limb、回绕不进位到高 limb,值恒在指定位宽内 */
38 while (small_factor_q(a + 2 * i, 2)) a[2 * i] += 2;
39 } else if (kind == PRIME_POOL_PRIME) {
40 while (lmmp_is_prime_2_(a[2 * i], a[2 * i + 1]) == 0) a[2 * i] += 2;
41 }
42 }
43 return a;
44}
mp_size_t lmmp_seed_random_(mp_ptr dst, mp_size_t n, mp_limb_t seed, unsigned seed_type)
生成随机大整数(0 - B^n-1 均匀分布)
uint32_t uint
定义 numth.h:38
@ PRIME_POOL_PRIME
@ PRIME_POOL_COPRIME

引用了 lmmp_is_prime_2_(), lmmp_seed_random_(), POOL, pool_2(), PRIME_POOL_COPRIME , 以及 PRIME_POOL_PRIME.

被这些函数引用 bench_is_prime_2(), bench_is_prime_2_notrial() , 以及 pool_2().

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

◆ run_is_prime_2()

void run_is_prime_2 ( void )
static

在文件 is_prime_2.c 第 82 行定义.

82 {
83 const uint BITS[] = {65, 82, 96, 128};
84 for (size_t i = 0; i < ARRAY_SIZE(BITS); ++i) {
85 uint bits = BITS[i];
86 report_bits("is_prime_2 odd", bits, bench_is_prime_2(bits, PRIME_POOL_ODD, &bench_default));
87 }
88 report_bits("is_prime_2 prime", 128, bench_is_prime_2(128, PRIME_POOL_PRIME, &bench_default));
89}
static double bench_is_prime_2(uint bits, PrimePool kind, const bench_options *o)
#define ARRAY_SIZE(a)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义 perf.h:40
@ PRIME_POOL_ODD

引用了 ARRAY_SIZE, bench_is_prime_2(), PRIME_POOL_ODD, PRIME_POOL_PRIME , 以及 run_is_prime_2().

被这些函数引用 main() , 以及 run_is_prime_2().

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

◆ run_is_prime_2_notrial()

void run_is_prime_2_notrial ( void )
static

在文件 is_prime_2.c 第 91 行定义.

91 {
92 const uint BITS[] = {65, 128};
93 for (size_t i = 0; i < ARRAY_SIZE(BITS); ++i) {
94 uint bits = BITS[i];
95 report_bits("is_prime_2_notrial odd", bits, bench_is_prime_2_notrial(bits, PRIME_POOL_ODD, &bench_default));
96 }
97 report_bits("is_prime_2_notrial coprime", 128, bench_is_prime_2_notrial(128, PRIME_POOL_COPRIME, &bench_default));
98}
static double bench_is_prime_2_notrial(uint bits, PrimePool kind, const bench_options *o)

引用了 ARRAY_SIZE, bench_is_prime_2_notrial(), PRIME_POOL_COPRIME, PRIME_POOL_ODD , 以及 run_is_prime_2_notrial().

被这些函数引用 main() , 以及 run_is_prime_2_notrial().

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