LatMRG Guide  1.0
A software package to test and search for new linear congruential random number generators
LatMRG::Primes< Int > Class Template Reference

This class provides methods to search for integers \(m\) that are prime, for which the integer \(r = (m^k-1)/(m-1)\) is also prime for a given \(k\), and possibly for which \((m-1)/2\) is also prime. More...

#include <latmrg/Primes.h>

Public Member Functions

 Primes ()
 Constructor. More...
 
 ~Primes ()
 Destructor. More...
 
void find (int e, int s, bool facto, std::ostream &fout)
 Finds \(s\) prime integers \(m<2^e\) that are closest to \(2^e\). More...
 
void find (int k, int e, int s, bool safe, bool facto, std::ostream &fout)
 Finds \(s\) prime integers \(m<2^e\) that are closest to \(2^e\), such that \(m\) and \(r = (m^k-1)/(m-1)\) are prime. More...
 
void find (int k, int e, long c1, long c2, bool safe, bool facto, std::ostream &fout)
 Finds all integers \(m\), in \(2^e + c_1 \le m \le2^e + c_2\), such that \(m\) and \(r = (m^k-1)/(m-1)\) are prime. More...
 

Public Attributes

bool print_time = true
 Used by the main executable to compare the examples. More...
 

Private Member Functions

void find (int k, int e, int s, const Int &S1, const Int &S2, bool safe, bool facto, std::ostream &fout)
 This is the general purpose function used by this program. More...
 
void nextM (Int &m)
 
void writeFooter (std::ostream &fout)
 Writes the CPU time of the find to the stream fout. More...
 
void writeHeader (int k, int e, long c1, long c2, bool safe, bool facto, std::ostream &fout)
 Writes the parameters of the find to the stream fout. More...
 

Private Attributes

Chrono timer
 

Detailed Description

template<typename Int>
class LatMRG::Primes< Int >

This class provides methods to search for integers \(m\) that are prime, for which the integer \(r = (m^k-1)/(m-1)\) is also prime for a given \(k\), and possibly for which \((m-1)/2\) is also prime.

This class solely uses probabilistic primality tests, but does it a lot of times.

Todo:
Could probably switch to a deterministic test because it is possible to do everything this class does with efficient deterministic tests for integers < 2^64 see https://math.stackexchange.com/questions/2481148/primality-testing-for-64-bit-numbers

Constructor & Destructor Documentation

◆ Primes()

template<typename Int >
LatMRG::Primes< Int >::Primes ( )

Constructor.

◆ ~Primes()

template<typename Int >
LatMRG::Primes< Int >::~Primes ( )

Destructor.

Member Function Documentation

◆ find() [1/4]

template<typename Int >
void LatMRG::Primes< Int >::find ( int  e,
int  s,
bool  facto,
std::ostream &  fout 
)

Finds \(s\) prime integers \(m<2^e\) that are closest to \(2^e\).

If facto is true, then \(m-1\) is factorized in its prime factors. The results are printed on stream fout.

◆ find() [2/4]

template<typename Int >
void LatMRG::Primes< Int >::find ( int  k,
int  e,
int  s,
bool  safe,
bool  facto,
std::ostream &  fout 
)

Finds \(s\) prime integers \(m<2^e\) that are closest to \(2^e\), such that \(m\) and \(r = (m^k-1)/(m-1)\) are prime.

If safe is true, \((m-1)/2\) is also required to be prime. The results are printed on stream fout. If facto is true, then \(m-1\) is factorized in its prime factors. If \(k=1\), \(r\) is considered to be prime.

◆ find() [3/4]

template<typename Int >
void LatMRG::Primes< Int >::find ( int  k,
int  e,
long  c1,
long  c2,
bool  safe,
bool  facto,
std::ostream &  fout 
)

Finds all integers \(m\), in \(2^e + c_1 \le m \le2^e + c_2\), such that \(m\) and \(r = (m^k-1)/(m-1)\) are prime.

If safe is true, \((m-1)/2\) is also required to be prime. The results are printed on stream fout. If facto is true, then \(m-1\) is factorized in prime factors. If \(k=1\), \(r\) is considered to be prime.

◆ find() [4/4]

template<typename Int >
void LatMRG::Primes< Int >::find ( int  k,
int  e,
int  s,
const Int &  S1,
const Int &  S2,
bool  safe,
bool  facto,
std::ostream &  fout 
)
private

This is the general purpose function used by this program.

This method searches for s prime integers between S1 and S2.

◆ nextM()

template<typename Int >
void LatMRG::Primes< Int >::nextM ( Int &  m)
inlineprivate

◆ writeFooter()

template<typename Int >
void LatMRG::Primes< Int >::writeFooter ( std::ostream &  fout)
private

Writes the CPU time of the find to the stream fout.

◆ writeHeader()

template<typename Int >
void LatMRG::Primes< Int >::writeHeader ( int  k,
int  e,
long  c1,
long  c2,
bool  safe,
bool  facto,
std::ostream &  fout 
)
private

Writes the parameters of the find to the stream fout.

Member Data Documentation

◆ print_time

template<typename Int >
bool LatMRG::Primes< Int >::print_time = true

Used by the main executable to compare the examples.

◆ timer

template<typename Int >
Chrono LatMRG::Primes< Int >::timer
private

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