# include # include # include # include # include using namespace std; # include "latin_cover.hpp" int main ( ); void test01 ( ); void test02 ( ); void test03 ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // latin_cover_test() tests latin_cover(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 05 August 2012 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "latin_cover_test():\n"; cout << " C++ version\n"; cout << " Test LATIN_COVER().\n"; test01 ( ); test02 ( ); test03 ( ); // // Terminate. // cout << "\n"; cout << "LATIN_COVER_TEST:\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void test01 ( ) //****************************************************************************80 // // Purpose: // // TEST01 tests LATIN_COVER. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 05 August 2012 // // Author: // // John Burkardt // { int *a; int n; int *p; int seed; int test; cout << "\n"; cout << "TEST01\n"; cout << " LATIN_COVER:\n"; for ( n = 3; n <= 9; n = n + 2 ) { seed = 123456789; for ( test = 1; test <= 3; test++ ) { p = perm_uniform_new ( n, seed ); perm_print ( n, p, " Permutation" ); a = latin_cover ( n, p ); i4mat_print ( n, n, a, " Latin cover" ); delete [] a; delete [] p; } } return; } //****************************************************************************80 void test02 ( ) //****************************************************************************80 // // Purpose: // // TEST02 tests LATIN_COVER_2D. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 24 June 2012 // // Author: // // John Burkardt // { int *a; int n; int *p1; int *p2; int seed; int test; cout << "\n"; cout << "TEST02\n"; cout << " LATIN_COVER_2D:\n"; for ( n = 3; n <= 9; n = n + 2 ) { seed = 123456789; for ( test = 1; test <= 3; test++ ) { p1 = perm_uniform_new ( n, seed ); perm_print ( n, p1, " Permutation 1" ); p2 = perm_uniform_new ( n, seed ); perm_print ( n, p2, " Permutation 2" ); a = latin_cover_2d ( n, p1, p2 ); i4mat_print ( n, n, a, " Latin cover" ); delete [] a; delete [] p1; delete [] p2; } } return; } //****************************************************************************80 void test03 ( ) //****************************************************************************80 // // Purpose: // // TEST03 tests LATIN_COVER_3D. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 05 August 2012 // // Author: // // John Burkardt // { int *a; int n; int *p1; int *p2; int *p3; int seed; int test; cout << "\n"; cout << "TEST03\n"; cout << " LATIN_COVER_3D\n"; for ( n = 3; n <= 9; n = n + 2 ) { seed = 123456789; for ( test = 1; test <= 3; test++ ) { p1 = perm_uniform_new ( n, seed ); perm_print ( n, p1, " Permutation 1" ); p2 = perm_uniform_new ( n, seed ); perm_print ( n, p2, " Permutation 2" ); p3 = perm_uniform_new ( n, seed ); perm_print ( n, p3, " Permutation 1" ); a = latin_cover_3d ( n, p1, p2, p3 ); i4block_print ( n, n, n, a, " Latin cover" ); delete [] a; delete [] p1; delete [] p2; delete [] p3; } } 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: // // 08 July 2009 // // 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 }