diff --git a/docs/AllClasses.html b/docs/AllClasses.html index c17ab90..dddc51b 100644 --- a/docs/AllClasses.html +++ b/docs/AllClasses.html @@ -20,7 +20,9 @@
primesieve_iterator allows to easily iterate over primes both forwards and backwards. Generating the first prime has a complexity of O(r log log r) operations with r = nˆ0.5, after that any additional prime is generated in amortized O(log n log log n) operations. The memory usage is about PrimePi(nˆ0.5) * 8 bytes. + +
The primesieve_iterator.pas example shows how to use primesieve_iterator. If any error occurs primesieve_next_prime() and primesieve_prev_prime() return PRIMESIEVE_ERROR. Furthermore primesieve_iterator.is_error is initialized to 0 and set to 1 if any error occurs.
Generate primes of int16_t type
Generate primes of Int16 (c int16_t) type
Generate primes of int32_t type
Generate primes of Int32 (c int32_t) type
Generate primes of int64_t type
Generate primes of Int64 (c int64_t) type
Generate primes of uint16_t type
Generate primes of UInt16 (c uint16_t) type
Generate primes of uint32_t type
Generate primes of UInt32 (c uint32_t) type
Generate primes of uint64_t type
Generate primes of UInt64 (c uint64_t) type
primesieve functions return PRIMESIEVE_ERROR (UINT64_MAX) if any error occurs.
primesieve functions return PRIMESIEVE_ERROR (UINT64_MAX) if any error occurs.
Pascal API version
Get the next prime. -
Returns UINT64_MAX if next prime > 2ˆ64.
Returns UINT64_MAX if next prime > 2ˆ64.
Get the previous prime. -
primesieve_prev_prime(n) returns 0 for n <= 2. Note that primesieve_next_prime() runs up to 2x faster than primesieve_prev_prime(). Hence if the same algorithm can be written using either primesieve_prev_prime() or primesieve_next_prime() it is preferable to use primesieve_next_prime().
primesieve_prev_prime(n) returns 0 for n <= 2. Note that primesieve_next_prime() runs up to 2x faster than primesieve_prev_prime(). Hence if the same algorithm can be written using either primesieve_prev_prime() or primesieve_next_prime() it is preferable to use primesieve_next_prime().
Generate primes of int16_t type
Generate primes of Int16 (c int16_t) type
Generate primes of int32_t type
Generate primes of Int32 (c int32_t) type
Generate primes of int64_t type
Generate primes of Int64 (c int64_t) type
Count the primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. +
Count the primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. -
Note that each call to primesieve_count_primes() incurs an initialization overhead of O(sqrt(stop)) even if the interval [start, stop] is tiny. Hence if you have written an algorithm that makes many calls to primesieve_count_primes() it may be preferable to use a primesieve::iterator which needs to be initialized only once.
Note that each call to primesieve_count_primes() incurs an initialization overhead of O(sqrt(stop)) even if the interval [start, stop] is tiny. Hence if you have written an algorithm that makes many calls to primesieve_count_primes() it may be preferable to use a primesieve_iterator which needs to be initialized only once.
Count the prime quadruplets within the interval [start, stop]. -
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Count the prime quintuplets within the interval [start, stop]. -
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Count the prime sextuplets within the interval [start, stop]. -
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Count the prime triplets within the interval [start, stop]. -
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Count the twin primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Count the twin primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Deallocate a primes array created using the primesieve_generate_primes() or primesieve_generate_n_primes() functions.
Deallocate a primes array created using the primesieve_generate_primes() or primesieve_generate_n_primes() functions.
Get an array with the first n primes >= start. +
Get an array with the first n primes >= start. -
ptype
- The type of the primes to generate, e.g. INT_PRIMES.
ptype
- The type of the primes to generate, e.g. INT_PRIMES.
Get an array with the primes inside the interval [start, stop]. -
size
- The size of the returned primes array.
ptype
- The type of the primes to generate, e.g. INT_PRIMES.
size
- The size of the returned primes array.
ptype
- The type of the primes to generate, e.g. INT_PRIMES.
Returns the largest valid stop number for primesieve. -
- -2ˆ64-1 (UINT64_MAX)- -
2ˆ64-1 (UINT64_MAX)
primesieve_iterator allows to easily iterate over primes both forwards and backwards. Generating the first prime has a complexity of O(r log log r) operations with r = nˆ0.5, after that any additional prime is generated in amortized O(log n log log n) operations. The memory usage is about PrimePi(nˆ0.5) * 8 bytes. + +
The primesieve_iterator.pas example shows how to use primesieve_iterator. If any error occurs primesieve_next_prime() and primesieve_prev_prime() return PRIMESIEVE_ERROR. Furthermore primesieve_iterator.is_error is initialized to 0 and set to 1 if any error occurs.
Get the next prime. -
Returns UINT64_MAX if next prime > 2ˆ64.
Returns UINT64_MAX if next prime > 2ˆ64.
Find the nth prime. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. +
Find the nth prime. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. -
Note that each call to primesieve_nth_prime(n, start) incurs an initialization overhead of O(sqrt(start)) even if n is tiny. Hence it is not a good idea to use primesieve_nth_prime() repeatedly in a loop to get the next (or previous) prime. For this use case it is better to use a primesieve::iterator which needs to be initialized only once. +
Note that each call to primesieve_nth_prime(n, start) incurs an initialization overhead of O(sqrt(start)) even if n is tiny. Hence it is not a good idea to use primesieve_nth_prime() repeatedly in a loop to get the next (or previous) prime. For this use case it is better to use a primesieve_iterator which needs to be initialized only once. -
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).
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).
Get the previous prime. -
primesieve_prev_prime(n) returns 0 for n <= 2. Note that primesieve_next_prime() runs up to 2x faster than primesieve_prev_prime(). Hence if the same algorithm can be written using either primesieve_prev_prime() or primesieve_next_prime() it is preferable to use primesieve_next_prime().
primesieve_prev_prime(n) returns 0 for n <= 2. Note that primesieve_next_prime() runs up to 2x faster than primesieve_prev_prime(). Hence if the same algorithm can be written using either primesieve_prev_prime() or primesieve_next_prime() it is preferable to use primesieve_next_prime().
Set the number of threads for use in primesieve_count_*() and primesieve_nth_prime(). By default all CPU cores are used.
Set the number of threads for use in primesieve_count_*() and primesieve_nth_prime(). By default all CPU cores are used.
Set the sieve size in KiB (kibibyte). The best sieving performance is achieved with a sieve size of your CPU's L1 or L2 cache size (per core).
- -sieve_size >= 8 && <= 4096- -
Set the sieve size in KiB (kibibyte). The best sieving performance is achieved with a sieve size of your CPU's L1 or L2 cache size (per core). sieve_size >= 8 && <= 4096
Reset the primesieve iterator to start. -
start
- Generate primes > start (or < start).
+
start
- Generate primes > start (or < start).
-
stop_hint
- Stop number optimization hint. E.g. if you want to generate the primes below 1000 use stop_hint = 1000, if you don't know use primesieve_get_max_stop().
stop_hint
- Stop number optimization hint. E.g. if you want to generate the primes below 1000 use stop_hint = 1000, if you don't know use primesieve_get_max_stop().
Generate primes of uint16_t type
Generate primes of UInt16 (c uint16_t) type
Generate primes of uint32_t type
Generate primes of UInt32 (c uint32_t) type
Generate primes of uint64_t type
Generate primes of UInt64 (c uint64_t) type
primesieve functions return PRIMESIEVE_ERROR (UINT64_MAX) if any error occurs.
primesieve functions return PRIMESIEVE_ERROR (UINT64_MAX) if any error occurs.
Pascal API version
Count the primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. +
Count the primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. -
Note that each call to primesieve_count_primes() incurs an initialization overhead of O(sqrt(stop)) even if the interval [start, stop] is tiny. Hence if you have written an algorithm that makes many calls to primesieve_count_primes() it may be preferable to use a primesieve::iterator which needs to be initialized only once.
Note that each call to primesieve_count_primes() incurs an initialization overhead of O(sqrt(stop)) even if the interval [start, stop] is tiny. Hence if you have written an algorithm that makes many calls to primesieve_count_primes() it may be preferable to use a primesieve_iterator which needs to be initialized only once.
Count the prime quadruplets within the interval [start, stop]. -
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Count the prime quintuplets within the interval [start, stop]. -
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Count the prime sextuplets within the interval [start, stop]. -
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Count the prime triplets within the interval [start, stop]. -
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Count the twin primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Count the twin primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads.
Deallocate a primes array created using the primesieve_generate_primes() or primesieve_generate_n_primes() functions.
Deallocate a primes array created using the primesieve_generate_primes() or primesieve_generate_n_primes() functions.
Get an array with the first n primes >= start. +
Get an array with the first n primes >= start. -
ptype
- The type of the primes to generate, e.g. INT_PRIMES.
ptype
- The type of the primes to generate, e.g. INT_PRIMES.
Get an array with the primes inside the interval [start, stop]. -
size
- The size of the returned primes array.
ptype
- The type of the primes to generate, e.g. INT_PRIMES.
size
- The size of the returned primes array.
ptype
- The type of the primes to generate, e.g. INT_PRIMES.
Returns the largest valid stop number for primesieve. -
- -2ˆ64-1 (UINT64_MAX)- -
2ˆ64-1 (UINT64_MAX)
Find the nth prime. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. +
Find the nth prime. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. -
Note that each call to primesieve_nth_prime(n, start) incurs an initialization overhead of O(sqrt(start)) even if n is tiny. Hence it is not a good idea to use primesieve_nth_prime() repeatedly in a loop to get the next (or previous) prime. For this use case it is better to use a primesieve::iterator which needs to be initialized only once. +
Note that each call to primesieve_nth_prime(n, start) incurs an initialization overhead of O(sqrt(start)) even if n is tiny. Hence it is not a good idea to use primesieve_nth_prime() repeatedly in a loop to get the next (or previous) prime. For this use case it is better to use a primesieve_iterator which needs to be initialized only once. -
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).
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).
Set the number of threads for use in primesieve_count_*() and primesieve_nth_prime(). By default all CPU cores are used.
Set the number of threads for use in primesieve_count_*() and primesieve_nth_prime(). By default all CPU cores are used.
Set the sieve size in KiB (kibibyte). The best sieving performance is achieved with a sieve size of your CPU's L1 or L2 cache size (per core).
- -sieve_size >= 8 && <= 4096- -
Set the sieve size in KiB (kibibyte). The best sieving performance is achieved with a sieve size of your CPU's L1 or L2 cache size (per core). sieve_size >= 8 && <= 4096
Reset the primesieve iterator to start. -
start
- Generate primes > start (or < start).
+
start
- Generate primes > start (or < start).
-
stop_hint
- Stop number optimization hint. E.g. if you want to generate the primes below 1000 use stop_hint = 1000, if you don't know use primesieve_get_max_stop().
stop_hint
- Stop number optimization hint. E.g. if you want to generate the primes below 1000 use stop_hint = 1000, if you don't know use primesieve_get_max_stop().
Get the next prime. -
Returns UINT64_MAX if next prime > 2ˆ64.
+Returns UINT64_MAX if next prime > 2ˆ64.
_PRIMESIEVE_PAS_VERSION = '0.2'; |
- |
-primesieve functions return PRIMESIEVE_ERROR (UINT64_MAX) if any error occurs. +primesieve functions return PRIMESIEVE_ERROR (UINT64_MAX) if any error occurs. |
-Generate primes of int16_t type +Generate primes of Int16 (c int16_t) type |
-Generate primes of uint16_t type +Generate primes of UInt16 (c uint16_t) type |
-Generate primes of int32_t type +Generate primes of Int32 (c int32_t) type |
-Generate primes of uint32_t type +Generate primes of UInt32 (c uint32_t) type |
-Generate primes of int64_t type +Generate primes of Int64 (c int64_t) type |
-Generate primes of uint64_t type +Generate primes of UInt64 (c uint64_t) type |
Get an array with the primes inside the interval [start, stop]. -
size
- The size of the returned primes array.
ptype
- The type of the primes to generate, e.g. INT_PRIMES.
size
- The size of the returned primes array.
ptype
- The type of the primes to generate, e.g. INT_PRIMES.
-Get an array with the first n primes >= start. +Get an array with the first n primes >= start. -
|
-Find the nth prime. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. +Find the nth prime. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. - Note that each call to primesieve_nth_prime(n, start) incurs an initialization overhead of O(sqrt(start)) even if n is tiny. Hence it is not a good idea to use primesieve_nth_prime() repeatedly in a loop to get the next (or previous) prime. For this use case it is better to use a primesieve::iterator which needs to be initialized only once. + Note that each call to primesieve_nth_prime(n, start) incurs an initialization overhead of O(sqrt(start)) even if n is tiny. Hence it is not a good idea to use primesieve_nth_prime() repeatedly in a loop to get the next (or previous) prime. For this use case it is better to use a primesieve_iterator which needs to be initialized only once. - if n = 0 finds the 1st prime >= start, if n = 0 finds the 1st prime >= start, |
-Count the primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. +Count the primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. - Note that each call to primesieve_count_primes() incurs an initialization overhead of O(sqrt(stop)) even if the interval [start, stop] is tiny. Hence if you have written an algorithm that makes many calls to primesieve_count_primes() it may be preferable to use a primesieve::iterator which needs to be initialized only once. +Note that each call to primesieve_count_primes() incurs an initialization overhead of O(sqrt(stop)) even if the interval [start, stop] is tiny. Hence if you have written an algorithm that makes many calls to primesieve_count_primes() it may be preferable to use a primesieve_iterator which needs to be initialized only once. |
-Count the twin primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. +Count the twin primes within the interval [start, stop]. By default all CPU cores are used, use primesieve_set_num_threads(int threads) to change the number of threads. |
-Set the sieve size in KiB (kibibyte). The best sieving performance is achieved with a sieve size of your CPU's L1 or L2 cache size (per core). - -sieve_size >= 8 && <= 4096- - +Set the sieve size in KiB (kibibyte). The best sieving performance is achieved with a sieve size of your CPU's L1 or L2 cache size (per core). sieve_size >= 8 && <= 4096 |
-Set the number of threads for use in primesieve_count_*() and primesieve_nth_prime(). By default all CPU cores are used. +Set the number of threads for use in primesieve_count_*() and primesieve_nth_prime(). By default all CPU cores are used. |
-Deallocate a primes array created using the primesieve_generate_primes() or primesieve_generate_n_primes() functions. +Deallocate a primes array created using the primesieve_generate_primes() or primesieve_generate_n_primes() functions. |
type primesieve_iterator = record
+primesieve_iterator allows to easily iterate over primes both forwards and backwards. Generating the first prime has a complexity of O(r log log r) operations with r = nˆ0.5, after that any additional prime is generated in amortized O(log n log log n) operations. The memory usage is about PrimePi(nˆ0.5) * 8 bytes. + +
The primesieve_iterator.pas example shows how to use primesieve_iterator. If any error occurs primesieve_next_prime() and primesieve_prev_prime() return PRIMESIEVE_ERROR. Furthermore primesieve_iterator.is_error is initialized to 0 and set to 1 if any error occurs.
+