SymEngine::Sieve Class Reference
+ Collaboration diagram for SymEngine::Sieve:

Data Structures

class  iterator
 

Static Public Member Functions

static void generate_primes (std::vector< unsigned > &primes, unsigned limit)
 
static void clear ()
 
static void set_sieve_size (unsigned size)
 
static void set_clear (bool clear)
 

Static Private Member Functions

static void _extend (unsigned limit)
 

Static Private Attributes

static std::vector< unsigned > _primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29}
 
static unsigned _sieve_size = 32 * 1024 * 8
 
static bool _clear = true
 

Detailed Description

Definition at line 18 of file prime_sieve.h.

Member Function Documentation

◆ generate_primes()

void SymEngine::Sieve::generate_primes ( std::vector< unsigned > &  primes,
unsigned  limit 
)
static
Parameters
primesholds all primes up to the limit (including).

Definition at line 77 of file prime_sieve.cpp.

78 {
79  _extend(limit);
80  auto it = std::upper_bound(_primes.begin(), _primes.end(), limit);
81  // find the first position greater than limit and reserve space for the
82  // primes
83  primes.reserve(it - _primes.begin());
84  std::copy(_primes.begin(), it, std::back_inserter(primes));
85  if (_clear)
86  clear();
87 }
T back_inserter(T... args)
T begin(T... args)
T copy(T... args)
T end(T... args)
T reserve(T... args)
T upper_bound(T... args)

The documentation for this class was generated from the following files: