# include # include # include # include using namespace std; # include "c8poly.hpp" int main ( ); void c8poly_print_test ( ); void roots_to_c8poly_test ( ); void c8vec_print ( int n, complex a[], string title ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // c8poly_test() tests c8poly(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 08 December 2019 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "c8poly_test():\n"; cout << " C++ version\n"; cout << " Test c8poly().\n"; c8poly_print_test ( ); roots_to_c8poly_test ( ); // // Terminate. // cout << "\n"; cout << "c8poly_test():\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void c8poly_print_test ( ) //****************************************************************************80 // // Purpose: // // c8poly_print_test() tests c8poly_print(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 08 December 2023 // // Author: // // John Burkardt // { int n = 5; complex c[6] = { complex ( 1.0, 2.0 ), complex ( -3.0, 4.0 ), complex ( 5.0, 6.0 ), complex ( 7.0, 8.0 ), complex ( 9.0, 10.0 ), complex ( 11.0, 12.0 ) }; cout << "\n"; cout << "c8poly_print_test():\n"; cout << " c8poly_print() prints a C8POLY.\n"; c8poly_print ( n, c, " The C8POLY:" ); return; } //****************************************************************************// void roots_to_c8poly_test ( ) //****************************************************************************// // // Purpose: // // roots_to_r8poly_test() tests roots_to_c8poly(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 08 December 2023 // // Author: // // John Burkardt // { complex *c; int n = 5; complex r[5] = { complex ( 1.0, 0.0 ), complex ( -4.0, 0.0 ), complex ( 3.0, 0.0 ), complex ( 0.0, 0.0 ), complex ( 3.0, 0.0 ) }; cout << "\n"; cout << "roots_to_c8poly_test():\n"; cout << " roots_to_c8poly() is given N complex roots,\n"; cout << " and constructs the coefficient vector\n"; cout << " of the corresponding polynomial.\n"; c8vec_print ( n, r, " Roots:" ); c = roots_to_c8poly ( n, r ); c8poly_print ( n, c, " Corresponding polynomial:" ); delete [] c; return; } //****************************************************************************80 void c8vec_print ( int n, complex a[], string title ) //****************************************************************************80 // // Purpose: // // c8vec_print() prints a C8VEC. // // Discussion: // // A C8VEC is a vector of complex values. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 10 September 2009 // // Author: // // John Burkardt // // Input: // // int N, the number of components of the vector. // // complex A[N], the vector to be printed. // // string TITLE, a title. // { int i; cout << "\n"; cout << title << "\n"; cout << "\n"; for ( i = 0; i < n; i++ ) { cout << " " << setw(8) << i << ": " << real ( a[i] ) << " " << imag ( a[i] ) << "\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: // // 19 March 2018 // // 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 }