LatMRG Guide  1.0
A software package to test and search for new linear congruential random number generators
Compilation and Executables Usage

LatMRG executable

As of the latest update, LatMRG possesses a single executable taking all it's options from configuration files. This executable has 4 different execution modes that simply the usage of the core functionnalities of LatMRG.

  • A mode to search of \(m\) and \(k\) parameters for MRG generators.
  • A mode to test if a specific MRG has full period.
  • A mode to test MRG generators with figures of merit tests built upon the computations LatMRG can perform on lattice.
  • A mode to search for new MRG generators, using the same kind of tests as the test mode.

We briefly introduce what each mode can do, before presenting the program usage.

Searching m and k parameters

This mode will search for good modulus in a certain range given a number \(k\). This is used when searching for new generators with full period.

This will search for prime \(m\) in \(m < 2^e\) or \( 2^e+c_1 \le m \le 2^e+c_2\). When doing these search, it is possible to ask that \(r = (m^k-1)/(m-1)\) is prime and that \((m-1)/2\). It is also possible to ask the program to factor \(m-1\) to a file.

All these factorisations and restrictions on primality are useful because they simplify the initialization process of the search program, as the factorization of \(r\) and \((m-1)/2\) is needed to check the full period of a generator.

Checking for full period

This mode takes a generator and tests if it's period length is maximal. This will need a factorization for \(r\) and \(m-1\) which can be very long to compute. Accomplishing this factorization outside of the main program is the main use case of this mode. Using this seperately of the generator testing gives you more flexibility with the execution time.

Testing lattice structure for MRG

This mode takes a generator, a test, a description of how to apply this test and performs the test on the generator. The generator can be of any of the types of MRG described in Theory of Random Numbers.

The program can perform multiple computations:

  • The length of the shortest vector in the lattice of the generator in L1 and euclidian norm.
  • The length of the shortest vector in the dual lattice of the generator
  • The preceding norms normalized between 0 and 1

But it's real strength lies in the fact that it can build the generator lattice and dual lattice for any projection of the generator, and compute figures of merit based on the normalized mesures on these multiple projections. Computing these figures of merit is really the main reason to use this mode.

To execute the program, it is necessary to feed it with the set of of the generator that you want to test. This program takes a values for \(T\), \(d\) and \(T_2, \ldots, T_d\) such that the program will test all projections of the form \(\{0, \ldots, t\}\) with \(k \le t < T\), and projections on indices \(\{i_1, \ldots, i_j: 0 \leq i_k \le T_j\}\) for \(2 \le j \le d\).

Searching for new MRG

This mode takes configuration of MRG generators (such and the modulo, the order and ranges for the parameters) and randomly searches for parameters that fit this configuration. Once a generator is found, it is tested with the same methodology as in the preceding Testing lattice structure for MRG mode and generators are ranked by the value they get in these tests.

Even though a lot for flexibility is available when using this mode, it is usual to compare generators with figures of merit between 0 and

Usage of the executable

We do not provide a precompiled binairy for the main executable. To use it you must first compile it following the instructions following this section. Once this is done, you will find the main MRGLattice executable in the bin directory of the software repository.

As any executable, the executable can be called from the command line as

./MRGLattice <LD, ZD, ZR> file1 file2 ...

It is necessary to specify configuration files for the program to actually do stuff. The option of LD, ZD or ZR can be used to change the numeric types used by the program. It can be ommited, its default value is ZD. For more information on what this option means, you can have a look at Types in LatMRG.

NEW As of the last upgrade to LatMRG, the executable now reads it's configuration from xml files. Since configuration files have a quite extensive set of tags allowing users to specify the options, the list of these tags and their usage for the different modes is specified in Configuration Files Synthax and Tags.

Building LatMRG

LatMRG is available on Github and can be downloaded either via git or as a .zip archive. We do not provide precompiled binairies, so you have to follow these instruction to use the software. Once you have the repository on a local machine, it is necessary to make sure that you have the correct dependencies installed:

  • NTL version 10.5.0 or later is needed. Follow Shoup's instructions to install the library compiled with the option NTL_THREADS=off in a standard path.
    • gmp is a NTL dependency. It is packaged by most major Linux distributions. You will need to also download the header files of the library (usually in a -dev or -devel named package).
  • Lattice Tester is a submodule in the git repository. The instructions bellow present how to download and compile Lattice Tester along LatMRG.
  • tinyxml2 A small library to parse xml documents. This should be available through the package manager of most linux distributions. The header file of the library is shipped as part of the LatMRG code.
  • git will greatly simplify the download process for both LatMRG and Lattice Tester.
  • yafu is an external executable that is used for factorization when checking that generators have full period. It is not necessary to have it when building, but the program will halt when asked for a factorization. If you want to avoid this behavior, download and unpack this executable in the data directory.

To build the program, it will also be necessary to have a recent C++ compiler and Python interpreter installed. Note that we do not provide instructions to build the library under Windows or macOS, and that the software is only tested for the x86_64 architecture. Also note that we currently do not use automatic makefile generation and that you will need to manually modify the makefile for any non standard path choices.

First, download the source code via github as a .zip unpack it and open a terminal in that directory, or use git:

git clone --recursive https://github.com/savamarc/LatMRG.git

If you downloaded the zip, you will also need to download and extract Lattice Tester. In the latticetester directory. Once this is done, the program can be compiled in only a few commands. Note that the first one is interractive.

make config_latticetester
make

Once this is done, the executables can be invoked from the local directory as ./bin/Program_name data_file.

Note that there is no way to install the program somewhere else. If yafu is used by the program, it might be problematic to move the binaries. This is because the program uses a relative path to invoke yafu. We are aware of these issues and they will be fixed some time in the future.