/* nag_rngs_init_repeatable (g05kbc) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpout; /* Scalars */ Integer exit_status = 0; double x; Integer i, igen; /* Arrays */ Integer iseed[4]; /* Check for command-line IO options */ fpout = nag_example_file_io(argc, argv, "-results", NULL); fprintf(fpout, "nag_rngs_init_repeatable (g05kbc) Example Program Results\n\n"); /* Initialise the seed */ iseed[0] = 1762543; iseed[1] = 9324783; iseed[2] = 42344; iseed[3] = 742355; /* igen identifies the stream. */ igen = 1; /* nag_rngs_init_repeatable (g05kbc). * Initialize seeds of a given generator for random number * generating functions (that pass seeds explicitly) to give * a repeatable sequence */ nag_rngs_init_repeatable(&igen, iseed); for (i = 1; i <= 5; ++i) { /* nag_rngs_basic (g05kac). * Pseudo-random real numbers, uniform distribution over * (0,1), seeds and generator number passed explicitly */ x = nag_rngs_basic(igen, iseed); fprintf(fpout, "%10.4f\n", x); } if (fpout != stdout) fclose(fpout); return exit_status; }