3.1 Sequential Random Number Generation with trng

Let’s first examine how we can use the trng C++ library to create a sequential version of code (running on one process) that uses a loop to generate one value after another in a stream.

This is the main program that sets up the use of the random number generator and uses a uniform distribution of integers from 1 to 99 for the values in the stream. Study it carefully to see how we use trng to do this.

There are several points to notice about this code:

If you run it without any changes, it is running with these command line arguments:

You should try it without the -c and run it a few more times to see that a new set of values is generated each time when we seed with a different number each time.

If you are interested in the code for handling these arguments for this sequential version, you could study the following code block. It is included with the code above when it is run, and not intended to be run on its own.

You have attempted of activities on this page