LatMRG Guide
1.0
A software package to test and search for new linear congruential random number generators
|
This class represents the lattice associated to a Multiply-with-carry (MWC) random number generator. More...
#include <latmrg/MWCLattice.h>
Public Types | |
typedef NTL::matrix< Int > | IntMat |
typedef NTL::vector< Int > | IntVec |
Public Types inherited from LatMRG::MRGLattice< Int, Dbl > | |
typedef Dbl | Dbl |
typedef Int | Int |
typedef NTL::matrix< Int > | IntMat |
typedef NTL::vector< Int > | IntVec |
Public Member Functions | |
MWCLattice (const Int &b, const IntVec &e, int k, int maxDim=1) | |
b is the modulo. More... | |
MWCLattice (const Int &b, const Int &m, int maxDim=1) | |
Another constructor with just b and m . More... | |
MWCLattice (const MWCLattice< Int, Dbl > &Lat) | |
Copy constructor. More... | |
~MWCLattice () | |
Destructor. More... | |
const IntVec & | geteCoef () const |
The coefficients of the MWC generator. More... | |
const Int & | getMWCmod () const |
The modulo of the MWC generator this object represents. More... | |
int | getMWCorder () const |
The order of the MWC generator. More... | |
void | kill () |
Cleans and releases memory used by this object. More... | |
MWCLattice< Int, Dbl > & | operator= (const MWCLattice< Int, Dbl > &Lat) |
Assigns Lat to this object. More... | |
std::string | toString () const override |
Gets all the information on the lattice in a string. More... | |
std::string | toStringCoef () const |
Gets the coefficients of the MRG that spawns the lattice in a string. More... | |
Public Member Functions inherited from 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 . 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... | |
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... | |
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 to coeffs`. 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... | |
Static Public Member Functions | |
static int | fullPeriod (const Int &b, const IntVec &e) |
This is a basic method to check if the MWC generator described by b and e has full period. More... | |
static int | validate (const Int &b, const IntVec &e) |
This checks if b and e are suitable parameters for a MWC generator. More... | |
Private Attributes | |
IntVec | m_eCoef |
The coefficients of the MWC generator. More... | |
Int | m_MWCmod |
The modulo of the MWC generator this object represents. More... | |
int | m_MWCorder |
The order of the MWC generator. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from LatMRG::MRGLattice< Int, Dbl > | |
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... | |
Protected Attributes inherited from LatMRG::MRGLattice< Int, Dbl > | |
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... | |
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 |
This class represents the lattice associated to a Multiply-with-carry (MWC) random number generator.
A MWC generator is defined by a recurrence of the form
\begin{align} x_n & = (e_1 x_{n-1} + \cdots + e_k x_{n-k} + c_{n-1})d\ \mathrm{mod} \ b \\ c_n & = \lfloor (e_0 x_n + e_1 x_{n-1} + \cdots + e_k x_{n-k} + c_{n-1} )/b \rfloor \\ u_n & = \sum_{i=1}^\infty x_{n+i-1} b^{-i} \end{align}
This generator can then be reprensented as an LCG and this class simply builds the correct MRGLattice object corresponding to a specific MWC generator. All the functions and attributes inherited by this class work as they would be expected to work on the lattice corresponding to that MRGLattice. For example, this means that the vector m_aCoef stores the coefficient of the LCG instead of the coefficients of the MWC generator.
This class simply implements a constructor and and the functions to compute the LCG equivalent to the MRG.
typedef NTL::matrix<Int> LatMRG::MWCLattice< Int, Dbl >::IntMat |
typedef NTL::vector<Int> LatMRG::MWCLattice< Int, Dbl >::IntVec |
LatMRG::MWCLattice< Int, Dbl >::MWCLattice | ( | const Int & | b, |
const IntVec & | e, | ||
int | k, | ||
int | maxDim = 1 |
||
) |
b is the modulo.
e is the vector of coefficients. k is the order of the recurrence.
It is recommended to verify that the parameters passed to this constructor work before using it, because the program will crash of validate(b, e) != 0
.
LatMRG::MWCLattice< Int, Dbl >::MWCLattice | ( | const Int & | b, |
const Int & | m, | ||
int | maxDim = 1 |
||
) |
Another constructor with just b
and m
.
Of course, b
and m
have to be valid.
LatMRG::MWCLattice< Int, Dbl >::MWCLattice | ( | const MWCLattice< Int, Dbl > & | Lat | ) |
Copy constructor.
The maximal dimension of the created basis is set equal to Lat
’s current dimension.
LatMRG::MWCLattice< Int, Dbl >::~MWCLattice | ( | ) |
Destructor.
|
inlinestatic |
This is a basic method to check if the MWC generator described by b
and e
has full period.
|
inline |
The coefficients of the MWC generator.
We have that m_eCoef[i] = e_i
. The MWC equations mean that if the order is k
, the generator has k+1
coefficients.
|
inline |
The modulo of the MWC generator this object represents.
|
inline |
The order of the MWC generator.
An order of k
means that the generator has k+1
coefficients.
void LatMRG::MWCLattice< Int, Dbl >::kill | ( | ) |
Cleans and releases memory used by this object.
MWCLattice< Int, Dbl > & LatMRG::MWCLattice< Int, Dbl >::operator= | ( | const MWCLattice< Int, Dbl > & | Lat | ) |
Assigns Lat
to this object.
The maximal dimension of this basis is set equal to Lat
’s current dimension.
|
override |
Gets all the information on the lattice in a string.
This contains the type of generator and the coefficients.
|
virtual |
Gets the coefficients of the MRG that spawns the lattice in a string.
Reimplemented from LatMRG::MRGLattice< Int, Dbl >.
|
inlinestatic |
This checks if b
and e
are suitable parameters for a MWC generator.
It is recommended to call this function before building a MWCLattice object because the program will exit if the condition verified here is not met.
This basically just checks that gcd(b, e[0]) = 1
and returns 1
if it is false
and 0
if it checks out.
|
private |
The coefficients of the MWC generator.
We have that m_eCoef[i] = e_i
. The MWC equations mean that if the order is k
, the generator has k+1
coefficients.
|
private |
The modulo of the MWC generator this object represents.
|
private |
The order of the MWC generator.
An order of k
means that the generator has k+1
coefficients.