LAMMP 4.2.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
gcd_1.c
浏览该文件的文档.
1/**
2 * Copyright (C) 2026 HJimmyK(Jericho Knox)
3 *
4 * This file is part of LAMMP.
5 *
6 * LAMMP is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License (LGPL) as published
8 * by the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed WITHOUT ANY WARRANTY.
12 *
13 * See <https://www.gnu.org/licenses/>.
14 */
15
16#include "../../../include/lammp/numth.h"
17#include "../../../include/lammp/lmmpn.h"
18
19
20/*
21 FIXME: 内联lmmp_tailing_zeros_()函数,使用编译器内置函数,可以显著提升性能。
22 */
23
25 lmmp_param_assert(u > 0 && v > 0);
26 int count, k;
30 while (u != v) {
31 if (u > v) {
32 u -= v;
34 u >>= count;
35 } else {
36 v -= u;
38 v >>= count;
39 }
40 }
41 return u << k;
42}
43
48 if (un == 1) {
49 ulimb = up[0];
50 } else {
52 }
53 if (ulimb == 0)
54 return vlimb;
55 else
56 return lmmp_gcd_11_(ulimb, vlimb);
57}
#define k
mp_limb_t lmmp_gcd_1_(mp_srcptr up, mp_size_t un, mp_limb_t vlimb)
计算两个无符号整数的最大公约数
Definition gcd_1.c:44
mp_limb_t lmmp_gcd_11_(mp_limb_t u, mp_limb_t v)
Copyright (C) 2026 HJimmyK(Jericho Knox)
Definition gcd_1.c:24
#define lmmp_tailing_zeros_
Definition inlines.h:161
uint64_t mp_size_t
Definition lmmp.h:77
const mp_limb_t * mp_srcptr
Definition lmmp.h:81
uint64_t mp_limb_t
Definition lmmp.h:76
#define lmmp_param_assert(x)
Definition lmmp.h:401
mp_limb_t lmmp_mod_1_(mp_srcptr numa, mp_size_t na, mp_limb_t x)
单精度数取余
Definition div.c:31
#define n