7#include "../../../include/lammp/impl/ele_mul.h"
8#include "../../../include/lammp/impl/prime_table.h"
9#include "../../../include/lammp/impl/longlong.h"
10#include "../../../include/lammp/impl/mparam.h"
15 for (; i < m; ++i) *n += r[i];
17 double logr = lgamma(*n + 1.0);
19 for (i = 0; i < m; ++i)
20 logr -= lgamma(r[i] + 1.0);
36 for (
uint i = 0; i < m; ++i) {
45 fac[nfactors++].
j = e;
54 uint approx1 = rn * 8;
56 return approx1 < approx2 ? approx1 : approx2;
67 const uintp restrict r,
73 for (
uint i = 0; i < m; ++i) {
82 nfactors = primen < nfactors ? primen : nfactors;
85 for (
uint i = 1; i < primen; ++i) {
106 while (cache.
is_end == 0) {
108 for (
uint i = 0; i < cache.
size; ++i) {
120#define MULTINOMIAL_SHORT_LIMIT (0xffff)
121#define MULTINOMIAL_INT_LIMIT (0xffffffff)
125 for (
uint j = 0; j < m; ++j) {
139 dst[shw + rn] =
lmmp_shl_(dst + shw, dst + shw, rn, shl);
141 rn -= dst[rn - 1] == 0 ? 1 : 0;
mp_size_t lmmp_factors_mul_(mp_ptr dst, mp_size_t rn, fac_ptr fac, uint nfactors)
计算因子的累乘,并将结果放入dst中
#define lmmp_zero(dst, n)
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的个数
#define _udiv32by32_q_preinv(q, n0, dinv)
#define ODD_FACTORIAL_SIZE
static mp_size_t lmmp_odd_multinomial_ushort_(mp_ptr restrict dst, mp_size_t rn, uint n, const uintp restrict r, uint m)
static uint factor_size_int(mp_size_t rn, uint n)
static uint factor_size_short(mp_size_t rn)
static uint count_factors(fac_ptr fac, uint nfactors, uint n, const uintp r, uint m, uint p)
mp_size_t lmmp_multinomial_size_(const uintp r, uint m, ulong *restrict n)
#define MULTINOMIAL_SHORT_LIMIT
static mp_size_t lmmp_odd_multinomial_uint_(mp_ptr restrict dst, mp_size_t rn, uint n, const uintp restrict r, uint m)
mp_size_t lmmp_multinomial_(mp_ptr restrict dst, mp_size_t rn, uint n, const uintp restrict r, uint m)
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)
素数表缓存更新(从小到大遍历全局质数表)
const ushort prime_short_table[6542]
void lmmp_prime_int_table_init_(uint n)
初始化全局素数表
ushort lmmp_prime_cnt16_(ushort n)
计算小于等于 n 的素数数量
void lmmp_prime_cache_init_(prime_cache_t *cache, uint n)
初始化素数表缓存
#define TALLOC_TYPE(n, type)
#define BALLOC_TYPE(n, type)