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

浏览该文件的源代码.

结构体

struct  ProthPool

函数

static double bench_is_prime_n_proth (uint t, int strength, bool prime_pool, const bench_options *o)
static double bench_is_prothprime (uint t, bool prime_pool, const bench_options *o)
int main (void)
static ProthPool pool_proth (uint t, int cnt, bool want_prime)
static mp_size_t proth_limbs (mp_ptr dst, uint k, uint t)
 Copyright (C) 2026 HJimmyK (Jericho Knox)
static void run_proth (void)

结构体说明

◆ ProthPool

struct ProthPool

在文件 proth.c 第 38 行定义.

ProthPool 的协作图:
成员变量
mp_ptr a
int cnt
uint ks[8]
mp_size_t nn[8]
mp_size_t stride

函数说明

◆ bench_is_prime_n_proth()

double bench_is_prime_n_proth ( uint t,
int strength,
bool prime_pool,
const bench_options * o )
static

在文件 proth.c 第 78 行定义.

78 {
79 if (t < 1) t = 1; /* 同 bench_is_prothprime:契约 n>0 */
80 ProthPool p = pool_proth(t, 8, prime_pool);
81 size_t idx = 0;
82 double us;
83 BENCH_MEASURE(us, o,
84 bench_sink += (mp_limb_t)lmmp_is_prime_n_(p.a + p.stride * (idx % p.cnt),
85 p.nn[idx % p.cnt], strength);
86 idx++;
87 );
88 lmmp_free(p.a);
89 return us;
90}
void lmmp_free(void *ptr)
内存释放函数(调用lmmp_heap_free_fn)
uint64_t mp_limb_t
定义 lmmp.h:92
#define t
int lmmp_is_prime_n_(mp_srcptr np, mp_size_t nn, int strength)
大整数素性检验(强度分档,大于 128 位)
#define BENCH_MEASURE(result, options,...)
定义 perf.h:93
static ProthPool pool_proth(uint t, int cnt, bool want_prime)
定义 proth.c:47
mp_size_t stride
定义 proth.c:42
mp_ptr a
定义 proth.c:39
mp_size_t nn[8]
定义 proth.c:41

引用了 ProthPool::a, bench_is_prime_n_proth(), BENCH_MEASURE, ProthPool::cnt, lmmp_free(), lmmp_is_prime_n_(), ProthPool::nn, pool_proth(), ProthPool::stride , 以及 t.

被这些函数引用 bench_is_prime_n_proth() , 以及 run_proth().

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

◆ bench_is_prothprime()

double bench_is_prothprime ( uint t,
bool prime_pool,
const bench_options * o )
static

在文件 proth.c 第 68 行定义.

68 {
69 if (t < 1) t = 1; /* is_prothprime_ 契约 n>0 */
70 ProthPool p = pool_proth(t, 8, prime_pool);
71 size_t idx = 0;
72 double us;
73 BENCH_MEASURE(us, o, bench_sink += (mp_limb_t)lmmp_is_prothprime_(p.ks[idx++ % p.cnt], t););
74 lmmp_free(p.a);
75 return us;
76}
int lmmp_is_prothprime_(uint k, mp_size_t n)
Proth 数 k*2^n+1 的素性判定(普罗斯定理)
uint ks[8]
定义 proth.c:40

引用了 ProthPool::a, bench_is_prothprime(), BENCH_MEASURE, ProthPool::cnt, ProthPool::ks, lmmp_free(), lmmp_is_prothprime_(), pool_proth() , 以及 t.

被这些函数引用 bench_is_prothprime() , 以及 run_proth().

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

◆ main()

int main ( void )

在文件 proth.c 第 119 行定义.

119 {
120 setvbuf(stdout, NULL, _IONBF, 0);
122 puts("[numth/prime/proth]");
123 run_proth();
125 return 0;
126}
void lmmp_global_init(void)
全局初始化函数(线程局部的)
void lmmp_global_deinit(void)
全局释放函数(线程局部的)
static void run_proth(void)
定义 proth.c:98

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

