# include # include # include # include # include "normal.h" int main ( ); void c8_normal_01_test ( ); void c8vec_normal_01_new_test ( ); void i4_normal_ab_test ( ); void r8_normal_01_test ( ); void r8_normal_ab_test ( ); void r8mat_normal_01_new_test ( ); void r8vec_normal_01_new_test ( ); void timestamp ( ); /**********************************************************************/ int main ( ) /**********************************************************************/ /* Purpose: normal_test() tests normal(). Licensing: This code is distributed under the MIT license. Modified: 07 December 2023 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "normal_test():\n" ); printf ( " C version\n" ); printf ( " Test normal().\n" ); /* Initialize the rand48() random number library. */ srand ( time ( NULL ) ); c8_normal_01_test ( ); c8vec_normal_01_new_test ( ); i4_normal_ab_test ( ); r8_normal_01_test ( ); r8_normal_ab_test ( ); r8mat_normal_01_new_test ( ); r8vec_normal_01_new_test ( ); /* Terminate. */ printf ( "\n" ); printf ( "normal_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /**********************************************************************/ void c8_normal_01_test ( ) /**********************************************************************/ /* Purpose: c8_normal_01_test() tests c8_normal_01(). Licensing: This code is distributed under the MIT license. Modified: 13 September 2022 Author: John Burkardt */ { int i; double complex r; printf ( "\n" ); printf ( "c8_normal_01_test():\n" ); printf ( " c8_normal_01() computes pseudonormal double complex values\n" ); printf ( " with mean 0.0 and standard deviation 1.0.\n" ); printf ( "\n" ); for ( i = 1; i <= 10; i++ ) { r = c8_normal_01 ( ); printf ( " %6d %14g,%14g\n", i, creal ( r ), cimag ( r ) ); } return; } /**********************************************************************/ void c8vec_normal_01_new_test ( ) /**********************************************************************/ /* Purpose: c8vec_normal_01_new_test() tests c8vec_normal_01_new(). Licensing: This code is distributed under the MIT license. Modified: 07 December 2023 Author: John Burkardt */ { int n = 10; double complex *r; printf ( "\n" ); printf ( "c8vec_normal_01_new_test():\n" ); printf ( " c8vec_normal_01_new() computes a vector of Normal 01 values.\n" ); printf ( "\n" ); r = c8vec_normal_01_new ( n ); c8vec_print ( n, r, " Vector:" ); free ( r ); return; } /**********************************************************************/ void i4_normal_ab_test ( ) /**********************************************************************/ /* Purpose: i4_normal_ab_test() tests i4_normal_ab(). Licensing: This code is distributed under the MIT license. Modified: 13 September 2022 Author: John Burkardt */ { int i; double mu; int r; double sigma; printf ( "\n" ); printf ( "i4_normal_ab_test():\n" ); printf ( " i4_normal_ab() computes pseudonormal integers\n" ); printf ( " with mean MU and standard deviation SIGMA.\n" ); mu = 70.0; sigma = 10.0; printf ( "\n" ); printf ( " The mean = %f\n", mu ); printf ( " The standard deviation = %f\n", sigma ); printf ( "\n" ); for ( i = 1; i <= 10; i++ ) { r = i4_normal_ab ( mu, sigma ); printf ( " %8d %8d\n", i, r ); } return; } /**********************************************************************/ void r8_normal_01_test ( ) /**********************************************************************/ /* Purpose: r8_normal_01_test() tests r8_normal_01(). Licensing: This code is distributed under the MIT license. Modified: 13 September 2022 Author: John Burkardt */ { int i; double r; printf ( "\n" ); printf ( "r8_normal_01_test():\n" ); printf ( " r8_normal_01() computes pseudonormal values\n" ); printf ( " with mean 0.0 and standard deviation 1.0.\n" ); printf ( "\n" ); for ( i = 1; i <= 10; i++ ) { r = r8_normal_01 ( ); printf ( " %6d %14f\n", i, r ); } return; } /**********************************************************************/ void r8_normal_ab_test ( ) /**********************************************************************/ /* Purpose: r8_normal_ab_test() tests r8_normal_ab(). Licensing: This code is distributed under the MIT license. Modified: 13 September 2022 Author: John Burkardt */ { int i; double mu; double r; double sigma; printf ( "\n" ); printf ( "r8_normal_ab_test():\n" ); printf ( " r8_normal_ab() computes pseudonormal values\n" ); printf ( " with mean MU and standard deviation SIGMA.\n" ); mu = 10.0; sigma = 2.0; printf ( "\n" ); printf ( " The mean = %f\n", mu ); printf ( " The standard deviation = %f\n", sigma ); printf ( "\n" ); for ( i = 1; i <= 10; i++ ) { r = r8_normal_ab ( mu, sigma ); printf ( " %6d %14f\n", i, r ); } return; } /**********************************************************************/ void r8mat_normal_01_new_test ( ) /**********************************************************************/ /* Purpose: r8mat_normal_01_new_test() tests r8mat_normal_01_new(). Licensing: This code is distributed under the MIT license. Modified: 13 September 2022 Author: John Burkardt */ { int m = 5; int n = 4; double *r; printf ( "\n" ); printf ( "r8mat_normal_01_new_test():\n" ); printf ( " r8mat_normal_01_new() computes a matrix of Normal 01 values.\n" ); printf ( "\n" ); r = r8mat_normal_01_new ( m, n ); r8mat_print ( m, n, r, " Matrix:" ); free ( r ); return; } /**********************************************************************/ void r8vec_normal_01_new_test ( ) /**********************************************************************/ /* Purpose: r8vec_normal_01_new_test() tests r8vec_normal_01_new(). Licensing: This code is distributed under the MIT license. Modified: 13 September 2022 Author: John Burkardt */ { int n = 10; double *r; printf ( "\n" ); printf ( "r8vec_normal_01_new_test():\n" ); printf ( " r8vec_normal_01_new() computes a vector of Normal 01 values.\n" ); printf ( "\n" ); r = r8vec_normal_01_new ( n ); r8vec_print ( n, r, " Vector:" ); free ( r ); return; } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* Purpose: timestamp() prints the current YMDHMS date as a time stamp. Example: May 31 2001 09:45:54 AM Licensing: This code is distributed under the MIT license. Modified: 13 September 2022 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 }