primesieve  7.4
primesieve Namespace Reference

Contains primesieve's C++ functions and classes. More...

Classes

class  iterator
primesieve::iterator allows to easily iterate over primes both forwards and backwards. More...

class  primesieve_error
primesieve throws a primesieve_error exception if an error occurs e.g. More...

Functions

template<typename T >
void generate_primes (uint64_t stop, std::vector< T > *primes)
Store the primes <= stop in the primes vector.

template<typename T >
void generate_primes (uint64_t start, uint64_t stop, std::vector< T > *primes)
Store the primes within the interval [start, stop] in the primes vector.

template<typename T >
void generate_n_primes (uint64_t n, std::vector< T > *primes)
Store the first n primes in the primes vector.

template<typename T >
void generate_n_primes (uint64_t n, uint64_t start, std::vector< T > *primes)
Store the first n primes >= start in the primes vector.

uint64_t nth_prime (int64_t n, uint64_t start=0)
Find the nth prime. More...

uint64_t count_primes (uint64_t start, uint64_t stop)
Count the primes within the interval [start, stop]. More...

uint64_t count_twins (uint64_t start, uint64_t stop)
Count the twin primes within the interval [start, stop]. More...

uint64_t count_triplets (uint64_t start, uint64_t stop)
Count the prime triplets within the interval [start, stop]. More...

uint64_t count_quadruplets (uint64_t start, uint64_t stop)
Count the prime quadruplets within the interval [start, stop]. More...

uint64_t count_quintuplets (uint64_t start, uint64_t stop)
Count the prime quintuplets within the interval [start, stop]. More...

uint64_t count_sextuplets (uint64_t start, uint64_t stop)
Count the prime sextuplets within the interval [start, stop]. More...

void print_primes (uint64_t start, uint64_t stop)
Print the primes within the interval [start, stop] to the standard output.

void print_twins (uint64_t start, uint64_t stop)
Print the twin primes within the interval [start, stop] to the standard output.

void print_triplets (uint64_t start, uint64_t stop)
Print the prime triplets within the interval [start, stop] to the standard output.

void print_quadruplets (uint64_t start, uint64_t stop)
Print the prime quadruplets within the interval [start, stop] to the standard output.

void print_quintuplets (uint64_t start, uint64_t stop)
Print the prime quintuplets within the interval [start, stop] to the standard output.

void print_sextuplets (uint64_t start, uint64_t stop)
Print the prime sextuplets within the interval [start, stop] to the standard output.

uint64_t get_max_stop ()
Returns the largest valid stop number for primesieve. More...

int get_sieve_size ()
Get the current set sieve size in KiB.

Get the current set number of threads.

void set_sieve_size (int sieve_size)
Set the sieve size in KiB (kibibyte). More...

Set the number of threads for use in primesieve::count_*() and primesieve::nth_prime(). More...

std::string primesieve_version ()
Get the primesieve version number, in the form “i.j”.

Detailed Description

Contains primesieve's C++ functions and classes.

◆ count_primes()

 uint64_t primesieve::count_primes ( uint64_t start, uint64_t stop )

Count the primes within the interval [start, stop].

Examples:
count_primes.cpp.

 uint64_t primesieve::count_quadruplets ( uint64_t start, uint64_t stop )

Count the prime quadruplets within the interval [start, stop].

◆ count_quintuplets()

 uint64_t primesieve::count_quintuplets ( uint64_t start, uint64_t stop )

Count the prime quintuplets within the interval [start, stop].

◆ count_sextuplets()

 uint64_t primesieve::count_sextuplets ( uint64_t start, uint64_t stop )

Count the prime sextuplets within the interval [start, stop].

◆ count_triplets()

 uint64_t primesieve::count_triplets ( uint64_t start, uint64_t stop )

Count the prime triplets within the interval [start, stop].

◆ count_twins()

 uint64_t primesieve::count_twins ( uint64_t start, uint64_t stop )

Count the twin primes within the interval [start, stop].

◆ get_max_stop()

 uint64_t primesieve::get_max_stop ( )

Returns the largest valid stop number for primesieve.

Returns
2^64-1 (UINT64_MAX).

◆ nth_prime()

 uint64_t primesieve::nth_prime ( int64_t n, uint64_t start = `0` )

Find the nth prime.

Parameters
 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).
Examples:
nth_prime.cpp.

Set the number of threads for use in primesieve::count_*() and primesieve::nth_prime().

By default all CPU cores are used.

◆ set_sieve_size()

 void primesieve::set_sieve_size ( int sieve_size )

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).

Precondition
sieve_size >= 8 && <= 4096.