函数调用图:

◆ pool_proth()

ProthPool pool_proth ( uint t,
int cnt,
bool want_prime )
static

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

47 {
48 ProthPool p;
49 p.stride = (mp_size_t)t / 64 + 3;
50 p.cnt = cnt;
51 p.a = alloc_limbs((size_t)p.stride * cnt);
52 uint k = 3;
53 for (int i = 0; i < cnt; i++) {
54 for (;;) {
55 mp_size_t nn = proth_limbs(p.a + p.stride * i, k, t);
56 bool ok = want_prime ? lmmp_is_prothprime_(k, (mp_size_t)t)
57 : !small_factor_q(p.a + p.stride * i, nn);
58 if (ok) break;
59 k += 2;
60 }
61 p.ks[i] = k;
62 p.nn[i] = proth_limbs(p.a + p.stride * i, k, t);
63 k += 2;
64 }
65 return p;
66}
#define k
uint64_t mp_size_t
定义 lmmp.h:93
uint32_t uint
定义 numth.h:38
static mp_size_t proth_limbs(mp_ptr dst, uint k, uint t)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义 proth.c:27

引用了 ProthPool::a, ProthPool::cnt, k, ProthPool::ks, lmmp_is_prothprime_(), ProthPool::nn, pool_proth(), proth_limbs(), ProthPool::stride , 以及 t.

被这些函数引用 bench_is_prime_n_proth(), bench_is_prothprime() , 以及 pool_proth().

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

◆ proth_limbs()

mp_size_t proth_limbs ( mp_ptr dst,
uint k,
uint t )
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

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

27 {
28 mp_size_t n = (mp_size_t)t / 64 + 2;
29 lmmp_zero(dst, n + 1);
30 uint sh = t % 64;
31 dst[t / 64] |= (mp_limb_t)k << sh;
32 if (sh != 0) dst[t / 64 + 1] |= (mp_limb_t)k >> (64 - sh);
33 dst[0] |= 1;
34 while (n > 1 && dst[n - 1] == 0) n--;
35 return n;
36}
#define lmmp_zero(dst, n)
定义 lmmp.h:476
#define n

引用了 k, lmmp_zero, n, proth_limbs() , 以及 t.

被这些函数引用 pool_proth() , 以及 proth_limbs().

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

◆ run_proth()

void run_proth ( void )
static

在文件 proth.c 第 98 行定义.

98 {
99 const uint TS[] = {480, 992};
100 for (size_t i = 0; i < ARRAY_SIZE(TS); ++i) {
101 uint t = TS[i];
102 char buf[64];
103 snprintf(buf, sizeof(buf), "is_prothprime prime(t=%u)", t);
104 report(buf, bench_is_prothprime(t, true, &bench_default), 0);
105 snprintf(buf, sizeof(buf), "is_prime_n s4 proth-prime(t=%u)", t);
106 report(buf, bench_is_prime_n_proth(t, 4, true, &bench_default), 0);
107 }
108 const uint TC[] = {2016, 4032};
109 for (size_t i = 0; i < ARRAY_SIZE(TC); ++i) {
110 uint t = TC[i];
111 char buf[64];
112 snprintf(buf, sizeof(buf), "is_prothprime composite(t=%u)", t);
113 report(buf, bench_is_prothprime(t, false, &bench_default), 0);
114 snprintf(buf, sizeof(buf), "is_prime_n s4 proth-composite(t=%u)", t);
115 report(buf, bench_is_prime_n_proth(t, 4, false, &bench_default), 0);
116 }
117}
#define ARRAY_SIZE(a)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义 perf.h:40
static double bench_is_prime_n_proth(uint t, int strength, bool prime_pool, const bench_options *o)
定义 proth.c:78
static double bench_is_prothprime(uint t, bool prime_pool, const bench_options *o)
定义 proth.c:68

引用了 ARRAY_SIZE, bench_is_prime_n_proth(), bench_is_prothprime(), run_proth() , 以及 t.

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

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