# include # include # include # include # include "asa032.h" int main ( ); void test01 ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: asa032_test() tests asa032(). Licensing: This code is distributed under the MIT license. Modified: 26 October 2010 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "asa032_test():\n" ); printf ( " C version \n" ); printf ( " Test asa032().\n" ); test01 ( ); /* Terminate. */ printf ( "\n" ); printf ( "asa032_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void test01 ( ) /******************************************************************************/ /* Purpose: test01() tests gamain(). Licensing: This code is distributed under the MIT license. Modified: 17 January 2008 Author: John Burkardt */ { double a; double fx; double fx2; int ifault; int n_data; double x; printf ( "\n" ); printf ( "test01():\n" ); printf ( " gamain() computes the incomplete Gamma function.\n" ); printf ( " Compare the result to tabulated values.\n" ); printf ( "\n" ); printf ( " A X " ); printf ( "FX FX2\n" ); printf ( " " ); printf ( "(Tabulated) (GAMAIN) DIFF\n" ); printf ( "\n" ); n_data = 0; for ( ; ; ) { gamma_inc_p_values ( &n_data, &a, &x, &fx ); if ( n_data == 0 ) { break; } fx2 = gamain ( x, a, &ifault ); printf ( " %12.8g %12.8g %24.16g %24.16g %10.4e\n", a, x, fx, fx2, fabs ( fx - fx2 ) ); } return; } /******************************************************************************/ 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 }