# include # include # include # include # include "c8poly.h" int main ( ); void c8poly_print_test ( ); void roots_to_c8poly_test ( ); void c8vec_print ( int n, double complex a[], char *title ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: c8poly_test() tests c8poly(). Licensing: This code is distributed under the MIT license. Modified: 07 December 2019 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "c8poly_test():\n" ); printf ( " C version\n" ); printf ( " Test c8poly().\n" ); c8poly_print_test ( ); roots_to_c8poly_test ( ); /* Terminate. */ printf ( "\n" ); printf ( "c8poly_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void c8poly_print_test ( ) /******************************************************************************/ /* Purpose: c8poly_print_test() tests c8poly_print(). Licensing: This code is distributed under the MIT license. Modified: 07 December 2023 Author: John Burkardt */ { int n = 5; double complex c[6] = { 1.0 + 2.0 * I, -3.0 + 4.0 * I, 5.0 + 6.0 * I, 7.0 + 8.0 * I, 9.0 + 10.0 * I, 11.0 + 12.0 * I }; printf ( "\n" ); printf ( "c8poly_print_test():\n" ); printf ( " 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: 07 December 2023 Author: John Burkardt */ { double complex *c; int n = 5; double complex r[5] = { 1.0, -4.0, 3.0, 0.0, 3.0 }; printf ( "\n" ); printf ( "roots_to_c8poly_test():\n" ); printf ( " roots_to_c8poly() is given N complex roots,\n" ); printf ( " and constructs the coefficient vector\n" ); printf ( " of the corresponding polynomial.\n" ); c8vec_print ( n, r, " Roots:" ); c = roots_to_c8poly ( n, r ); c8poly_print ( n, c, " Corresponding polynomial:" ); free ( c ); return; } /******************************************************************************/ void c8vec_print ( int n, double complex a[], char *title ) /******************************************************************************/ /* Purpose: c8vec_print() prints a C8VEC. Discussion: A C8VEC is a vector of double complex values. Licensing: This code is distributed under the MIT license. Modified: 27 January 2013 Author: John Burkardt Input: int N, the number of components of the vector. double complex A[N], the vector to be printed. char *TITLE, a title. */ { int i; fprintf ( stdout, "\n" ); fprintf ( stdout, "%s\n", title ); fprintf ( stdout, "\n" ); for ( i = 0; i < n; i++ ) { fprintf ( stdout, " %8d: %14f %14f\n", i, creal ( a[i] ), cimag ( a[i] ) ); } 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: 01 May 2021 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 }