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 110 of file ntheory.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 561 of file ntheory.cpp.

562 {
563  _extend(limit);
564  auto it = std::upper_bound(_primes.begin(), _primes.end(), limit);
565  // find the first position greater than limit and reserve space for the
566  // primes
567  primes.reserve(it - _primes.begin());
568  std::copy(_primes.begin(), it, std::back_inserter(primes));
569  if (_clear)
570  clear();
571 }
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: