LatMRG Guide  1.0
A software package to test and search for new linear congruential random number generators
LatMRG::MRGLattice< Integ, Float > Class Template Reference

This class implements lattice basis built from multiple recursive linear congruential generators (MRGs). More...

#include <latmrg/MRGLattice.h>

Inheritance diagram for LatMRG::MRGLattice< Integ, Float >:

Public Types

typedef Float Dbl
 
typedef Integ Int
 
typedef NTL::matrix< IntIntMat
 
typedef NTL::vector< IntIntVec
 

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...
 
IntgetLac (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< Intm_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< IntVecm_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 IntVecgetCoef () 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...
 

Detailed Description

template<typename Integ, typename Float>
class LatMRG::MRGLattice< Integ, Float >

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. \]

Member Typedef Documentation

◆ Dbl

template<typename Integ, typename Float>
typedef Float LatMRG::MRGLattice< Integ, Float >::Dbl

◆ Int

template<typename Integ, typename Float>
typedef Integ LatMRG::MRGLattice< Integ, Float >::Int

◆ IntMat

template<typename Integ, typename Float>
typedef NTL::matrix<Int> LatMRG::MRGLattice< Integ, Float >::IntMat

◆ IntVec

template<typename Integ, typename Float>
typedef NTL::vector<Int> LatMRG::MRGLattice< Integ, Float >::IntVec

Constructor & Destructor Documentation

◆ MRGLattice() [1/4]

template<typename Int , typename Dbl >
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.

◆ MRGLattice() [2/4]

template<typename Int , typename Dbl >
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.

◆ MRGLattice() [3/4]

template<typename Int , typename Dbl >
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.

◆ MRGLattice() [4/4]

template<typename Int , typename Dbl >
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.

◆ ~MRGLattice()

template<typename Int , typename Dbl >
LatMRG::MRGLattice< Int, Dbl >::~MRGLattice ( )

Destructor.

Member Function Documentation

◆ buildBasis()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::buildBasis ( int  d)
virtual

Builds the basis in dimension \(d\).

◆ buildLaBasis()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::buildLaBasis ( int  d)
protected

Builds the basis of the MRG recurrence in case of lacunary indices.

◆ buildNaBasis()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::buildNaBasis ( int  d)
protected

Builds the basis of the MRG recurrence in case of non-lacunary indices.

◆ buildProjection()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::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.

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.

◆ getCoef()

template<typename Integ, typename Float>
const IntVec& LatMRG::MRGLattice< Integ, Float >::getCoef ( ) const
inline

Returns a non-mutable copy of the multipliers (coefficients) of the MRG.

◆ getLac()

template<typename Int , typename Dbl >
Int & LatMRG::MRGLattice< Int, Dbl >::getLac ( int  j)

Returns the \(j\)-th lacunary index.

◆ getLossRho()

template<typename Integ, typename Float>
Int LatMRG::MRGLattice< Integ, Float >::getLossRho ( ) const
inline

◆ getRho()

template<typename Integ, typename Float>
Int LatMRG::MRGLattice< Integ, Float >::getRho ( ) const
inline

◆ incDim()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::incDim ( )
virtual

Increments the dimension of the basis by 1 by calling either incDimBasis or incDimLaBasis.

◆ incDimBasis()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::incDimBasis ( )
protectedvirtual

Increments the basis by 1 in case of non-lacunary indices.

◆ incDimLaBasis()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::incDimLaBasis ( int  IMax)
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".

◆ init()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::init ( )
protected

Initializes some of the local variables.

◆ initOrbit()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::initOrbit ( )
protected

Initializes this object when the lattice type is ORBIT.

◆ initStates()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::initStates ( )
protected

Initializes a square matrix of order \(k\).

This initial matrix contains a system of generators for the given group of states.

◆ insertion()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::insertion ( IntVec Sta)
protected

◆ isLacunary()

template<typename Integ, typename Float>
bool LatMRG::MRGLattice< Integ, Float >::isLacunary ( ) const
inline

Returns true for the case of lacunary indices, returns false for non-lacunary indices.

◆ kill()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::kill ( )

Cleans and releases memory used by this object.

◆ lemme2()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::lemme2 ( IntVec Sta)
protected

◆ operator=()

