# include # include # include # include # include # include using namespace std; # include "asa144.hpp" int main ( ); void test01 ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // ASA144_TEST tests ASA144. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 28 January 2008 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "ASA144_TEST\n"; cout << " C++ version\n"; cout << " Test the ASA144 library.\n"; test01 ( ); // // Terminate. // cout << "\n"; cout << "ASA144_TEST\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void test01 ( ) //****************************************************************************80 // // Purpose: // // TEST01 tests RCONT. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 28 January 2008 // // Author: // // John Burkardt // { # define NROW 5 # define NCOL 5 int ifault; bool key; int matrix[NROW*NCOL]; int ncolt[NCOL] = { 2, 2, 2, 2, 1 }; int nrowt[NROW] = { 3, 2, 2, 1, 1 }; int nsubt[NCOL]; int test; int test_num = 10; cout << "\n"; cout << "TEST01\n"; cout << " RCONT constructs a random matrix with\n"; cout << " given row and column sums.\n"; i4vec_print ( NROW, nrowt, " The rowsum vector:" ); i4vec_print ( NCOL, ncolt, " The columnsum vector: " ); key = false; for ( test = 1; test <= test_num; test++ ) { rcont ( NROW, NCOL, nrowt, ncolt, nsubt, matrix, &key, &ifault ); if ( ifault != 0 ) { cout << "\n"; cout << " RCONT returned IFAULT = " << ifault << "\n"; return; } i4mat_print ( NROW, NCOL, matrix, " The rowcolsum matrix:" ); } return; # undef NROW # undef NCOL } //****************************************************************************80 void timestamp ( ) //****************************************************************************80 // // Purpose: // // TIMESTAMP prints the current YMDHMS date as a time stamp. // // Example: // // May 31 2001 09:45:54 AM // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2003 // // 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 ); cout << time_buffer << "\n"; return; # undef TIME_SIZE }