|
LatMRG Guide
1.0
A software package to test and search for new linear congruential random number generators
|
This class implements lattice basis built from multiple recursive linear congruential generators (MRGs). More...
#include <latmrg/MRGLattice.h>
Public Types | |
| typedef Float | Dbl |
| typedef Integ | Int |
| typedef NTL::matrix< Int > | IntMat |
| typedef NTL::vector< Int > | IntVec |
Public Member Functions | |
| MRGLattice (const Int &m, const IntVec &a, int maxDim, int k, LatticeType latt, LatticeTester::NormType norm=LatticeTester::L2NORM) | |
Constructor with modulus of congruence \(m\), order of the recurrence \(k\), multipliers \(a\), maximal dimension MaxDim, and lattice type Latt. More... | |
| MRGLattice (const Int &m, const Int &a, int maxDim, LatticeType latt, LatticeTester::NormType norm=LatticeTester::L2NORM) | |
| Alternative constructor for a LCG. More... | |
| MRGLattice (const Int &m, const IntVec &a, int maxDim, int k, IntVec &lac, LatticeType latt, LatticeTester::NormType norm=LatticeTester::L2NORM) | |
As in the constructor above but the basis is built for the lacunary indices lac. More... | |
| MRGLattice (const MRGLattice< Int, Dbl > &Lat) | |
| Copy constructor. More... | |
| ~MRGLattice () | |
| Destructor. More... | |
| virtual void | buildBasis (int d) |
| Builds the basis in dimension \(d\). More... | |
| Int & | getLac (int j) |
| Returns the \(j\)-th lacunary index. More... | |
| virtual void | incDim () |
Increments the dimension of the basis by 1 by calling either incDimBasis or incDimLaBasis. More... | |
| bool | isLacunary () const |
Returns true for the case of lacunary indices, returns false for non-lacunary indices. More... | |
| void | kill () |
| Cleans and releases memory used by this object. More... | |
| MRGLattice< Int, Dbl > & | operator= (const MRGLattice< Int, Dbl > &Lat) |
Assigns Lat to this object. More... | |
| virtual void | setLac (const LatticeTester::Lacunary< Int > &lat) |
Sets the lacunary indices for this lattice to lat. More... | |
Protected Attributes | |
| IntVec | m_aCoef |
| The coefficients of the recurrence. More... | |
| bool * | m_ip |
When the flag m_ip[i] is true, the \(i\)-th diagonal element of matrix m_sta is non-zero (modulo \(m\)) and divides \(m\). More... | |
| LatticeTester::Lacunary< Int > | m_lac |
Contains the lacunary indices when LacunaryFlag is true, otherwise is undefined. More... | |
| bool | m_lacunaryFlag |
Is true in the case of lacunary indices, false otherwise. More... | |
| LatticeType | m_latType |
| Indicates which lattice or sublattice is analyzed. More... | |
| IntMat | m_sta |
| Matrix that contains the vectors that can be used to generate the basis for an arbitrary dimension. More... | |
Used for the calculation of a combined MRG. | |
| Int | m_lossRho |
| Int | m_rho |
| Int | m_t4 |
| Work variables. More... | |
| Int | m_t5 |
| Int | m_t6 |
| Int | m_t7 |
| Int | m_t8 |
| Int | m_e |
| IntVec | m_xi |
Private Attributes | |
| std::vector< IntVec > | m_pow2_exp |
| The powers of 2 used if this generator has power of 2 coefficients. More... | |
| bool | m_power2 |
| Indicates this generator is built using coefficients that are power of 2 combinations. More... | |
Sets and gets the values of <tt>m_rho</tt> and <tt>m_lossRho</tt>. | |
| Int | getRho () const |
| Int | getLossRho () const |
| void | setRho (const Int &val) |
| void | setLossRho (const Int &val) |
| const IntVec & | getCoef () const |
| Returns a non-mutable copy of the multipliers (coefficients) of the MRG. More... | |
| virtual std::string | toStringCoef () const |
| Returns the vector of multipliers \(A\) as a string. More... | |
| std::string | toString () const override |
| Returns the vector of multipliers \(A\) as a string. More... | |
| void | setPower2 (std::vector< IntVec > &coeffs) |
Sets m_power2 to true and sets m_pow2_exp tocoeffs`. More... | |
| void | buildProjection (LatticeTester::IntLattice< Int, Int, Dbl, Dbl > *lattice, const LatticeTester::Coordinates &proj) override |
Builds a projection for this lattice on the set in indices in proj. More... | |
| void | initStates () |
| Initializes a square matrix of order \(k\). More... | |
| void | init () |
| Initializes some of the local variables. More... | |
| void | initOrbit () |
Initializes this object when the lattice type is ORBIT. More... | |
| void | insertion (IntVec &Sta) |
| void | lemme2 (IntVec &Sta) |
| void | trace (char *msg, int d) |
| For debugging purposes. More... | |
| virtual void | incDimBasis () |
| Increments the basis by 1 in case of non-lacunary indices. More... | |
| void | incDimLaBasis (int) |
| Increments the basis by 1 in case of lacunary indices. More... | |
| void | buildNaBasis (int d) |
| Builds the basis of the MRG recurrence in case of non-lacunary indices. More... | |
| void | buildLaBasis (int d) |
| Builds the basis of the MRG recurrence in case of lacunary indices. More... | |
This class implements lattice basis built from multiple recursive linear congruential generators (MRGs).
One must first call the constructor with a given congruence modulus \(m\), order \(k\) for the recurrence, and maximal dimension for the basis. One must then build the lattice basis associated to a vector of multipliers for a given dimension. Each MRG is defined by a vector of multipliers \(A\), where \(A[i-1]\) represents \(a_i\). This MRG satisfies the recurrence
\[ x_n = (a_1 x_{n-1} + \cdots+ a_k x_{n-k}) \mod m. \]
| typedef Float LatMRG::MRGLattice< Integ, Float >::Dbl |
| typedef Integ LatMRG::MRGLattice< Integ, Float >::Int |
| typedef NTL::matrix<Int> LatMRG::MRGLattice< Integ, Float >::IntMat |
| typedef NTL::vector<Int> LatMRG::MRGLattice< Integ, Float >::IntVec |
| LatMRG::MRGLattice< Int, Dbl >::MRGLattice | ( | const Int & | m, |
| const IntVec & | a, | ||
| int | maxDim, | ||
| int | k, | ||
| LatticeType | latt, | ||
| LatticeTester::NormType | norm = LatticeTester::L2NORM |
||
| ) |
Constructor with modulus of congruence \(m\), order of the recurrence \(k\), multipliers \(a\), maximal dimension MaxDim, and lattice type Latt.
a has to be a vector of k+1 components with a[i]= \(a_i\) for compatibility with other classes. Vectors and (square) matrices of the basis have maximal dimension maxDim, and the indices of vectors and matrices vary from dimension 1 to maxDim. The norm to be used for the basis vectors is norm.
| LatMRG::MRGLattice< Int, Dbl >::MRGLattice | ( | const Int & | m, |
| const Int & | a, | ||
| int | maxDim, | ||
| LatticeType | latt, | ||
| LatticeTester::NormType | norm = LatticeTester::L2NORM |
||
| ) |
Alternative constructor for a LCG.
In this case, k is 1 and a is a single number.
| LatMRG::MRGLattice< Int, Dbl >::MRGLattice | ( | const Int & | m, |
| const IntVec & | a, | ||
| int | maxDim, | ||
| int | k, | ||
| IntVec & | lac, | ||
| LatticeType | latt, | ||
| LatticeTester::NormType | norm = LatticeTester::L2NORM |
||
| ) |
As in the constructor above but the basis is built for the lacunary indices lac.
a has to be a vector of k+1 components with a[i]= \(a_i\) for compatibility with other classes.
| LatMRG::MRGLattice< Int, Dbl >::MRGLattice | ( | const MRGLattice< Int, Dbl > & | Lat | ) |
Copy constructor.
The maximal dimension of the created basis is set equal to Lat’s current dimension.
| LatMRG::MRGLattice< Int, Dbl >::~MRGLattice | ( | ) |
Destructor.
|
virtual |
Builds the basis in dimension \(d\).
|
protected |
Builds the basis of the MRG recurrence in case of lacunary indices.
|
protected |
Builds the basis of the MRG recurrence in case of non-lacunary indices.
|
override |
Builds a projection for this lattice on the set in indices in proj.
This differs from the original implementation in IntLattice because it does not compute a dual lattice basis. lattice has to be initialized with the right dimension beforehand.
|
inline |
Returns a non-mutable copy of the multipliers (coefficients) of the MRG.
| Int & LatMRG::MRGLattice< Int, Dbl >::getLac | ( | int | j | ) |
Returns the \(j\)-th lacunary index.
|
inline |
|
inline |
|
virtual |
Increments the dimension of the basis by 1 by calling either incDimBasis or incDimLaBasis.
|
protectedvirtual |
Increments the basis by 1 in case of non-lacunary indices.
|
protected |
Increments the basis by 1 in case of lacunary indices.
Uses the method described in the article: P. L'Ecuyer and R. Couture, "An Implementation of the Lattice and Spectral Tests for Multiple Recursive Linear Random Number Generators", INFORMS Journal on Computing, 9, 2 (1997), page 206–217. Section 3, "Lacunary indices".
|
protected |
Initializes some of the local variables.
|
protected |
Initializes this object when the lattice type is ORBIT.
|
protected |
Initializes a square matrix of order \(k\).
This initial matrix contains a system of generators for the given group of states.
|
protected |
|
inline |
Returns true for the case of lacunary indices, returns false for non-lacunary indices.
| void LatMRG::MRGLattice< Int, Dbl >::kill | ( | ) |
Cleans and releases memory used by this object.
|
protected |
| MRGLattice< Int, Dbl > & LatMRG::MRGLattice< Int, Dbl >::operator= | ( | const MRGLattice< Int, Dbl > & | Lat | ) |
Assigns Lat to this object.
The maximal dimension of this basis is set equal to Lat’s current dimension.
|
virtual |
Sets the lacunary indices for this lattice to lat.
|
inline |
| void LatMRG::MRGLattice< Int, Dbl >::setPower2 | ( | std::vector< IntVec > & | coeffs | ) |
Sets m_power2 to true and sets m_pow2_exp tocoeffs`.
|
inline |
|
override |
Returns the vector of multipliers \(A\) as a string.
|
virtual |
Returns the vector of multipliers \(A\) as a string.
Reimplemented in LatMRG::MWCLattice< Int, Dbl >, and LatMRG::AWCSWBLattice< Int, Dbl >.
|
protected |
For debugging purposes.
|
protected |
The coefficients of the recurrence.
|
protected |
|
protected |
When the flag m_ip[i] is true, the \(i\)-th diagonal element of matrix m_sta is non-zero (modulo \(m\)) and divides \(m\).
Otherwise (when m_ip[i] is false), the \(i\)-th line of matrix m_sta is identically 0.
|
protected |
Contains the lacunary indices when LacunaryFlag is true, otherwise is undefined.
|
protected |
Is true in the case of lacunary indices, false otherwise.
|
protected |
Indicates which lattice or sublattice is analyzed.
|
protected |
|
private |
The powers of 2 used if this generator has power of 2 coefficients.
|
private |
Indicates this generator is built using coefficients that are power of 2 combinations.
|
protected |
|
protected |
Matrix that contains the vectors that can be used to generate the basis for an arbitrary dimension.
This matrix is of order k and if we want to build the full lattice, this matrix is the identity matrix. Marc-Antoine This matrix is different in some way that I don't quite understand if we use lacunary indices.
|
protected |
Work variables.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |