# include # include # include # include # include "asa310.h" int main ( ); void test01 ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: ASA310_TEST tests the ASA310 library. Licensing: This code is distributed under the MIT license. Modified: 20 November 2010 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "ASA310_TEST:\n" ); printf ( " C version\n" ); printf ( " Test the ASA310 library.\n" ); test01 ( ); /* Terminate. */ printf ( "\n" ); printf ( "ASA310_TEST:\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void test01 ( ) /******************************************************************************/ /* Purpose: TEST01 demonstrates the use of NCBETA. Licensing: This code is distributed under the MIT license. Modified: 20 November 2010 Author: John Burkardt */ { double a; double b; double errmax = 1.0E-10; double fx; double fx2; int ifault; double lambda; int n_data; double x; printf ( "\n" ); printf ( "TEST01:\n" ); printf ( " NCBETA computes the noncentral incomplete Beta function.\n" ); printf ( " Compare to tabulated values.\n" ); printf ( "\n" ); printf ( " A B LAMBDA X " ); printf ( " FX FX2\n" ); printf ( " " ); printf ( " (Tabulated) (NCBETA) DIFF\n" ); printf ( "\n" ); n_data = 0; for ( ; ; ) { beta_noncentral_cdf_values ( &n_data, &a, &b, &lambda, &x, &fx ); if ( n_data == 0 ) { break; } fx2 = ncbeta ( a, b, lambda, x, errmax, &ifault ); printf ( " %7.2f %7.2f %7.3f %10.4f %24.16f %24.16f %10.4e\n", a, b, lambda, 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 }