# include # include # include # include # include # include "asa226.hpp" using namespace std; int main ( ); void test01 ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // asa226_test() tests asa226(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 24 January 2008 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "asa226_test():\n"; cout << " C++ version\n"; cout << " Test asa226().\n"; test01 ( ); // // Terminate. // cout << "\n"; cout << "asa226_test():\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void test01 ( ) //****************************************************************************80 // // Purpose: // // test01() tests betanc(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 24 January 2008 // // Author: // // John Burkardt // { double a; double b; double fx; double fx2; int ifault; double lambda; int n_data; double x; cout << "\n"; cout << "test01():\n"; cout << " betanc() computes the noncentral incomplete Beta function.\n"; cout << " Compare to tabulated values.\n"; cout << "\n"; cout << " A B LAMBDA X " << " FX FX2\n"; cout << " " << " (Tabulated) (BETANC) DIFF\n"; cout << "\n"; n_data = 0; for ( ; ; ) { beta_noncentral_cdf_values ( &n_data, &a, &b, &lambda, &x, &fx ); if ( n_data == 0 ) { break; } fx2 = betanc ( x, a, b, lambda, &ifault ); cout << " " << setprecision(2) << setw(7) << a << " " << setprecision(2) << setw(7) << b << " " << setprecision(3) << setw(7) << lambda << " " << setprecision(4) << setw(10) << x << " " << setprecision(16) << setw(24) << fx << " " << setprecision(16) << setw(24) << fx2 << " " << setprecision(4) << setw(10) << fabs ( fx - fx2 ) << "\n"; } return; } //****************************************************************************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 }