# include # include # include # include # include using namespace std; # include "latin_random.hpp" int main ( ); void test01 ( int &seed ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // latin_random_test() tests latin_random(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 01 March 2007 // // Author: // // John Burkardt // { int seed; int test; timestamp ( ); cout << "\n"; cout << "LATIN_RANDOM_TEST():\n"; cout << " C++ version\n"; cout << " Test LATIN_RANDOM().\n"; seed = 123456789; for ( test = 0; test < 3; test++ ) { test01 ( seed ); } // // Terminate. // cout << "\n"; cout << "LATIN_RANDOM_TEST():\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void test01 ( int &seed ) //****************************************************************************80 // // Purpose: // // TEST01 tests LATIN_RANDOM_NEW. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 12 November 2014 // // Author: // // John Burkardt // // Parameters: // // Input/output, int &SEED, a seed for the random number generator. // { int m = 2; int n = 10; double *x; cout << "\n"; cout << "TEST01\n"; cout << " LATIN_RANDOM chooses a Latin Square cell arrangement,\n"; cout << " and then chooses a random point from each cell.\n"; cout << "\n"; cout << " Spatial dimension = " << m << "\n"; cout << " Number of points = " << n << "\n"; cout << " Initial seed for UNIFORM = " << seed << "\n"; x = latin_random_new ( m, n, seed ); r8mat_transpose_print ( m, n, x, " Latin Random Square:" ); delete [] x; return; } //****************************************************************************80 void timestamp ( ) //****************************************************************************80 // // Purpose: // // timestamp() prints the current YMDHMS date as a time stamp. // // Example: // // 31 May 2001 09:45:54 AM // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 19 March 2018 // // Author: // // John Burkardt // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct std::tm *tm_ptr; std::time_t now; now = std::time ( NULL ); tm_ptr = std::localtime ( &now ); std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr ); std::cout << time_buffer << "\n"; return; # undef TIME_SIZE }