16#ifndef __LAMMP_PRIME_TABLE_H__
17#define __LAMMP_PRIME_TABLE_H__
25#define LMMP_BITSET_BITS (64)
26#define LMMP_BITSET_MASK (0xffffffffffffffffull)
27#define LMMP_BITSET_BYTES (8)
29#define PRIME_SHORT_TABLE_SIZE 6542
31#define PRIME_SHORT_TABLE_N 0x10000
60 }
else if (
n < 95000) {
61 return (
ulong)ceil((
double)
n / (log(
n) - 1.095)) + 1;
62 }
else if (
n < 355991) {
63 return (
ulong)ceil((
double)
n / (log(
n) - 1.0975)) + 1;
64 }
else if (
n < 1332479531) {
69 double lnx2 = lnx * lnx;
70 double r = x / lnx * (1.0 + 1.0 / lnx + 2.51 / lnx2);
87 double lnx2 = lnx * lnx;
88 double lnx3 = lnx2 * lnx;
89 double lnx4 = lnx3 * lnx;
90 double lnx5 = lnx4 * lnx;
91 double lnx6 = lnx5 * lnx;
94 lnx - 1.0 - 1.0 / lnx - 3.35 / lnx2 - 12.65 / lnx3 - 71.7 / lnx4 - 466.1275 / lnx5 - 3489.8225 / lnx6;
96 return (
ulong)ceil(
n / denom);
uint64_t lmmp_bitset_t
Copyright (C) 2026 HJimmyK(Jericho Knox)
static int trial_div35711(ulong n)
校验是否能被3,5,7,11整除,能够整除则返回1,否则返回0
void lmmp_prime_cache_free_(prime_cache_t *cache)
释放素数表缓存
#define PRIME_SHORT_TABLE_SIZE
const lmmp_bitset_t r35711_mask_map[19]
void lmmp_prime_cache_next_(prime_cache_t *cache)
素数表缓存更新(从小到大遍历全局质数表)
void lmmp_prime_int_table_free_(void)
释放全局素数表
static ulong lmmp_prime_size_(ulong n)
估计 n 范围内的素数数量
int lmmp_is_prime_table_(uint p)
根据全局素数表判断一个数是否为素数
#define PRIME_SHORT_TABLE_N
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)
初始化素数表缓存