LatMRG Guide
1.0
A software package to test and search for new linear congruential random number generators
|
This class is used to to test for full period length of generators and also to store a bit of information about generators without creating a lattice. More...
#include <latmrg/MRGComponent.h>
Public Member Functions | |
MRGComponent (const Int &m, int k, DecompType decom1, const char *filem1, DecompType decor, const char *filer) | |
Constructor with modulus \(m\) and order \(k\). More... | |
MRGComponent (Int b, int e, Int r, int k, DecompType decom1, const char *filem1, DecompType decor, const char *filer) | |
Same as the other constructors with m=b^e+r . More... | |
MRGComponent (Modulus< Int > &modul, int k, DecompType decom1, const char *filem1, DecompType decor, const char *filer) | |
Constructor similar to the above, except that the modulus of congruence \(m\) is inside the object modul . More... | |
MRGComponent (const MRGComponent< Int > &comp) | |
Copy constructor;. More... | |
~MRGComponent () | |
Destructor. More... | |
GenType | get_type () |
Gets the type of this component. More... | |
IntVec | getA () const |
Gets the multipliers of the recurrence to \(A\). More... | |
Int & | getB () |
Returns the value of b with b^e+r = m . More... | |
int & | getE () |
Returns the value of e with b^e+r = m . More... | |
int | getK () const |
Returns the value of the modulus \(m\) of the recurrence. More... | |
const Int | getM () const |
Returns the value of the modulus \(m\) of the recurrence. More... | |
IntMat | getMatrix () const |
Gets the matrix multipliers of the recurrence. More... | |
IntVec & | getOrbitSeed () |
Returns const reference of orbitSeed. More... | |
Int & | getR () |
Returns the value of r with b^e+r = m . More... | |
bool | maxPeriod (const IntVec &A) |
Returns true if coefficients \(A\) give a MRG with maximal period; returns false otherwise. More... | |
bool | maxPeriod (const Int &a) |
Returns true if \(a\) makes for a full period LCG with non-zero carry; returns false otherwise. More... | |
bool | maxPeriod (const IntMat &A) |
Returns true if coefficients in \(A\) give a MMRG with maximal period; returns false otherwise. More... | |
bool | maxPeriod23 (const IntVec &A) |
Returns true if coefficients \(A\) give a MRG with maximal period; returns false otherwise. More... | |
MRGComponent< Int > & | operator= (const MRGComponent< Int > &comp) |
Assignment operator. More... | |
void | set_type (GenType type) |
Sets the type of this component. More... | |
void | setA (const IntVec &A) |
Sets the multipliers of the recurrence to \(A\). More... | |
void | setA (const IntMat &A) |
Sets the matrix of the recurrence to \(A\). More... | |
void | setPower2 (std::vector< IntVec > &coeffs) |
std::string | toString () |
Returns this object as a string. More... | |
Public Attributes | |
Int | m_MWCb |
The modulo of the MWC generator if we study one. More... | |
Private Types | |
typedef NTL::matrix< Int > | IntMat |
typedef NTL::vector< Int > | IntVec |
Private Member Functions | |
void | init (const Int &m, int k, DecompType decom1, const char *filem1, DecompType decor, const char *filer) |
Does the same as the constructor above with similar arguments. More... | |
Private Attributes | |
IntFactorization< Int > | factor |
The prime factor decomposition of \(m\). More... | |
IntFactorization< Int > | ifm1 |
The prime factor decomposition of \(m-1\). More... | |
IntFactorization< NTL::ZZ > | ifm2 |
The prime factor decomposition of \(m-1\). More... | |
IntFactorization< Int > | ifr |
The prime factor decomposition of \(r=(m^k-1)/(m-1)\), where \(k\) is the order of the recurrence. More... | |
IntFactorization< NTL::ZZ > | ifr2 |
The prime factor decomposition of \(r=(m^k-1)/(m-1)\), where \(k\) is the order of the recurrence. More... | |
IntVec | m_a |
The multipliers \(a_i\) of the recurrence, \(i = 1, …, k\). More... | |
IntMat | m_A |
The generator matrix \(A\) of the recurrence for MMRG. More... | |
Int | m_b |
Basis b with b^e+r = m . More... | |
int | m_e |
Exponent e with b^e+r = m . More... | |
int | m_k |
The order \(k\) of the recurrence. More... | |
Int | m_r |
Rest r with b^e+r = m . More... | |
GenType | m_type = LCG |
The type of generator this stores. More... | |
Modulus< Int > | module |
The modulus \(m\) of the recurrence. More... | |
Int | nj |
Value needed for the calculation of the multipliers of a combined MRG. More... | |
IntVec | orbitSeed |
Contains the starting state of the component for the case when the lattice type is ORBIT . More... | |
Int | rho |
The length of the period \(\rho\) for this MRG. More... | |
This class is used to to test for full period length of generators and also to store a bit of information about generators without creating a lattice.
Each MRG component is defined by a modulus \(m\), an order \(k\) and a list of files and factorizations needed check the full period.
This class can also store
\[ x_n = (a_1 x_{n-1} + \cdots+ a_k x_{n-k}) \mbox{ mod } m \]
If it is used to check the period of another generator, the multipliers stored might change.
|
private |
|
private |
LatMRG::MRGComponent< Int >::MRGComponent | ( | const Int & | m, |
int | k, | ||
DecompType | decom1, | ||
const char * | filem1, | ||
DecompType | decor, | ||
const char * | filer | ||
) |
Constructor with modulus \(m\) and order \(k\).
Arguments decom1
and decor
refer to the prime factor decomposition of \(m-1\) and \(r=(m^k-1)/(m-1)\), respectively. If decor
equals DECOMP
, the constructor will factorize \(r\). If decor
equals DECOMP_WRITE
, the constructor will factorize \(r\) and write the prime factors to file filer
. If decor
equals DECOMP_READ
, the constructor will read the factors of \(r\) from file filer
. If decor
equals DECOMP_PRIME
, \(r\) is assumed to be prime. Similar considerations apply to decom1
and filem1
with respect to \(m-1\).
LatMRG::MRGComponent< Int >::MRGComponent | ( | Int | b, |
int | e, | ||
Int | r, | ||
int | k, | ||
DecompType | decom1, | ||
const char * | filem1, | ||
DecompType | decor, | ||
const char * | filer | ||
) |
Same as the other constructors with m=b^e+r
.
LatMRG::MRGComponent< Int >::MRGComponent | ( | Modulus< Int > & | modul, |
int | k, | ||
DecompType | decom1, | ||
const char * | filem1, | ||
DecompType | decor, | ||
const char * | filer | ||
) |
Constructor similar to the above, except that the modulus of congruence \(m\) is inside the object modul
.
LatMRG::MRGComponent< Int >::~MRGComponent | ( | ) |
Destructor.
LatMRG::MRGComponent< Int >::MRGComponent | ( | const MRGComponent< Int > & | comp | ) |
Copy constructor;.
|
inline |
Gets the type of this component.
|
inline |
Gets the multipliers of the recurrence to \(A\).
|
inline |
Returns the value of b
with b^e+r = m
.
|
inline |
Returns the value of e
with b^e+r = m
.
|
inline |
Returns the value of the modulus \(m\) of the recurrence.
|
inline |
Returns the value of the modulus \(m\) of the recurrence.
|
inline |
Gets the matrix multipliers of the recurrence.
|
inline |
Returns const reference of orbitSeed.
|
inline |
Returns the value of r
with b^e+r = m
.
|
private |
Does the same as the constructor above with similar arguments.
bool LatMRG::MRGComponent< Int >::maxPeriod | ( | const IntVec & | A | ) |
Returns true
if coefficients \(A\) give a MRG with maximal period; returns false
otherwise.
Note that when calling this class it is necessary that a[i] = a_i
.
bool LatMRG::MRGComponent< Int >::maxPeriod | ( | const Int & | a | ) |
Returns true
if \(a\) makes for a full period LCG with non-zero carry; returns false
otherwise.
This checks the 2 following conditions :
The user must choose the carry himself. Any carry relatively prime to \(m\) will give full period.
bool LatMRG::MRGComponent< Int >::maxPeriod | ( | const IntMat & | A | ) |
Returns true
if coefficients in \(A\) give a MMRG with maximal period; returns false
otherwise.
bool LatMRG::MRGComponent< Int >::maxPeriod23 | ( | const IntVec & | A | ) |
Returns true
if coefficients \(A\) give a MRG with maximal period; returns false
otherwise.
This method supposes that condition 1 is true
and tests only conditions 2 and 3. See method isPrimitive
of class PolyPE
on page (FIXME: page#) of this guide.
MRGComponent< Int > & LatMRG::MRGComponent< Int >::operator= | ( | const MRGComponent< Int > & | comp | ) |
Assignment operator.
|
inline |
Sets the type of this component.
void LatMRG::MRGComponent< Int >::setA | ( | const IntVec & | A | ) |
Sets the multipliers of the recurrence to \(A\).
void LatMRG::MRGComponent< Int >::setA | ( | const IntMat & | A | ) |
Sets the matrix of the recurrence to \(A\).
void LatMRG::MRGComponent< Int >::setPower2 | ( | std::vector< IntVec > & | coeffs | ) |
std::string LatMRG::MRGComponent< Int >::toString | ( | ) |
Returns this object as a string.
|
private |
The prime factor decomposition of \(m\).
Used to compute the full period of a LCG with a carry.
|
private |
The prime factor decomposition of \(m-1\).
|
private |
The prime factor decomposition of \(m-1\).
This is used when computing the full period of a matrix generator. This is because we use NTL to compute the characteristic polynomial of the matrix since it is already implemented.
|
private |
The prime factor decomposition of \(r=(m^k-1)/(m-1)\), where \(k\) is the order of the recurrence.
|
private |
The prime factor decomposition of \(r=(m^k-1)/(m-1)\), where \(k\) is the order of the recurrence.
This is used when computing the full period of a matrix generator. This is because we use NTL to compute the characteristic polynomial of the matrix since it is already implemented.
|
private |
The multipliers \(a_i\) of the recurrence, \(i = 1, …, k\).
|
private |
The generator matrix \(A\) of the recurrence for MMRG.
|
private |
Basis b
with b^e+r = m
.
|
private |
Exponent e
with b^e+r = m
.
|
private |
The order \(k\) of the recurrence.
Int LatMRG::MRGComponent< Int >::m_MWCb |
The modulo of the MWC generator if we study one.
This is because the we check MWC period with module.m as the modulo of the equivalent LCG.
|
private |
Rest r
with b^e+r = m
.
|
private |
The type of generator this stores.
Should be MRG, MMRG or MWC. The default value is LCG.
|
private |
The modulus \(m\) of the recurrence.
|
private |
Value needed for the calculation of the multipliers of a combined MRG.
It is defined by
\[ n_j = (m/m_j)^{-1} \mbox{ mod } m_j \qquad\mbox{ for } j = 1,…,J, \]
where \(n_j = \) nj
, \(m_j\) is this object’s modulus m
, \(m\) is the calculated modulus for the combined MRG (see class MRGLatticeFactory
), and \((m/m_j)^{-1} \mbox{ mod } m_j\) is the inverse of \(m/m_j\) modulo \(m_j\). This value is calculated by MRGLatticeFactory
and stored here for simplicity.
|
private |
Contains the starting state of the component for the case when the lattice type is ORBIT
.
It is made of \(k\) numbers.
|
private |
The length of the period \(\rho\) for this MRG.
For now, the recurrence is assumed to correspond to a primitive polynomial and rho
is calculated as
\[ \rho= m^k - 1 \]
This value is calculated by MRGLatticeFactory
and stored here for simplicity.