|
LMMP 4.3.0
Lamina High-Precision Arithmetic Library
|
#include "impl/prime_table.h"#include "mparam.h"#include "impl/inlines.h"#include "impl/tmp_alloc.h"结构体 | |
| struct | prime_int |
| Copyright (C) 2026 HJimmyK (Jericho Knox) 更多... | |
宏定义 | |
| #define | DEC_WORD(m, wbase) |
| #define | G global_prime_int_table |
| #define | PRIME_SEG_WORDS (1u << 16) |
| #define | set_not_prime(p, i) |
| #define | WHEEL_IDX(x) |
| #define | WHEEL_NUM(i) |
类型定义 | |
| typedef struct prime_int | prime_int |
| Copyright (C) 2026 HJimmyK (Jericho Knox) | |
函数 | |
| static void | fill_pattern (uchar *restrict dst, uint b0, uint bend, const uchar *restrict pat) |
| int | lmmp_is_prime_table_ (uint p) |
| 根据全局素数表判断一个数是否为素数 | |
| void | lmmp_prime_cache_free_ (prime_cache_t *cache) |
| 释放素数表缓存 | |
| void | lmmp_prime_cache_init_ (prime_cache_t *cache, uint n) |
| 初始化素数表缓存 | |
| void | lmmp_prime_cache_next_ (prime_cache_t *cache) |
| 素数表缓存更新(从小到大遍历全局质数表) | |
| ushort | lmmp_prime_cnt16_ (ushort n) |
| 计算小于等于 n 的素数数量 | |
| void | lmmp_prime_int_table_free_ (void) |
| 释放全局素数表 | |
| void | lmmp_prime_int_table_init_ (uint n) |
| 初始化全局素数表 | |
| static uint | prime_table_words (uint n) |
| static uint | wheel_leq_idx (uint n) |
变量 | |
| static const uchar | bump30 [30] |
| static const uchar | gap30 [30] |
| static LMMP_THREAD_LOCAL prime_int | global_prime_int_table |
| static const uchar | inv30_by_slot [8] = {1, 13, 11, 7, 23, 19, 17, 29} |
| static const uchar | presieve77_table [77] |
| static const uint | res8 [8] = {1, 7, 11, 13, 17, 19, 23, 29} |
| static const uchar | slot30 [30] |
| struct prime_int |
Copyright (C) 2026 HJimmyK (Jericho Knox)
This file is part of LMMP.
LMMP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library. If not, see https://www.gnu.org/licenses/.
SPDX-License-Identifier: LGPL-3.0-or-later
在文件 prime_sieve.c 第 29 行定义.
| 成员变量 | ||
|---|---|---|
| lmmp_bitset_p restrict | map | |
| uint | map_size | |
| uint | max | |
| #define DEC_WORD | ( | m, | |
| wbase ) |
在文件 prime_sieve.c 第 295 行定义.
被这些函数引用 lmmp_prime_cache_next_().
| #define G global_prime_int_table |
在文件 prime_sieve.c 第 41 行定义.
被这些函数引用 lmmp_is_prime_table_(), lmmp_prime_cache_init_(), lmmp_prime_cache_next_(), lmmp_prime_int_table_free_(), lmmp_prime_int_table_init_(), lmmp_trialdiv_(), lmmp_trialdiv_table_free_(), trialdiv_close(), trialdiv_extend_(), trialdiv_init_chunk_() , 以及 trialdiv_init_inv_().
| #define PRIME_SEG_WORDS (1u << 16) |
在文件 prime_sieve.c 第 90 行定义.
被这些函数引用 lmmp_prime_int_table_init_().
| #define set_not_prime | ( | p, | |
| i ) |
在文件 prime_sieve.c 第 70 行定义.
被这些函数引用 lmmp_prime_int_table_init_().
| #define WHEEL_IDX | ( | x | ) |
在文件 prime_sieve.c 第 68 行定义.
被这些函数引用 lmmp_prime_int_table_init_().
| #define WHEEL_NUM | ( | i | ) |
在文件 prime_sieve.c 第 69 行定义.
| typedef struct prime_int prime_int |
Copyright (C) 2026 HJimmyK (Jericho Knox)
This file is part of LMMP.
LMMP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library. If not, see https://www.gnu.org/licenses/.
SPDX-License-Identifier: LGPL-3.0-or-later
在文件 prime_sieve.c 第 109 行定义.
引用了 b0, fill_pattern(), n, restrict , 以及 t.
| int lmmp_is_prime_table_ | ( | uint | p | ) |
根据全局素数表判断一个数是否为素数
| p | 待判断的数 |
在文件 prime_sieve.c 第 264 行定义.
引用了 G, lmmp_is_prime_table_(), lmmp_param_assert, lmmp_prime_cnt16_(), prime_short_table, PRIME_SHORT_TABLE_N, s , 以及 slot30.
被这些函数引用 lmmp_is_prime_table_(), lmmp_is_prime_uint_() , 以及 lmmp_is_prime_ulong_().
| void lmmp_prime_cache_free_ | ( | prime_cache_t * | cache | ) |
释放素数表缓存
| cache | 缓存结构体 |
在文件 prime_sieve.c 第 363 行定义.
引用了 lmmp_free(), lmmp_prime_cache_free_() , 以及 prime_cache_t::pp.
被这些函数引用 lmmp_odd_2factorial_uint_(), lmmp_odd_factorial_uint_(), lmmp_odd_multinomial_uint_(), lmmp_odd_nCr_uint_(), lmmp_odd_nPr_uint_(), lmmp_prime_cache_free_() , 以及 lmmp_primefac_().
| void lmmp_prime_cache_init_ | ( | prime_cache_t * | cache, |
| uint | n ) |
初始化素数表缓存
| cache | 缓存结构体 |
| n | 遍历素数表的范围(超过n时或者遍历到全局质数表末尾,is_end 置为 1) |
在文件 prime_sieve.c 第 284 行定义.
引用了 ALLOC_TYPE, prime_cache_t::end_idx, prime_cache_t::end_num, G, prime_cache_t::is_end, LMMP_BITSET_BITS, lmmp_param_assert, lmmp_prime_cache_init_(), n, prime_cache_t::pp, PRIME_CACHE_SIZE, prime_cache_t::size, prime_cache_t::start_idx , 以及 wheel_leq_idx().
被这些函数引用 lmmp_odd_2factorial_uint_(), lmmp_odd_factorial_uint_(), lmmp_odd_multinomial_uint_(), lmmp_odd_nCr_uint_(), lmmp_odd_nPr_uint_(), lmmp_prime_cache_init_() , 以及 lmmp_primefac_().
| void lmmp_prime_cache_next_ | ( | prime_cache_t * | cache | ) |
素数表缓存更新(从小到大遍历全局质数表)
| cache | 缓存结构体 |
在文件 prime_sieve.c 第 302 行定义.
引用了 DEC_WORD, prime_cache_t::end_idx, prime_cache_t::end_num, G, prime_cache_t::is_end, LMMP_BITSET_BITS, lmmp_debug_assert, lmmp_prime_cache_next_(), prime_cache_t::pp, PRIME_CACHE_BLOCK_NUM, PRIME_CACHE_SIZE, prime_cache_t::size, prime_cache_t::start_idx , 以及 wheel_leq_idx().
被这些函数引用 lmmp_odd_2factorial_uint_(), lmmp_odd_factorial_uint_(), lmmp_odd_multinomial_uint_(), lmmp_odd_nCr_uint_(), lmmp_odd_nPr_uint_(), lmmp_prime_cache_next_() , 以及 lmmp_primefac_().
计算小于等于 n 的素数数量
| n | 范围 |
在文件 prime_sieve.c 第 368 行定义.
引用了 lmmp_prime_cnt16_(), lo, n, prime_short_table , 以及 PRIME_SHORT_TABLE_SIZE.
被这些函数引用 lmmp_hyperfac_(), lmmp_is_prime_table_(), lmmp_next_prime_ulong_(), lmmp_odd_2factorial_ushort_(), lmmp_odd_multinomial_ushort_(), lmmp_odd_nCr_ushort_(), lmmp_odd_nPr_ushort_(), lmmp_prev_prime_ulong_(), lmmp_prime_cnt16_(), lmmp_prime_int_table_init_(), lmmp_prime_size_(), lmmp_primefac_(), lmmp_superfac_() , 以及 lmmp_trialdiv_().
| void lmmp_prime_int_table_free_ | ( | void | ) |
释放全局素数表
在文件 prime_sieve.c 第 388 行定义.
引用了 G, lmmp_free() , 以及 lmmp_prime_int_table_free_().
被这些函数引用 lmmp_prime_int_table_free_().
| void lmmp_prime_int_table_init_ | ( | uint | n | ) |
初始化全局素数表
| n | 素数表大小(含n) |
在文件 prime_sieve.c 第 123 行定义.
引用了 ALLOC_TYPE, bump30, fill_pattern(), G, gap30, inv30_by_slot, k, LMMP_BITSET_BITS, lmmp_free(), lmmp_prime_cnt16_(), lmmp_prime_int_table_init_(), MP_UINT_MAX, n, presieve77_table, PRIME_SEG_WORDS, prime_short_table, prime_table_words(), REALLOC_TYPE, res8, restrict, s, set_not_prime, slot30, WHEEL_IDX , 以及 wheel_leq_idx().
被这些函数引用 lmmp_odd_2factorial_uint_(), lmmp_odd_factorial_uint_(), lmmp_odd_multinomial_uint_(), lmmp_odd_nCr_uint_(), lmmp_odd_nPr_uint_(), lmmp_prime_int_table_init_() , 以及 lmmp_primefac_().
在文件 prime_sieve.c 第 84 行定义.
引用了 n , 以及 prime_table_words().
被这些函数引用 lmmp_prime_int_table_init_() , 以及 prime_table_words().
在文件 prime_sieve.c 第 73 行定义.
引用了 n, slot30 , 以及 wheel_leq_idx().
被这些函数引用 lmmp_prime_cache_init_(), lmmp_prime_cache_next_(), lmmp_prime_int_table_init_() , 以及 wheel_leq_idx().
|
static |
在文件 prime_sieve.c 第 58 行定义.
被这些函数引用 lmmp_prime_int_table_init_().
|
static |
在文件 prime_sieve.c 第 62 行定义.
被这些函数引用 lmmp_prime_int_table_init_().
|
static |
在文件 prime_sieve.c 第 35 行定义.
|
static |
在文件 prime_sieve.c 第 66 行定义.
被这些函数引用 lmmp_prime_int_table_init_().
|
static |
在文件 prime_sieve.c 第 100 行定义.
被这些函数引用 lmmp_prime_int_table_init_().
|
static |
在文件 prime_sieve.c 第 51 行定义.
被这些函数引用 lmmp_prime_int_table_init_().
|
static |
在文件 prime_sieve.c 第 54 行定义.
被这些函数引用 lmmp_is_prime_table_(), lmmp_prime_int_table_init_() , 以及 wheel_leq_idx().