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>
|  | 
|  | 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... 
 | 
|  | 
|  | 
| 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...
 | 
|  | 
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 
◆ Primes()
◆ ~Primes()
◆ 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()
◆ writeFooter()
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. 
 
 
◆ print_time
Used by the main executable to compare the examples. 
 
 
◆ timer
The documentation for this class was generated from the following file: