7#include "../../../include/lammp/impl/ele_mul.h"
8#include "../../../include/lammp/impl/mparam.h"
9#include "../../../include/lammp/impl/prime_table.h"
10#include "../../../include/lammp/impl/tmp_alloc.h"
11#include "../../../include/lammp/lmmpn.h"
12#include "../../../include/lammp/numth.h"
15#define MUL(dst, ap, an, bp, bn) \
17 lmmp_mul_(dst, ap, an, bp, bn); \
19 lmmp_mul_(dst, bp, bn, ap, an)
21#define mul_1(dst, rn, value) \
22 dst[rn] = lmmp_mul_1_(dst, dst, rn, value); \
24 rn -= dst[rn - 1] == 0
27 double ln_fact = lgamma(n + 1.0);
28 double log2_fact = ln_fact /
LOG2_;
50 for (
uint i = 0; i < nfactors; i++) {
60 mul_1(dst, rn, f * f);
64 mul_1(dst, rn, f * f * f);
68 mul_1(dst, rn, f * f * f * f);
74 for (
uint i = 0; i < j - 3; i += 4) {
100 for (
mp_size_t i = 0; i < nfactors; ++i) {
104 fac[new_nfactors].f = f;
105 fac[new_nfactors++].j = j >> 1;
122 if (new_nfactors > 0) {
134 tn -=
tp2[tn - 1] == 0;
135 MUL(dst,
tp2, tn, mp, mpn);
137 rn -= dst[rn - 1] == 0;
144 rn -= dst[rn - 1] == 0;
177 while(cache.
is_end == 0) {
179 for (
uint i = 0; i < cache.
size; i++) {
201 dst[shw + rn] =
lmmp_shl_(dst + shw, dst + shw, rn, bits);
203 rn -= dst[rn - 1] == 0;
mp_size_t lmmp_elem_mul_ulong_(mp_ptr dst, const ulongp limbs, mp_size_t n, mp_ptr tp)
计算limbs数组的累乘积
mp_size_t lmmp_factorial_(mp_ptr restrict dst, mp_bitcnt_t bits, mp_size_t rn, uint n)
#define MUL(dst, ap, an, bp, bn)
mp_size_t lmmp_odd_factorial_uint_(mp_ptr restrict dst, mp_size_t rn, uint n)
static void count_factors(fac_ptr fac, uint nfactors, uint n, uint p)
mp_size_t lmmp_factorial_size_(uint n, mp_bitcnt_t *restrict bits)
#define mul_1(dst, rn, value)
mp_size_t lmmp_factors_mul_(mp_ptr restrict dst, mp_size_t rn, fac_ptr restrict fac, uint nfactors)
#define lmmp_copy(dst, src, n)
#define lmmp_zero(dst, n)
#define lmmp_debug_assert(x)
#define lmmp_param_assert(x)
void lmmp_sqr_(mp_ptr dst, mp_srcptr numa, mp_size_t na)
大数平方操作 [dst,2*na] = [numa,na]^2
mp_limb_t lmmp_shl_(mp_ptr dst, mp_srcptr numa, mp_size_t na, mp_size_t shl)
大数左移操作 [dst,na] = [numa,na]<<shl,dst的低shl位填充0
int lmmp_limb_popcnt_(mp_limb_t x)
计算一个64位无符号整数中1的个数
mp_size_t lmmp_odd_nPr_ushort_(mp_ptr dst, mp_size_t rn, ulong n, ulong r)
计算 nPr 排列数的奇数部分
void lmmp_prime_cache_free_(prime_cache_t *cache)
释放素数表缓存
ulong lmmp_prime_size_(ulong n)
估计 n 范围内的素数数量
void lmmp_prime_cache_next_(prime_cache_t *cache)
素数表缓存更新(从小到大遍历全局质数表)
void lmmp_prime_int_table_init_(uint n)
初始化全局素数表
void lmmp_prime_cache_init_(prime_cache_t *cache, uint n)
初始化素数表缓存
#define TALLOC_TYPE(n, type)
#define BALLOC_TYPE(n, type)