# include # include # include # include # include using namespace std; # include "asa159.hpp" int main ( ); void test01 ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // ASA159_TEST tests ASA159. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 10 March 2009 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "ASA159_TEST\n"; cout << " C++ version\n"; cout << " Test the ASA159 library.\n"; test01 ( ); // // Terminate. // cout << "\n"; cout << "ASA159_TEST\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void test01 ( ) //****************************************************************************80 // // Purpose: // // TEST01 tests RCONT2. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 10 March 2009 // // Author: // // John Burkardt // { # define M 5 # define N 5 int a[M*N]; int c[N] = { 2, 2, 2, 2, 1 }; int i; int ierror; bool key = false; int m = M; int n = N; int ntest = 10; int r[M] = { 3, 2, 2, 1, 1 }; int seed; seed = 123456789; cout << "\n"; cout << "TEST01\n"; cout << " RCONT2 constructs a random matrix with\n"; cout << " given row and column sums.\n"; i4vec_print ( m, r, " The rowsum vector:" ); i4vec_print ( n, c, " The columnsum vector:" ); for ( i = 1; i <= ntest; i++ ) { rcont2 ( m, n, r, c, &key, &seed, a, &ierror ); if ( ierror != 0 ) { cout << "\n"; cout << " RCONT2 returned error flag IERROR = " << ierror << "\n"; return; } i4mat_print ( m, n, a, " The rowcolsum matrix:" ); } return; } //****************************************************************************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 }