LMMP
4.3.0
Lamina High-Precision Arithmetic Library
Toggle main menu visibility
载入中...
搜索中...
未找到
strong_lucas.c
浏览该文件的文档.
1
/**
2
* Copyright (C) 2026 HJimmyK (Jericho Knox)
3
*
4
* This file is part of LMMP.
5
*
6
* LMMP is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU Lesser General Public License as
8
* published by the Free Software Foundation; either version 3 of
9
* the License, or (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library. If not, see
18
* <https://www.gnu.org/licenses/>.
19
*
20
* SPDX-License-Identifier: LGPL-3.0-or-later
21
*/
22
23
#include "
prime_pool.h
"
24
25
static
double
bench_is_strong_lucas
(
mp_size_t
n
,
PrimePool
kind,
const
bench_options
*o) {
26
int
cnt = pool_cnt(
n
);
27
mp_ptr
a = pool_n(
n
, cnt, 0x51ce77ac02ull +
n
, kind);
28
size_t
idx = 0;
29
double
us;
30
BENCH_MEASURE
(us, o, bench_sink += (
mp_limb_t
)
lmmp_is_strong_lucas_
(a +
n
* (idx++ % cnt),
n
););
31
lmmp_free
(a);
32
return
us;
33
}
34
35
static
void
run_strong_lucas
(
void
) {
36
const
mp_size_t
SZ[] = {3, 8, 16, 32, 64, 200};
37
for
(
size_t
i = 0; i <
ARRAY_SIZE
(SZ); ++i) {
38
mp_size_t
n
= SZ[i];
39
report_n(
"strong_lucas coprime"
,
n
,
bench_is_strong_lucas
(
n
,
PRIME_POOL_COPRIME
, &bench_default), 0);
40
}
41
}
42
43
int
main
(
void
) {
44
setvbuf(stdout, NULL, _IONBF, 0);
45
lmmp_global_init
();
46
puts(
"[numth/prime/strong_lucas]"
);
47
run_strong_lucas
();
48
lmmp_global_deinit
();
49
return
0;
50
}
main
int main(void)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
main.c:26
mp_ptr
mp_limb_t * mp_ptr
定义
lmmp.h:96
mp_size_t
uint64_t mp_size_t
定义
lmmp.h:93
lmmp_free
void lmmp_free(void *ptr)
内存释放函数(调用lmmp_heap_free_fn)
定义
memory.c:437
lmmp_global_init
void lmmp_global_init(void)
全局初始化函数(线程局部的)
定义
global.c:58
mp_limb_t
uint64_t mp_limb_t
定义
lmmp.h:92
lmmp_global_deinit
void lmmp_global_deinit(void)
全局释放函数(线程局部的)
定义
global.c:65
n
#define n
lmmp_is_strong_lucas_
int lmmp_is_strong_lucas_(mp_srcptr np, mp_size_t nn)
强 Lucas-Selfridge 测试(大于 128 位)
定义
is_prime_n.c:506
ARRAY_SIZE
#define ARRAY_SIZE(a)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
perf.h:40
BENCH_MEASURE
#define BENCH_MEASURE(result, options,...)
定义
perf.h:93
bench_options
定义
perf.h:44
prime_pool.h
PrimePool
PrimePool
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
prime_pool.h:41
PRIME_POOL_COPRIME
@ PRIME_POOL_COPRIME
定义
prime_pool.h:41
bench_is_strong_lucas
static double bench_is_strong_lucas(mp_size_t n, PrimePool kind, const bench_options *o)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
strong_lucas.c:25
run_strong_lucas
static void run_strong_lucas(void)
定义
strong_lucas.c:35
src
lmmp
numth
perf
strong_lucas.c
生成于
, 为 LMMP使用
1.18.0