# include # include # include # include # include "asa076.h" int main ( ); void test01 ( ); void test02 ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: asa076_test() tests asa076(). Licensing: This code is distributed under the MIT license. Modified: 02 November 2010 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "asa076_test():\n" ); printf ( " C version\n" ); printf ( " Test asa076().\n" ); test01 ( ); test02 ( ); /* Terminate. */ printf ( "\n" ); printf ( "asa076_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void test01 ( ) /******************************************************************************/ /* Purpose: TEST01 tests TFN. Licensing: This code is distributed under the MIT license. Modified: 02 November 2010 Author: John Burkardt */ { double a; double h; int n_data; double t1; double t2; printf ( "\n" ); printf ( "TEST01():\n" ); printf ( " TFN() computes Owen's T function.\n" ); printf ( " Compare to tabulated values.\n" ); printf ( "\n" ); printf ( " H A " ); printf ( " T T \n" ); printf ( " " ); printf ( " (Tabulated) (TFN) DIFF\n" ); printf ( "\n" ); n_data = 0; for ( ; ; ) { owen_values ( &n_data, &h, &a, &t1 ); if ( n_data == 0 ) { break; } t2 = tfn ( h, a ); printf ( " %12.4f %12.4f %24.16g %24.16g %10.4e\n", h, a, t1, t2, fabs ( t1 - t2 ) ); } return; } /******************************************************************************/ void test02 ( ) /******************************************************************************/ /* Purpose: TEST02() tests THA(). Licensing: This code is distributed under the MIT license. Modified: 02 November 2010 Author: John Burkardt */ { double a; double h; int n_data; double one = 1.0; double t1; double t2; printf ( "\n" ); printf ( "TEST02():\n" ); printf ( " THA() computes Owen's T function.\n" ); printf ( " Compare to tabulated values.\n" ); printf ( "\n" ); printf ( " H A " ); printf ( " T T \n" ); printf ( " " ); printf ( " (Tabulated) (THA) DIFF\n" ); printf ( "\n" ); n_data = 0; for ( ; ; ) { owen_values ( &n_data, &h, &a, &t1 ); if ( n_data == 0 ) { break; } t2 = tha ( h, one, a, one ); printf ( " %12.4f %12.4f %24.16g %24.16g %10.4e\n", h, a, t1, t2, fabs ( t1 - t2 ) ); } 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 }