# include # include # include # include "ppc_array.h" # include "ppc_netpbm_random.h" int main ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: ppc_netpbm_random_test() tests ppc_netpbm_random(). Licensing: This code is distributed under the MIT license. Modified: 08 September 2023 Author: John Burkardt */ { double f; char *filename = "ppc_random.pbm"; char **M; int m; int n; unsigned int s; timestamp ( ); printf ( "\n" ); printf ( "ppc_netpbm_random_test():\n" ); printf ( " C version\n" ); printf ( " Test ppc_netpbm_random().\n" ); s = 123456789; srand ( s ); m = 8; n = 5; f = 0.25; M = make_random_matrix ( m, n, f ); printf ( "\n" ); printf ( " Random PBM matrix:\n" ); printf ( "\n" ); print_matrix ( "%d", M, m, n ); printf ( "\n" ); printf ( " Write matrix to PBM file:\n" ); printf ( "\n" ); write_pbm ( M, m, n, filename ); free_matrix ( M ); /* Terminate. */ printf ( "\n" ); printf ( "ppc_netpbm_random_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ 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 }