Regina Calculation Engine
|
A helper class for finding primes and factorising integers. More...
#include <maths/primes.h>
Static Public Member Functions | |
static unsigned long | size () |
Returns the number of primes (or suspected primes) currently stored. More... | |
static Integer | prime (unsigned long which, bool autoGrow=true) |
Returns the requested prime (or suspected prime). More... | |
static std::vector< Integer > | primeDecomp (const Integer &n) |
Returns the prime factorisation of the given integer as a list of individual primes (or suspected primes). More... | |
static std::vector< std::pair< Integer, unsigned long > > | primePowerDecomp (const Integer &n) |
Returns the prime factorisation of the given integer as a list of prime powers (or suspected prime powers). More... | |
A helper class for finding primes and factorising integers.
This class has two functions: (i) to maintain a list of known primes, and (ii) to use this list to factorise integers into prime factors.
The primes stored by this class will always be the smallest k suspected primes, where k may grow dynamically as the program runs. Specifically:
This list is used by the high-level factorisation routines in this class, such as primeDecomp() and primePowerDecomp(). For users only interested in these high-level routines, there is no need to worry about the size of the list; the high-level routines will extend it if necessary.
Although this class makes use of global data in its implementation, all of its methods are thread-safe.