LMMP
4.3.0
Lamina High-Precision Arithmetic Library
Toggle main menu visibility
载入中...
搜索中...
未找到
inv.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 "
support/perf.h
"
24
#include "
lmmp/lmmpn.h
"
25
#include "mparam.h"
26
27
static
double
bench_inv_1
(
const
bench_options
*o) {
28
mp_limb_t
x = 0x9e3779b97f4a7c15ull |
LIMB_B_2
;
29
double
us;
30
BENCH_MEASURE
(us, o, bench_sink +=
lmmp_inv_1_
(x););
31
return
us;
32
}
33
34
static
double
bench_inv_2_1
(
const
bench_options
*o) {
35
mp_limb_t
xh = 0x9e3779b97f4a7c15ull |
LIMB_B_2
;
36
mp_limb_t
xl = 0x3141592653589793ull;
37
double
us;
38
BENCH_MEASURE
(us, o, bench_sink +=
lmmp_inv_2_1_
(xh, xl););
39
return
us;
40
}
41
42
int
main
(
void
) {
43
setvbuf(stdout, NULL, _IONBF, 0);
44
lmmp_global_init
();
45
puts(
"[lmmpn/inv]"
);
46
report(
"inv_1"
,
bench_inv_1
(&bench_default), 0);
47
report(
"inv_2_1"
,
bench_inv_2_1
(&bench_default), 0);
48
lmmp_global_deinit
();
49
return
0;
50
}
LIMB_B_2
#define LIMB_B_2
定义
mparam.h:40
main
int main(void)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
main.c:26
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
lmmpn.h
lmmp_inv_1_
mp_limb_t lmmp_inv_1_(mp_limb_t x)
1阶逆元计算 (inv1)
定义
inv.c:124
lmmp_inv_2_1_
mp_limb_t lmmp_inv_2_1_(mp_limb_t xh, mp_limb_t xl)
2-1阶逆元计算 (inv21)
定义
inv.c:27
bench_inv_2_1
static double bench_inv_2_1(const bench_options *o)
定义
inv.c:34
bench_inv_1
static double bench_inv_1(const bench_options *o)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
inv.c:27
perf.h
BENCH_MEASURE
#define BENCH_MEASURE(result, options,...)
定义
perf.h:93
bench_options
定义
perf.h:44
src
lmmp
lmmpn
perf
inv.c
生成于
, 为 LMMP使用
1.18.0