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

浏览源代码.

宏定义

#define getbit(p, bi)   ((p[(bi - 1) / LIMB_BITS] >> (bi - 1) % LIMB_BITS) & 1)
 

函数

static mp_bitcnt_t count_bits (mp_srcptr p, mp_size_t n)
 
static mp_limb_t getbits (const mp_limb_t *p, mp_bitcnt_t bi, mp_bitcnt_t nbits)
 
static void lmmp_mullo_n_ (mp_ptr restrict dst, mp_srcptr restrict numa, mp_srcptr restrict numb, mp_size_t n, mp_ptr restrict tp)
 
void lmmp_powlo_ (mp_ptr restrict dst, mp_srcptr restrict bp, mp_size_t n, mp_srcptr restrict ep, mp_size_t en)
 
static void lmmp_sqrlo_n_ (mp_ptr restrict dst, mp_srcptr restrict numa, mp_size_t n, mp_ptr restrict tp)
 Copyright (C) 2026 HJimmyK(Jericho Knox)
 
static mp_size_t win_size (mp_size_t eb)
 

宏定义说明

◆ getbit

#define getbit (   p,
  bi 
)    ((p[(bi - 1) / LIMB_BITS] >> (bi - 1) % LIMB_BITS) & 1)

在文件 powlo.c58 行定义.

函数说明

◆ count_bits()

static mp_bitcnt_t count_bits ( mp_srcptr  p,
mp_size_t  n 
)
inlinestatic

在文件 powlo.c79 行定义.

79 {
80 return (n - 1) * LIMB_BITS + lmmp_limb_bits_(p[n - 1]);
81}
#define lmmp_limb_bits_
Definition inlines.h:162
#define LIMB_BITS
Definition lmmp.h:123
#define n

引用了 LIMB_BITS, lmmp_limb_bits_ , 以及 n.

被这些函数引用 lmmp_powlo_().

+ 这是这个函数的调用关系图:

◆ getbits()

static mp_limb_t getbits ( const mp_limb_t p,
mp_bitcnt_t  bi,
mp_bitcnt_t  nbits 
)
inlinestatic

在文件 powlo.c60 行定义.

60 {
62 mp_limb_t r;
64
65 if (bi <= nbits) {
66 return p[0] & (((mp_limb_t)1 << bi) - 1);
67 } else {
68 bi -= nbits; /* bit index of low bit to extract */
69 i = bi / LIMB_BITS; /* word index of low bit to extract */
70 bi %= LIMB_BITS; /* bit index in low word */
71 r = p[i] >> bi; /* extract (low) bits */
72 nbits_in_r = LIMB_BITS - bi; /* number of bits now in r */
73 if (nbits_in_r < nbits) /* did we get enough bits? */
74 r += p[i + 1] << nbits_in_r; /* prepend bits from higher word */
75 return r & (((mp_limb_t)1 << nbits) - 1);
76 }
77}
size_t mp_bitcnt_t
Definition lmmp.h:119
uint64_t mp_size_t
Definition lmmp.h:114
uint64_t mp_limb_t
Definition lmmp.h:113

引用了 LIMB_BITS , 以及 n.

被这些函数引用 lmmp_powlo_().

+ 这是这个函数的调用关系图:

◆ lmmp_mullo_n_()

static void lmmp_mullo_n_ ( mp_ptr restrict  dst,
mp_srcptr restrict  numa,
mp_srcptr restrict  numb,
mp_size_t  n,
mp_ptr restrict  tp 
)
inlinestatic

在文件 powlo.c37 行定义.

43 {
44 if (n < MULLO_DC_THRESHOLD) {
46 } else {
48 }
49}
void lmmp_mullo_dc_(mp_ptr dst, mp_srcptr numa, mp_srcptr numb, mp_ptr tp, mp_size_t n)
低位乘法 [dst,n] = [numa,n] * [numb,n] mod B^n
void lmmp_mullo_fft_(mp_ptr dst, mp_srcptr numa, mp_srcptr numb, mp_size_t n, mp_ptr scratch)
低位FFT乘法 [dst,n] = [numa,n] * [numb,n] mod B^n
Definition mullo.c:22
#define MULLO_DC_THRESHOLD
Definition mparam.h:59
#define numb
#define tp

引用了 lmmp_mullo_dc_(), lmmp_mullo_fft_(), MULLO_DC_THRESHOLD, n, numb , 以及 tp.

被这些函数引用 lmmp_powlo_().

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ lmmp_powlo_()

void lmmp_powlo_ ( mp_ptr restrict  dst,
mp_srcptr restrict  bp,
mp_size_t  n,
mp_srcptr restrict  ep,
mp_size_t  en 
)

在文件 powlo.c83 行定义.

