Exercise 3: Random plaquette Goals: Generating random numbers in QDP Concepts: Random state, Canned routines Directory: \$HOME/examples/03-random-plaquette How to: \$ cd \$HOME/examples/03-random-plaquette \$ make \$ submit plaquette

Random numbers are very important for Lattice QCD codes. Very often it is important to be able to generate pseudo-random number reliably, e.g., independent on the size of the machine the program runs on. QDP provides such an facility. The random number generator is represented by a parallel variable of type QDP_RandomState. It is possible to use more than one generator at the same time.  The QDP library knows how to produce the uniform and normal distributions out of the QDP_RandomState. The following functions are defined in <qdp.h>:

 `void QDP_R_eq_random_S(QDP_Real *, QDP_RandomState *, QDP_Subset);void QDP_R_eq_gaussian_S(QDP_Real *, QDP_RandomState *, QDP_Subset);void QDP_C_eq_gaussian_S(QDP_Complex *, QDP_RandomState *, QDP_Subset);void QDP_V_eq_gaussian_S(QDP_ColorVector *, QDP_RandomState *, QDP_Subset);void QDP_M_eq_gaussian_S(QDP_ColorMatrix *, QDP_RandomState *, QDP_Subset);void QDP_H_eq_gaussian_S(QDP_HalfFermion *, QDP_RandomState *, QDP_Subset);void QDP_D_eq_gaussian_S(QDP_DiracFermion *, QDP_RandomState *, QDP_Subset);void QDP_P_eq_gaussian_S(QDP_DiracPropagator *, QDP_RandomState *, QDP_Subset);`

To use a random number generator, first one creates a random state and sets a seed. This is done in file main.c, lines 22 and 24.  The routine init_random() is defined in file random.c. We will not go into details how it works, it suffices to say that on each lattice site it converts the seed into an independent random stream.

 ` 11 QDP_RandomState *random_state;... 21 /* create random generator */ 22 random_state = QDP_create_S(); 23 /* seed it */ 24 init_random(random_state, 299792458);... 35 /* delete random generator */ 36 QDP_destroy_S(random_state);`

In this example, instead of making all links equal to unity, we set them to random values. Since the library does not provide a random SU(3) matrices for us, we build them by hand in file random-link.c.

 ` 26 /* allocate the gauge field and make it random */ 27 for (mu = 0; mu < NDIM; mu++) { 28 U[mu] = QDP_create_M(); 29 random_link(U[mu], random_state, QDP_all); 30 }`

### Problems

• You can try running this example on different sizes of the machine.
• Another exercise is to play with the seed of the random state.
• One extra credit for knowing what the number on line 24 is.