# include # include # include # include # include using namespace std; # include "normal.hpp" 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 ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // normal_test() tests normal(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 07 December 2023 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "normal_test():\n"; cout << " C++ version\n"; cout << " Test normal()\n"; // // Initialize the rand48() random number generator 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. // cout << "\n"; cout << "normal_test():\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void c8_normal_01_test ( ) //****************************************************************************80 // // 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; complex r; cout << "\n"; cout << "c8_normal_01_test():\n"; cout << " c8_normal_01() computes pseudorandom complex values\n"; cout << " normally distributed in the unit circle.\n"; cout << "\n"; for ( i = 1; i <= 10; i++ ) { r = c8_normal_01 ( ); cout << " " << setw(6) << i << " " << setw(12) << real ( r ) << " " << setw(12) << imag ( r ) << "\n"; } return; } //****************************************************************************80 void c8vec_normal_01_new_test ( ) //****************************************************************************80 // // 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; complex *r; cout << "\n"; cout << "c8vec_normal_01_new_test():\n"; cout << " c8vec_normal_01_new() computes a vector of Normal 01 values.\n"; cout << "\n"; r = c8vec_normal_01_new ( n ); c8vec_print ( n, r, " Random vector:" ); delete [] r; return; } //****************************************************************************80 void i4_normal_ab_test ( ) //****************************************************************************80 // // 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; cout << "\n"; cout << "i4_normal_ab_test():\n"; cout << " i4_normal_ab() computes pseudonormal integer values\n"; cout << " with mean MU and standard deviation SIGMA.\n"; mu = 70.0; sigma = 10.0; cout << "\n"; cout << " The mean = " << mu << "\n"; cout << " The standard deviation = " << sigma << "\n"; cout << "\n"; for ( i = 1; i <= 10; i++ ) { r = i4_normal_ab ( mu, sigma ); cout << " " << setw(8) << i << " " << setw(8) << r << "\n"; } return; } //****************************************************************************80 void r8_normal_01_test ( ) //****************************************************************************80 // // 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; cout << "\n"; cout << "r8_normal_01_test():\n"; cout << " r8_normal_01() computes pseudonormal values\n"; cout << " with mean 0.0 and standard deviation 1.0.\n"; cout << "\n"; for ( i = 1; i <= 10; i++ ) { r = r8_normal_01 ( ); cout << " " << setw(6) << i << " " << setw(14) << r << "\n"; } return; } //****************************************************************************80 void r8_normal_ab_test ( ) //****************************************************************************80 // // 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; cout << "\n"; cout << "r8_normal_ab_test():\n"; cout << " r8_normal_ab() computes pseudonormal values\n"; cout << " with mean MU and standard deviation SIGMA.\n"; mu = 10.0; sigma = 2.0; cout << "\n"; cout << " The mean = " << mu << "\n"; cout << " The standard deviation = " << sigma << "\n"; cout << "\n"; for ( i = 1; i <= 10; i++ ) { r = r8_normal_ab ( mu, sigma ); cout << " " << setw(6) << i << " " << setw(14) << r << "\n"; } return; } //****************************************************************************80 void r8mat_normal_01_new_test ( ) //****************************************************************************80 // // 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; int n; double *r; cout << "\n"; cout << "r8mat_normal_01_new_test():\n"; cout << " r8mat_normal_01_new() computes a matrix of values.\n"; cout << "\n"; m = 5; n = 4; r = r8mat_normal_01_new ( m, n ); r8mat_print ( m, n, r, " Matrix:" ); delete [] r; return; } //****************************************************************************80 void r8vec_normal_01_new_test ( ) //****************************************************************************80 // // 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; cout << "\n"; cout << "r8vec_normal_01_new_test():\n"; cout << " r8vec_normal_01_new() computes a vector of Normal 01 values.\n"; cout << "\n"; r = r8vec_normal_01_new ( n ); r8vec_print ( n, r, " Random vector:" ); delete [] r; 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: // // 08 July 2009 // // Author: // // John Burkardt // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct std::tm *tm_ptr; std::time_t now; now = std::time ( NULL ); tm_ptr = std::localtime ( &now ); std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr ); std::cout << time_buffer << "\n"; return; # undef TIME_SIZE }