83 {
84 lmmp_param_assert(ep[en - 1] > 0);
85 lmmp_param_assert(n > 0 && en > 0);
86 lmmp_param_assert(dst != NULL && bp != NULL && ep != NULL);
90 mp_limb_t* pp;
91 long i;
92 int flipflop;
95 mp_ptr restrict scratch = tp + 3 * n;
96
97 ebi = count_bits(ep, en);
98
100 if (windowsize > 1) {
103
104 pp = TALLOC_TYPE((n << (windowsize - 1)), mp_limb_t);
105
106 this_pp = pp;
107
109
110 /* Store b^2 in tp. */
112
113 /* Precompute odd powers of b and put them in the temporary area at pp. */
114 i = (1 << (windowsize - 1)) - 1;
115 do {
117 this_pp += n;
119 } while (--i != 0);
120
122 ebi -= windowsize;
123
125 ebi += cnt;
126
127 lmmp_copy(dst, pp + n * (expbits >> 1), n);
128 } else {
129 pp = tp + n;
130 lmmp_copy(pp, bp, n);
131 lmmp_copy(dst, bp, n);
132 --ebi;
133 }
134
135 flipflop = 0;
136
137 do {
138 while (getbit(ep, ebi) == 0) {
142 if (--ebi == 0)
143 goto done;
144 }
145
146 /* The next bit of the exponent is 1. Now extract the largest block of
147 bits <= windowsize, and such that the least significant bit is 1. */
148
151
155
156 while (this_windowsize > 1) {
159 this_windowsize -= 2;
160 }
161
162 if (this_windowsize != 0)
164 else {
167 }
168 lmmp_mullo_n_(dst, tp, pp + n * (expbits >> 1), n, scratch);
169 } while (ebi != 0);
170
171done:
172 if (flipflop)
173 lmmp_copy(tp, dst, n);
174 TEMP_FREE;
175}
mp_limb_t * mp_ptr
Definition lmmp.h:117
#define LMMP_SWAP(x, y, type)
交换两个变量的值
Definition lmmp.h:445
#define lmmp_copy(dst, src, n)
Definition lmmp.h:461
#define lmmp_debug_assert(x)
Definition lmmp.h:485
#define LMMP_MIN(l, o)
返回两个数中的较小值
Definition lmmp.h:437
#define lmmp_param_assert(x)
Definition lmmp.h:496
#define ctz_shr_u64(r, x, cnt)
Copyright (C) 2026 HJimmyK(Jericho Knox)
Definition longlong.h:74
#define scratch
static mp_size_t win_size(mp_size_t eb)
Definition powlo.c:51
#define getbit(p, bi)
Definition powlo.c:58
static mp_bitcnt_t count_bits(mp_srcptr p, mp_size_t n)
Definition powlo.c:79
static mp_limb_t getbits(const mp_limb_t *p, mp_bitcnt_t bi, mp_bitcnt_t nbits)
Definition powlo.c:60
static void lmmp_sqrlo_n_(mp_ptr restrict dst, mp_srcptr restrict numa, mp_size_t n, mp_ptr restrict tp)
Copyright (C) 2026 HJimmyK(Jericho Knox)
Definition powlo.c:24
static void lmmp_mullo_n_(mp_ptr restrict dst, mp_srcptr restrict numa, mp_srcptr restrict numb, mp_size_t n, mp_ptr restrict tp)
Definition powlo.c:37
#define TEMP_DECL
Definition tmp_alloc.h:131
#define TEMP_FREE
Definition tmp_alloc.h:158
#define TALLOC_TYPE(n, type)
Definition tmp_alloc.h:156

引用了 count_bits(), ctz_shr_u64, getbit, getbits(), lmmp_copy, lmmp_debug_assert, LMMP_MIN, lmmp_mullo_n_(), lmmp_param_assert, lmmp_sqrlo_n_(), LMMP_SWAP, n, scratch, TALLOC_TYPE, TEMP_DECL, TEMP_FREE, tp , 以及 win_size().

+ 函数调用图:

◆ lmmp_sqrlo_n_()

static void lmmp_sqrlo_n_ ( mp_ptr restrict  dst,
mp_srcptr restrict  numa,
mp_size_t  n,
mp_ptr restrict  tp 
)
inlinestatic

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/.

在文件 powlo.c24 行定义.

29 {
30 if (n < MULLO_DC_THRESHOLD) {
32 } else {
34 }
35}
void lmmp_sqrlo_dc_(mp_ptr dst, mp_srcptr numa, mp_ptr tp, mp_size_t n)
低位平方 [dst,n] = [numa,n]^2 mod B^n

引用了 lmmp_mullo_fft_(), lmmp_sqrlo_dc_(), MULLO_DC_THRESHOLD, n , 以及 tp.

被这些函数引用 lmmp_powlo_().

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ win_size()

static mp_size_t win_size ( mp_size_t  eb)
inlinestatic

在文件 powlo.c51 行定义.

51 {
53 static mp_bitcnt_t x[] = {7, 25, 81, 241, 673, 1793, 4609, 11521, 28161, ~(mp_bitcnt_t)0};
54 for (k = 0; eb > x[k++];);
55 return k;
56}
#define k

引用了 k , 以及 n.

被这些函数引用 lmmp_powlo_().

+ 这是这个函数的调用关系图: