# include # include # include # include using namespace std; # include "asa299.hpp" int main ( ); void test01 ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // asa299_test() tests asa299(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 10 January 2007 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "asa299_test():\n"; cout << " C++ version\n"; cout << " Test asa299().\n"; test01 ( ); // // Terminate. // cout << "\n"; cout << "asa299_test():\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void test01 ( ) //****************************************************************************80 // // Purpose: // // test01() tests simplex_lattice_point_next(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 10 January 2007 // // Author: // // John Burkardt // { # define N 4 int i; int j; bool more; int t = 4; int x[N]; cout << "\n"; cout << "test01():\n"; cout << " simplex_lattice_point_next() generates lattice points\n"; cout << " in the simplex\n"; cout << " 0 <= X\n"; cout << " sum ( X(1:N) ) <= T\n"; cout << " Here N = " << N << "\n"; cout << " and T = " << t << "\n"; cout << "\n"; cout << " Index X(1) X(2) X(3) X(4)\n"; cout << "\n"; more = false; i = 0; for ( ; ; ) { simplex_lattice_point_next ( N, t, &more, x ); i = i + 1; cout << " " << setw(8) << i; cout << " "; for ( j = 0; j < N; j++ ) { cout << " " << setw(8) << x[j]; } cout << "\n"; if ( !more ) { break; } } return; # undef N } //****************************************************************************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: // // 24 September 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 }