# include # include # include # include "pcg_minimal.h" int main ( ); void pcg_minimal_test01 ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: MAIN is the main program for pcg_minimal_test. Licensing: This code is distributed under the MIT license. Modified: 12 February 2020 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "pcg_minimal_test\n" ); printf ( " C version\n" ); printf ( " Test pcg_minimal.\n" ); pcg_minimal_test01 ( ); /* Terminate. */ printf ( "\n" ); printf ( "pcg_minimal_test\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void pcg_minimal_test01 ( ) /******************************************************************************/ /* Purpose: pcg_minimal_test01 simply calls pcg_minimal 10 times. Licensing: This code is distributed under the MIT license. Modified: 12 February 2020 Author: John Burkardt */ { int i; pcg32_random_t fred; uint32_t result; fred.inc = 123456789UL; fred.state = 23456789UL; printf ( "\n" ); printf ( "pcg_minimal_test01:\n" ); printf ( " Call pcg32_random_r 10 times.\n" ); printf ( "\n" ); for ( i = 1; i <= 10; i++ ) { result = pcg32_random_r ( &fred ); printf ( " %2d %16u\n", i, result ); } return; } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* Purpose: TIMESTAMP prints the current YMDHMS date as a time stamp. Example: 17 June 2014 09:45:54 AM Licensing: This code is distributed under the MIT license. Modified: 17 June 2014 Author: John Burkardt */ { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct tm *tm; time_t now; now = time ( NULL ); tm = localtime ( &now ); strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); printf ( "%s\n", time_buffer ); return; # undef TIME_SIZE }