# include # include # include # include # include "asa103.h" int main ( ); void digamma_test ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: asa103_test() tests asa103(). Licensing: This code is distributed under the MIT license. Modified: 04 November 2010 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "asa103_test():\n" ); printf ( " C version\n" ); printf ( " Test asa103().\n" ); digamma_test ( ); /* Terminate. */ printf ( "\n" ); printf ( "asa103_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void digamma_test ( ) /******************************************************************************/ /* Purpose: digamma_test() tests digamma(). Licensing: This code is distributed under the MIT license. Modified: 04 November 2010 Author: John Burkardt */ { double fx; double fx2; int ifault; int n_data; double x; printf ( "\n" ); printf ( "digamma_test():\n" ); printf ( " digamma() computes the Digama or Psi function. \n" ); printf ( " Compare the result to tabulated values.\n" ); printf ( "\n" ); printf ( " X " ); printf ( "FX FX2\n" ); printf ( " " ); printf ( "(Tabulated) (DIGAMMA) DIFF\n" ); printf ( "\n" ); n_data = 0; for ( ; ; ) { psi_values ( &n_data, &x, &fx ); if ( n_data == 0 ) { break; } fx2 = digamma ( x, &ifault ); printf ( " %10.4g %24.16g %24.16g %10.4e\n", 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 }