# include # include # include # include # include "asa299.h" int main ( ); void test01 ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: asa299_test() tests asa299(). Licensing: This code is distributed under the MIT license. Modified: 10 January 2007 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "asa299_test():\n" ); printf ( " C version\n" ); printf ( " Test asa299().\n" ); test01 ( ); /* Terminate. */ printf ( "\n" ); printf ( "asa299_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void test01 ( ) /******************************************************************************/ /* 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; int more; int t = 4; int x[N]; printf ( "\n" ); printf ( "test01():\n" ); printf ( " simplex_lattice_point_next() generates lattice points\n" ); printf ( " in the simplex\n" ); printf ( " 0 <= X\n" ); printf ( " sum ( X(1:N) ) <= T\n" ); printf ( " Here N = %d\n", N ); printf ( " and T = %d\n", t ); printf ( "\n" ); printf ( " Index X(1) X(2) X(3) X(4)\n" ); printf ( "\n" ); more = 0; i = 0; for ( ; ; ) { simplex_lattice_point_next ( N, t, &more, x ); i = i + 1; printf ( " %8d ", i ); for ( j = 0; j < N; j++ ) { printf ( " %8d", x[j] ); } printf ( "\n" ); if ( !more ) { break; } } return; # undef N } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* Purpose: timestamp() prints the current YMDHMS date as a time stamp. Example: 17 June 2014 09:45:54 AM Licensing: This code is distributed under the MIT license. Modified: 17 June 2014 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 ); printf ( "%s\n", time_buffer ); return; # undef TIME_SIZE }