LAMMP 4.2.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
pow_basecase.c 文件参考
+ pow_basecase.c 的引用(Include)关系图:

浏览源代码.

宏定义

#define b1   base
 
#define b1n   n
 
#define mul_b(_i_)
 Copyright (C) 2026 HJimmyK(Jericho Knox)
 

函数

mp_size_t lmmp_pow_basecase_ (mp_ptr restrict dst, mp_size_t rn, mp_srcptr restrict base, mp_size_t n, ulong exp)
 

宏定义说明

◆ b1

#define b1   base

◆ b1n

#define b1n   n

◆ mul_b

#define mul_b (   _i_)
值:
lmmp_mul_(dst, sq, rn, b##_i_, b##_i_##n); \
rn += b##_i_##n; \
rn -= (dst[rn - 1] == 0) ? 1 : 0
void lmmp_mul_(mp_ptr dst, mp_srcptr numa, mp_size_t na, mp_srcptr numb, mp_size_t nb)
不等长大数乘法操作 [dst,na+nb] = [numa,na] * [numb,nb]
#define n

Copyright (C) 2026 HJimmyK(Jericho Knox)

This file is part of LAMMP.

LAMMP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed WITHOUT ANY WARRANTY.

See https://www.gnu.org/licenses/.

在文件 pow_basecase.c23 行定义.

26 : 0

函数说明

◆ lmmp_pow_basecase_()

mp_size_t lmmp_pow_basecase_ ( mp_ptr restrict  dst,
mp_size_t  rn,
mp_srcptr restrict  base,
mp_size_t  n,
ulong  exp 
)

在文件 pow_basecase.c28 行定义.

28 {
30 lmmp_param_assert(exp % 2 == 1);
32
33#define b1 base
34#define b1n n
36 rn = n;
37 lmmp_copy(dst, base, n);
38 lmmp_sqr_(sq, dst, rn);
39 rn <<= 1;
40 rn -= (sq[rn - 1] == 0) ? 1 : 0;
42 int i = 62 - lz;
43 exp <<= lz + 1;
44/*
45 For the intermediate 0, we will skip it entirely until the next 1,
46 and then perform a multiplication. This can reduce the extra copying
47 caused by sparse 1s and improve efficiency.
48 */
49 for ( ; i > 0; ) {
51 if (lz == 0) {
52 mul_b(1);
53
54 lmmp_sqr_(sq, dst, rn);
55 rn <<= 1;
56 rn -= (sq[rn - 1] == 0) ? 1 : 0;
57 --i;
58 exp <<= 1;
59 } else {
60 int j = 2;
61 if (lz & 1) {
62 lmmp_copy(dst, sq, rn);
63 lmmp_sqr_(sq, dst, rn);
64 rn <<= 1;
65 rn -= (sq[rn - 1] == 0);
66 ++j;
67 for (; j <= lz; j += 2) {
68 lmmp_sqr_(dst, sq, rn);
69 rn <<= 1;
70 rn -= (dst[rn - 1] == 0);
71 lmmp_sqr_(sq, dst, rn);
72 rn <<= 1;
73 rn -= (sq[rn - 1] == 0);
74 }
75 } else {
76 for (; j <= lz; j += 2) {
77 lmmp_sqr_(dst, sq, rn);
78 rn <<= 1;
79 rn -= (dst[rn - 1] == 0);
80 lmmp_sqr_(sq, dst, rn);
81 rn <<= 1;
82 rn -= (sq[rn - 1] == 0);
83 }
84 }
85
86 i -= lz;
87 exp <<= lz;
88 }
89 }
91
92 mul_b(1);
93
95 return rn;
96
97#undef b1
98#undef b1n
99#undef new_b
100}
#define lmmp_leading_zeros_
Definition inlines.h:160
#define lmmp_sqr_
Definition inlines.h:166
mp_limb_t * mp_ptr
Definition lmmp.h:80
#define lmmp_copy(dst, src, n)
Definition lmmp.h:367
#define lmmp_debug_assert(x)
Definition lmmp.h:390
uint64_t mp_limb_t
Definition lmmp.h:76
#define lmmp_param_assert(x)
Definition lmmp.h:401
#define LIMB_B_2
Definition mparam.h:157
#define mul_b(_i_)
Copyright (C) 2026 HJimmyK(Jericho Knox)
#define TEMP_DECL
Definition tmp_alloc.h:131
#define TEMP_FREE
Definition tmp_alloc.h:150
#define TALLOC_TYPE(n, type)
Definition tmp_alloc.h:148

引用了 LIMB_B_2, lmmp_copy, lmmp_debug_assert, lmmp_leading_zeros_, lmmp_param_assert, lmmp_sqr_, mul_b, n, TALLOC_TYPE, TEMP_DECL , 以及 TEMP_FREE.