|
primesieve
5.6.0
|
primesieve C API. More...

Macros | |
| #define | PRIMESIEVE_VERSION "5.6.0" |
| #define | PRIMESIEVE_VERSION_MAJOR 5 |
| #define | PRIMESIEVE_VERSION_MINOR 6 |
| #define | PRIMESIEVE_VERSION_PATCH 0 |
| #define | PRIMESIEVE_ERROR ((uint64_t) ~((uint64_t) 0)) |
| primesieve functions return PRIMESIEVE_ERROR (UINT64_MAX) if any error occurs. | |
Enumerations | |
| enum | { MAX_THREADS = - 1, SHORT_PRIMES, USHORT_PRIMES, INT_PRIMES, UINT_PRIMES, LONG_PRIMES, ULONG_PRIMES, LONGLONG_PRIMES, ULONGLONG_PRIMES, INT16_PRIMES, UINT16_PRIMES, INT32_PRIMES, UINT32_PRIMES, INT64_PRIMES, UINT64_PRIMES } |
Functions | |
| void * | primesieve_generate_primes (uint64_t start, uint64_t stop, size_t *size, int type) |
| Get an array with the primes inside the interval [start, stop]. More... | |
| void * | primesieve_generate_n_primes (uint64_t n, uint64_t start, int type) |
| Get an array with the first n primes >= start. More... | |
| uint64_t | primesieve_nth_prime (int64_t n, uint64_t start) |
| Find the nth prime. More... | |
| uint64_t | primesieve_parallel_nth_prime (int64_t n, uint64_t start) |
| Find the nth prime in parallel. More... | |
| uint64_t | primesieve_count_primes (uint64_t start, uint64_t stop) |
| Count the primes within the interval [start, stop]. More... | |
| uint64_t | primesieve_count_twins (uint64_t start, uint64_t stop) |
| Count the twin primes within the interval [start, stop]. More... | |
| uint64_t | primesieve_count_triplets (uint64_t start, uint64_t stop) |
| Count the prime triplets within the interval [start, stop]. More... | |
| uint64_t | primesieve_count_quadruplets (uint64_t start, uint64_t stop) |
| Count the prime quadruplets within the interval [start, stop]. More... | |
| uint64_t | primesieve_count_quintuplets (uint64_t start, uint64_t stop) |
| Count the prime quintuplets within the interval [start, stop]. More... | |
| uint64_t | primesieve_count_sextuplets (uint64_t start, uint64_t stop) |
| Count the prime sextuplets within the interval [start, stop]. More... | |
| uint64_t | primesieve_parallel_count_primes (uint64_t start, uint64_t stop) |
| Count the primes within the interval [start, stop] in parallel. More... | |
| uint64_t | primesieve_parallel_count_twins (uint64_t start, uint64_t stop) |
| Count the twin primes within the interval [start, stop] in parallel. More... | |
| uint64_t | primesieve_parallel_count_triplets (uint64_t start, uint64_t stop) |
| Count the prime triplets within the interval [start, stop] in parallel. More... | |
| uint64_t | primesieve_parallel_count_quadruplets (uint64_t start, uint64_t stop) |
| Count the prime quadruplets within the interval [start, stop] in parallel. More... | |
| uint64_t | primesieve_parallel_count_quintuplets (uint64_t start, uint64_t stop) |
| Count the prime quintuplets within the interval [start, stop] in parallel. More... | |
| uint64_t | primesieve_parallel_count_sextuplets (uint64_t start, uint64_t stop) |
| Count the prime sextuplets within the interval [start, stop] in parallel. More... | |
| void | primesieve_print_primes (uint64_t start, uint64_t stop) |
| Print the primes within the interval [start, stop] to the standard output. More... | |
| void | primesieve_print_twins (uint64_t start, uint64_t stop) |
| Print the twin primes within the interval [start, stop] to the standard output. More... | |
| void | primesieve_print_triplets (uint64_t start, uint64_t stop) |
| Print the prime triplets within the interval [start, stop] to the standard output. More... | |
| void | primesieve_print_quadruplets (uint64_t start, uint64_t stop) |
| Print the prime quadruplets within the interval [start, stop] to the standard output. More... | |
| void | primesieve_print_quintuplets (uint64_t start, uint64_t stop) |
| Print the prime quintuplets within the interval [start, stop] to the standard output. More... | |
| void | primesieve_print_sextuplets (uint64_t start, uint64_t stop) |
| Print the prime sextuplets within the interval [start, stop] to the standard output. More... | |
| void | primesieve_callback_primes (uint64_t start, uint64_t stop, void(*callback)(uint64_t prime)) |
| Call back the primes within the interval [start, stop]. More... | |
| int | primesieve_get_sieve_size () |
| Get the current set sieve size in kilobytes. More... | |
| int | primesieve_get_num_threads () |
| Get the current set number of threads. More... | |
| uint64_t | primesieve_get_max_stop () |
| Returns the largest valid stop number for primesieve. More... | |
| void | primesieve_set_sieve_size (int sieve_size) |
| Set the sieve size in kilobytes. More... | |
| void | primesieve_set_num_threads (int num_threads) |
| Set the number of threads for use in subsequent primesieve_parallel_* function calls. More... | |
| void | primesieve_free (void *primes) |
| Deallocate a primes array created using the primesieve_generate_primes() or primesieve_generate_n_primes() functions. | |
| int | primesieve_test () |
| Run extensive correctness tests. More... | |
| const char * | primesieve_version () |
| Get the primesieve version number, in the form “i.j.k”. More... | |
primesieve C API.
primesieve is a library for fast prime number generation. In case an error occurs errno is set to EDOM and PRIMESIEVE_ERROR is returned.
Copyright (C) 2015 Kim Walisch, kim.walisch@gmail.com
This file is distributed under the BSD License.
| anonymous enum |
| void primesieve_callback_primes | ( | uint64_t | start, |
| uint64_t | stop, | ||
| void(*)(uint64_t prime) | callback | ||
| ) |
Call back the primes within the interval [start, stop].
| callback | A callback function. |
| uint64_t primesieve_count_primes | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the primes within the interval [start, stop].
| uint64_t primesieve_count_quadruplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the prime quadruplets within the interval [start, stop].
| uint64_t primesieve_count_quintuplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the prime quintuplets within the interval [start, stop].
| uint64_t primesieve_count_sextuplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the prime sextuplets within the interval [start, stop].
| uint64_t primesieve_count_triplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the prime triplets within the interval [start, stop].
| uint64_t primesieve_count_twins | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the twin primes within the interval [start, stop].
| void* primesieve_generate_n_primes | ( | uint64_t | n, |
| uint64_t | start, | ||
| int | type | ||
| ) |
Get an array with the first n primes >= start.
| type | The type of the primes to generate, e.g. INT_PRIMES. |
| void* primesieve_generate_primes | ( | uint64_t | start, |
| uint64_t | stop, | ||
| size_t * | size, | ||
| int | type | ||
| ) |
Get an array with the primes inside the interval [start, stop].
| size | The size of the returned primes array. |
| type | The type of the primes to generate, e.g. INT_PRIMES. |
| uint64_t primesieve_get_max_stop | ( | ) |
Returns the largest valid stop number for primesieve.
| int primesieve_get_num_threads | ( | ) |
Get the current set number of threads.
| int primesieve_get_sieve_size | ( | ) |
Get the current set sieve size in kilobytes.
| uint64_t primesieve_nth_prime | ( | int64_t | n, |
| uint64_t | start | ||
| ) |
Find the nth prime.
| n | if n = 0 finds the 1st prime >= start, if n > 0 finds the nth prime > start, if n < 0 finds the nth prime < start (backwards). |
| uint64_t primesieve_parallel_count_primes | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the primes within the interval [start, stop] in parallel.
By default all CPU cores are used, use primesieve_set_num_threads(int) to change the number of threads.
| uint64_t primesieve_parallel_count_quadruplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the prime quadruplets within the interval [start, stop] in parallel.
By default all CPU cores are used, use primesieve_set_num_threads(int) to change the number of threads.
| uint64_t primesieve_parallel_count_quintuplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the prime quintuplets within the interval [start, stop] in parallel.
By default all CPU cores are used, use primesieve_set_num_threads(int) to change the number of threads.
| uint64_t primesieve_parallel_count_sextuplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the prime sextuplets within the interval [start, stop] in parallel.
By default all CPU cores are used, use primesieve_set_num_threads(int) to change the number of threads.
| uint64_t primesieve_parallel_count_triplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the prime triplets within the interval [start, stop] in parallel.
By default all CPU cores are used, use primesieve_set_num_threads(int) to change the number of threads.
| uint64_t primesieve_parallel_count_twins | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Count the twin primes within the interval [start, stop] in parallel.
By default all CPU cores are used, use primesieve_set_num_threads(int) to change the number of threads.
| uint64_t primesieve_parallel_nth_prime | ( | int64_t | n, |
| uint64_t | start | ||
| ) |
Find the nth prime in parallel.
By default all CPU cores are used, use primesieve_set_num_threads(int) to change the number of threads.
| n | if n = 0 finds the 1st prime >= start, if n > 0 finds the nth prime > start, if n < 0 finds the nth prime < start (backwards). |
| void primesieve_print_primes | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Print the primes within the interval [start, stop] to the standard output.
| void primesieve_print_quadruplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Print the prime quadruplets within the interval [start, stop] to the standard output.
| void primesieve_print_quintuplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Print the prime quintuplets within the interval [start, stop] to the standard output.
| void primesieve_print_sextuplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Print the prime sextuplets within the interval [start, stop] to the standard output.
| void primesieve_print_triplets | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Print the prime triplets within the interval [start, stop] to the standard output.
| void primesieve_print_twins | ( | uint64_t | start, |
| uint64_t | stop | ||
| ) |
Print the twin primes within the interval [start, stop] to the standard output.
| void primesieve_set_num_threads | ( | int | num_threads | ) |
Set the number of threads for use in subsequent primesieve_parallel_* function calls.
Note that this only changes the number of threads for the current process.
| num_threads | Number of threads for sieving or MAX_THREADS to use all CPU cores. |
| void primesieve_set_sieve_size | ( | int | sieve_size | ) |
Set the sieve size in kilobytes.
The best sieving performance is achieved with a sieve size of your CPU's L1 data cache size (per core). For sieving >= 10^17 a sieve size of your CPU's L2 cache size sometimes performs better.
| sieve_size | Sieve size in kilobytes. |
| int primesieve_test | ( | ) |
Run extensive correctness tests.
The tests last about one minute on a quad core CPU from 2013 and use up to 1 gigabyte of memory.
| const char* primesieve_version | ( | ) |
Get the primesieve version number, in the form “i.j.k”.
1.8.9.1