template<typename Int , typename Dbl >
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.

◆ setLac()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::setLac ( const LatticeTester::Lacunary< Int > &  lat)
virtual

Sets the lacunary indices for this lattice to lat.

◆ setLossRho()

template<typename Integ, typename Float>
void LatMRG::MRGLattice< Integ, Float >::setLossRho ( const Int val)
inline

◆ setPower2()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::setPower2 ( std::vector< IntVec > &  coeffs)

Sets m_power2 to true and sets m_pow2_exp tocoeffs`.

◆ setRho()

template<typename Integ, typename Float>
void LatMRG::MRGLattice< Integ, Float >::setRho ( const Int val)
inline

◆ toString()

template<typename Int , typename Dbl >
std::string LatMRG::MRGLattice< Int, Dbl >::toString ( ) const
override

Returns the vector of multipliers \(A\) as a string.

◆ toStringCoef()

template<typename Int , typename Dbl >
std::string LatMRG::MRGLattice< Int, Dbl >::toStringCoef ( ) const
virtual

Returns the vector of multipliers \(A\) as a string.

Reimplemented in LatMRG::MWCLattice< Int, Dbl >, and LatMRG::AWCSWBLattice< Int, Dbl >.

◆ trace()

template<typename Int , typename Dbl >
void LatMRG::MRGLattice< Int, Dbl >::trace ( char *  msg,
int  d 
)
protected

For debugging purposes.

Member Data Documentation

◆ m_aCoef

template<typename Integ, typename Float>
IntVec LatMRG::MRGLattice< Integ, Float >::m_aCoef
protected

The coefficients of the recurrence.

◆ m_e

template<typename Integ, typename Float>
Int LatMRG::MRGLattice< Integ, Float >::m_e
protected

◆ m_ip

template<typename Integ, typename Float>
bool* LatMRG::MRGLattice< Integ, Float >::m_ip
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.

◆ m_lac

template<typename Integ, typename Float>
LatticeTester::Lacunary<Int> LatMRG::MRGLattice< Integ, Float >::m_lac
protected

Contains the lacunary indices when LacunaryFlag is true, otherwise is undefined.

◆ m_lacunaryFlag

template<typename Integ, typename Float>
bool LatMRG::MRGLattice< Integ, Float >::m_lacunaryFlag
protected

Is true in the case of lacunary indices, false otherwise.

◆ m_latType

template<typename Integ, typename Float>
LatticeType LatMRG::MRGLattice< Integ, Float >::m_latType
protected

Indicates which lattice or sublattice is analyzed.

◆ m_lossRho

template<typename Integ, typename Float>
Int LatMRG::MRGLattice< Integ, Float >::m_lossRho
protected

◆ m_pow2_exp

template<typename Integ, typename Float>
std::vector<IntVec> LatMRG::MRGLattice< Integ, Float >::m_pow2_exp
private

The powers of 2 used if this generator has power of 2 coefficients.

◆ m_power2

template<typename Integ, typename Float>
bool LatMRG::MRGLattice< Integ, Float >::m_power2
private

Indicates this generator is built using coefficients that are power of 2 combinations.

◆ m_rho

template<typename Integ, typename Float>
Int LatMRG::MRGLattice< Integ, Float >::m_rho
protected

◆ m_sta

template<typename Integ, typename Float>
IntMat LatMRG::MRGLattice< Integ, Float >::m_sta
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.

◆ m_t4

template<typename Integ, typename Float>
Int LatMRG::MRGLattice< Integ, Float >::m_t4
protected

Work variables.

◆ m_t5

template<typename Integ, typename Float>
Int LatMRG::MRGLattice< Integ, Float >::m_t5
protected

◆ m_t6

template<typename Integ, typename Float>
Int LatMRG::MRGLattice< Integ, Float >::m_t6
protected

◆ m_t7

template<typename Integ, typename Float>
Int LatMRG::MRGLattice< Integ, Float >::m_t7
protected

◆ m_t8

template<typename Integ, typename Float>
Int LatMRG::MRGLattice< Integ, Float >::m_t8
protected

◆ m_xi

template<typename Integ, typename Float>
IntVec LatMRG::MRGLattice< Integ, Float >::m_xi
protected

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