If f (x) is an irreducible polynomial, then c−kf (cx) and xkf (c/x) are also irreducible polynomials for any non-zero constant c. Using this fact, Deng [2004] gave the following theorem:
Theorem 1 Let R(k, p) = (pk− 1)/(p − 1) be a GMP and c be any non-zero intenger. Let f (x) in (3) be a primitive polynomial and define
G(x) = c−kf (cx) = xk− G1xk−1− G2xk−2− · · · − Gk mod p, (18)
H(x) = −α−1k xkf (c/x) = xk− H1xk−1− H2xk−2− · · · − Hk mod p, (19) where Gj = c−jαj mod p and Hj = −α−1k αk−jcj mod p, for j = 1, 2, · · · , k, α0 = −1. If the constant term Gk (= c−kαk) is a primitive element modulo p, then both G(x) and H(x) are k-th degree primitive polynomials.
There are two advantages in considering G(x) and H(x):
1. They can be calculated very efficiently from the polynomial f (x).
2. Both of them have exactly the same number of nonzero terms as that in f (x).
Hence, if f (x) is a characteristic polynomial of a MRG which is implemented efficiently, then the induced generator with characteristic polynomial G(x) or H(x) can be also implemented efficiently.
Based on Theorem 1, many maximum-period MRGs (corresponding to G(x) or H(x)) can be constructed quickly from a single maximum-period MRG (corresponding to f (x)). But there are some defects here:
1. We need to check the primitive-root condition of the constant term ( Gk or Hk) 2. It appears that the sequential selection of c should be randomized.
3. The selection of c causes no guarantee for the generated MRGs to be distinct.
Next, we describe an automatically generating algorithm proposed by Deng, Li and Shiau [2009]
to overcome above drawbacks.
Algorithm AGM Let R(k, p) = (pk− 1)/(p − 1) be a GMP and f (x) in (3) be a primitive polynomial corresponding to a efficient and portable MRG in which the nonzero coefficient is B as in equations (8), (9), (10), (11), (12), (14) and (16). Let R be an integer with gcd(R, p−1) = 1.
The following procedure will randomly generate a sequence of maximum-period MRGs.
1. Whenever a new processor is initiated, generate rn by the following equation:
rn= Rrn−1 mod (p − 1), n ≥ 1 with r0 = 1. (20)
2. Calculate dn and then cn for the new processor by
dn= k−1(rn+ 1) mod (p − 1) and cn= Bdn mod p (21)
3. With the given cn, compute the primitive polynomial G(x) or H(x) by
G(x) = c−kn f (cnx) mod p, (22)
H(x) = −B−1xkf (cn/x) mod p. (23)
4. The new processor can use the newly constructed maximum-period MRG of order k cor-responding to the characteristic polynomial G(x) or H(x) as follows:
Xi = G1Xi−1+ · · · + GkXi−k mod p, (24)
Xi= H1Xi−1+ · · · + HkXi−k mod p, (25)
The above automatic generating method is most suitable for Sophine-Germain primes
be-H(x) can be generated, which in turn can produce different maximum-period MRGs. When p is a non-Sophine-Germain prime, the AGM algorithm can still be used as long as gcd(k, p − 1)=1 so that k−1 exists under modulus (p − 1). One slight drawback is the number of different maximum-period MRGs can be produced is less than those with Sophine-Germain prime mod-ulus. Hence, our web utilized the multiplier B for Sophine-Germain primes from Table 2-29 to generate parallel MRGs.
Previous algorithm is mainly for the case when the prime modulus p is of a Sophine-Germain prime. Deng, Shiau and Tsai [2009] proposed another automatic generation algorithm for the case of non-Sophine-Germain prime. We describe briefly their algorithm below:
Algorithm AGM for non-Sophine-Germain prime. Let f (x) in (3) be a primitive polynomial corresponding to a DL or a DT generator in which the nonzero coefficient is B as in equations (12) or (16). The steps below will randomly generate a set of maximum-period MRGs.
1. Whenever a new processor is initiated, continue generating a new dn via a simple LCG:
dn= W dn−1 mod p until gcd(kdn− 1, p − 1) = 1, where W is a primitive element modulus 3. The new processor can use the newly constructed maximum-period MRG corresponding to the characteristic polynomial G(x) in (26) and H(x) in (27) as in equations (24) and (25), respectively.
When the baseline generator is a DL or DT generator, the previously generated MRGs have k nonzero terms. Deng, Shiau and Tsai [2009] presented efficient implementations for the constructed MRGs by a (k + 1) recurrence equation.
For these 64-bit and 128-bit generators found (DX, DL, DS and DT), we can certainly follow a similar procedure to construct many efficient MRGs using the same algorithm as described. Since these automatic generation algorithm which may involve some tedious arithmetic operations over a finite field. In the next chapter, we describe our effort to implement the automatic generation method via a web programming so that it can provide interested users with the computer programs for the desired efficient MRGs or automatic generation of MRGs.
7 Web Programming for MRGs and Parallel MRGs
For easy access to the program codes and/or the required parameters for efficient and portable MRGs, we have provided a web page at http://140.113.114.152/main.html. This is a tempo-rary site for the experimental purpose only. We are in the process of finding a more permanent website which can be linked to the main home page at http://www.stat.nctu.edu.tw/ in the near future. For the method of generating parallel MRGs, please see the discussion as before.
In addition, we also offer the codes necessary in order to use TestU01 packages. Therefore, the users can easily test the empirical performance of the corresponding MRGs.
We hope to continually improve our web program so that it will provide a more user-friendly interface and more functionality on the information provided. Currently, our web program has four different options as shown below:
Figure 1: Four different options
We explain these four main options for our program in a greater detail: (1) Multiple Recursive Generators which the user can retrieve the parameters for the generator requested (2) Parallel Multiple Recursive Generators which can produce the parameters from a single generator, (3) TestU01 of Multiple provide the program in TestU01 form for the generator requested and (4) TestU01 of Parallel Multiple which can produce the TestU01 program from a single generator.
AS shown in Figure 1, users can choose these options by clicking the option for retrieving the program codes, parameters for the efficient and portable MRGs, TestU01 program code for the MRGs or parallel MRGs.
Next, we explain the four options in details for the users inputs and program outputs pro-duced.
7.1 Retrieving parameters for the maximum period MRGs
The first option offer program codes in C of efficient and portable MRGs as shown in Figure 2 is displayed after the first option is selected.
The first input box decides the initial seed chosen from the user for the given efficient MRGs.
Here, we use an LCG with multiplier B = 16807 and the B given in the corresponding MRG.
Using the initial seed input in the first input box, the web program produce an initialization
Figure 2: Interface for Efficient and Portable MRGs
from the database with k set by the user who enters second input box for the order k. When the user enters an approximate value of order k, the web program will automatically find the nearest prime order k which have been stored in the database. The values for the order k available are ranging from 101 to 4001 with interval of one hundred for 32-bit generators. For 63-bit, 64-bit, 127-bit and 128-bit generators, the values of k are from 101 to 2003 with interval of one hundred.
The upper limit of k maybe updated as we find larger order MRGs. We need two more inputs from the user: (1) the size of the prime modulus p = 2d− c, where the bit d can be 31, 63, 64, 127, or 128 bit. (2) the type of efficient MRGs as discussed previously which can be DX-k-s with s = 1, 2, 3, 4 or DL-k, DS-k, or DT-k. After selecting the bit (d) and type of efficient and portable MRGs, the user can press the “send” button. The program code for the corresponding MRG and its parameter would be shown as in Figure 3 below.
Figure 3 is an example using the values initial seed = 123, order k = 110 (which would be replaced by the closest order k = 101 in the result), bit = 31 and DX-1 type.
The first part of the output as shown in Figure 3 is:
Xi = Xi−1+ BXi−101 (28)
which displays the generator’s (in this case, DX-101-1) recurrence equation. The actual program implementation of this generator can be downloaded which is shown as
Finally, the initialization part of the program
DX s1 initial seeds(1048575, 101, 2147400803, 123); (29) which is the code to initiate the start seeds. The following program is automatically produced
typedef unsigned long long int64;
typedef struct { int B, PP, KK;
double PP_inv;
} param_DX_s1;
typedef struct { int64 *XX;
int II;
} state_DX_s1;
#define DMOD(n, p) ((n) % (p))
param_DX_s1 DX_s1_param ; state_DX_s1 DX_s1_state ;
void DX_s1_initial_seeds(int B, int k, int m, int seed) {
DX_s1_param.KK = k ; DX_s1_param.PP = m ; DX_s1_param.B = B ;
int i;
DX_s1_state.XX = (int64*)malloc(sizeof(int64)*DX_s1_param.KK);
DX_s1_state.XX[0] = seed;
for(i=1; i < DX_s1_param.KK ; i++)
DX_s1_state.XX[i] = DMOD( 16807 * DX_s1_state.XX[i-1], DX_s1_param.PP);
DX_s1_param.PP_inv = 1.0/DX_s1_param.PP;
DX_s1_state.II = DX_s1_param.KK-1; /* running index */
}
Figure 3: Result for Efficient and Portable MRGs
by our web program
which is a part of the downloaded file for code of the chosen MRG. In (29), the fist parameter 1048575 is the multiplier B in (28); the second parameter 101 is the order k; the third parameter is the modulus p of chosen MRG; the final parameter 123 is the initial seed. The last part of the output gives a simple illustration for using our code. When the option of 63-bit, 64-bit, 127-bit or 128-bit generators is selected, our web program can provide an implementation with codes written for 32-bit CPU with the help of a general multi-precision package called GMP.