LMMP 4.3.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
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
27static 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
34static 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
42int main(void) {
43 setvbuf(stdout, NULL, _IONBF, 0);
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);
49 return 0;
50}
#define LIMB_B_2
int main(void)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义 main.c:26
void lmmp_global_init(void)
全局初始化函数(线程局部的)
uint64_t mp_limb_t
定义 lmmp.h:92
void lmmp_global_deinit(void)
全局释放函数(线程局部的)
mp_limb_t lmmp_inv_1_(mp_limb_t x)
1阶逆元计算 (inv1)
定义 inv.c:124
mp_limb_t lmmp_inv_2_1_(mp_limb_t xh, mp_limb_t xl)
2-1阶逆元计算 (inv21)
定义 inv.c:27
static double bench_inv_2_1(const bench_options *o)
定义 inv.c:34
static double bench_inv_1(const bench_options *o)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义 inv.c:27
#define BENCH_MEASURE(result, options,...)
定义 perf.h:93