# include # include # include # include # include "r8bto.h" int main ( ); void r8bto_dif2_test ( ); void r8bto_indicator_test ( ); void r8bto_mtv_test ( ); void r8bto_mv_test ( ); void r8bto_print_test ( ); void r8bto_print_some_test ( ); void r8bto_random_test ( ); void r8bto_to_r8ge_test ( ); void r8bto_zeros_test ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: r8bto_test() tests r8bto(). Licensing: This code is distributed under the MIT license. Modified: 18 August 2022 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "r8bto_test():\n" ); printf ( " C version\n" ); printf ( " Test r8bto().\n" ); r8bto_dif2_test ( ); r8bto_indicator_test ( ); r8bto_mtv_test ( ); r8bto_mv_test ( ); r8bto_print_test ( ); r8bto_print_some_test ( ); r8bto_random_test ( ); r8bto_to_r8ge_test ( ); r8bto_zeros_test ( ); /* Terminate. */ printf ( "\n" ); printf ( "r8bto_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void r8bto_dif2_test ( ) /******************************************************************************/ /* Purpose: R8BTO_DIF2_TEST tests R8BTO_DIF2. Licensing: This code is distributed under the MIT license. Modified: 05 July 2016 Author: John Burkardt */ { double *a; int l = 5; int m = 1; printf ( "\n" ); printf ( "R8BTO_DIF2_TEST\n" ); printf ( " R8BTO_DIF2 sets up an R8BTO second difference matrix.\n" ); printf ( "\n" ); printf ( " Block order M = %d\n", m ); printf ( " Block number L = %d\n", l ); printf ( " Matrix order N = %d\n", m * l ); a = r8bto_dif2 ( m, l ); r8bto_print ( m, l, a, " The R8BTO second difference matrix:" ); free ( a ); return; } /******************************************************************************/ void r8bto_indicator_test ( ) /******************************************************************************/ /* Purpose: R8BTO_INDICATOR_TEST tests R8BTO_INDICATOR. Licensing: This code is distributed under the MIT license. Modified: 11 March 2013 Author: John Burkardt */ { # define L 3 # define M 2 double *a; printf ( "\n" ); printf ( "R8BTO_INDICATOR_TEST\n" ); printf ( " R8BTO_INDICATOR sets up an R8BTO indicator matrix.\n" ); printf ( "\n" ); printf ( " Block order M = %d\n", M ); printf ( " Block number L = %d\n", L ); printf ( " Matrix order N = %d\n", M * L ); a = r8bto_indicator ( M, L ); r8bto_print ( M, L, a, " The block Toeplitz matrix:" ); free ( a ); return; # undef L # undef M } /******************************************************************************/ void r8bto_mtv_test ( ) /******************************************************************************/ /* Purpose: R8BTO_MTV_TEST tests R8BTO_MTV. Licensing: This code is distributed under the MIT license. Modified: 11 March 2013 Author: John Burkardt */ { # define L 3 # define M 2 # define N ( M * L ) double a[M*M*(2*L-1)] = { 1.0, 5.0, 2.0, 5.0, 3.0, 6.0, 4.0, 6.0, 5.0, 7.0, 6.0, 7.0, 7.0, 8.0, 8.0, 8.0, 9.0, 9.0, 0.0, 9.0 }; double *b; double *x; printf ( "\n" ); printf ( "R8BTO_MTV_TEST\n" ); printf ( " R8BTO_MTV computes A'* x for an R8BTO matrix.\n" ); printf ( "\n" ); printf ( " Block order M = %d\n", M ); printf ( " Block number L = %d\n", L ); printf ( " Matrix order N = %d\n", N ); r8bto_print ( M, L, a, " The block Toeplitz matrix:" ); x = r8ge_indicator ( M, L ); r8ge_print ( M, L, x, " The 'vector' x:" ); b = r8bto_mtv ( M, L, a, x ); r8ge_print ( M, L, b, " The product A'*x:" ); free ( b ); free ( x ); return; # undef L # undef M # undef N } /******************************************************************************/ void r8bto_mv_test ( ) /******************************************************************************/ /* Purpose: R8BTO_MV_TEST tests R8BTO_MV. Licensing: This code is distributed under the MIT license. Modified: 11 March 2013 Author: John Burkardt */ { # define L 3 # define M 2 # define N ( M * L ) double a[M*M*(2*L-1)] = { 1.0, 5.0, 2.0, 5.0, 3.0, 6.0, 4.0, 6.0, 5.0, 7.0, 6.0, 7.0, 7.0, 8.0, 8.0, 8.0, 9.0, 9.0, 0.0, 9.0 }; double *b; double *x; printf ( "\n" ); printf ( "R8BTO_MV_TEST\n" ); printf ( " R8BTO_MV computes A * x for an R8BTO matrix.\n" ); printf ( "\n" ); printf ( " Block order M = %d\n", M ); printf ( " Block number L = %d\n", L ); printf ( " Matrix order N = %d\n", N ); r8bto_print ( M, L, a, " The block Toeplitz matrix:" ); x = r8ge_indicator ( M, L ); r8ge_print ( M, L, x, " The 'vector' x:" ); b = r8bto_mv ( M, L, a, x ); r8ge_print ( M, L, b, " The product A*x:" ); free ( b ); free ( x ); return; # undef L # undef M # undef N } /******************************************************************************/ void r8bto_print_test ( ) /******************************************************************************/ /* Purpose: R8BTO_PRINT_TEST tests R8BTO_PRINT. Licensing: This code is distributed under the MIT license. Modified: 06 July 2016 Author: John Burkardt */ { # define L 3 # define M 2 double *a; printf ( "\n" ); printf ( "R8BTO_PRINT_TEST\n" ); printf ( " R8BTO_PRINT prints an R8BTO matrix.\n" ); printf ( "\n" ); printf ( " Block order M = %d\n", M ); printf ( " Block number L = %d\n", L ); printf ( " Matrix order N = %d\n", M * L ); a = r8bto_indicator ( M, L ); r8bto_print ( M, L, a, " The R8BTO matrix:" ); free ( a ); return; # undef L # undef M } /******************************************************************************/ void r8bto_print_some_test ( ) /******************************************************************************/ /* Purpose: R8BTO_PRINT_SOME_TEST tests R8BTO_PRINT_SOME. Licensing: This code is distributed under the MIT license. Modified: 07 July 2016 Author: John Burkardt */ { # define L 3 # define M 2 double *a; printf ( "\n" ); printf ( "R8BTO_PRINT_SOME_TEST\n" ); printf ( " R8BTO_PRINT_SOME prints some of an R8BTO matrix.\n" ); printf ( "\n" ); printf ( " Block order M = %d\n", M ); printf ( " Block number L = %d\n", L ); printf ( " Matrix order N = %d\n", M * L ); a = r8bto_indicator ( M, L ); r8bto_print_some ( M, L, a, 0, 2, 5, 3, " Row (0:5), Cols (2:3):" ); free ( a ); return; # undef L # undef M } /******************************************************************************/ void r8bto_random_test ( ) /******************************************************************************/ /* Purpose: R8BTO_RANDOM_TEST tests R8BTO_RANDOM. Licensing: This code is distributed under the MIT license. Modified: 07 July 2016 Author: John Burkardt */ { # define L 3 # define M 2 double *a; int seed; printf ( "\n" ); printf ( "R8BTO_RANDOM_TEST\n" ); printf ( " R8BTO_RANDOM randomizes an R8BTO matrix.\n" ); printf ( "\n" ); printf ( " Block order M = %d\n", M ); printf ( " Block number L = %d\n", L ); printf ( " Matrix order N = %d\n", M * L ); seed = 123456789; a = r8bto_random ( M, L, &seed ); r8bto_print ( M, L, a, " The random R8BTO matrix:" ); free ( a ); return; # undef L # undef M } /******************************************************************************/ void r8bto_to_r8ge_test ( ) /******************************************************************************/ /* Purpose: R8BTO_TO_R8GE_TEST tests R8BTO_TO_R8GE. Licensing: This code is distributed under the MIT license. Modified: 07 July 2016 Author: John Burkardt */ { # define L 3 # define M 2 double *a; double *a_r8ge; int n; n = M * L; printf ( "\n" ); printf ( "R8BTO_TO_R8GE_TEST\n" ); printf ( " R8BTO_TO_R8GE converts an R8BTO matrix to R8GE format.\n" ); printf ( "\n" ); printf ( " Block order M = %d\n", M ); printf ( " Block number L = %d\n", L ); printf ( " Matrix order N = %d\n", n ); a = r8bto_indicator ( M, L ); r8bto_print ( M, L, a, " The R8BTO matrix:" ); a_r8ge = r8bto_to_r8ge ( M, L, a ); r8ge_print ( n, n, a_r8ge, " The R8GE matrix:" ); free ( a ); free ( a_r8ge ); return; # undef L # undef M } /******************************************************************************/ void r8bto_zeros_test ( ) /******************************************************************************/ /* Purpose: R8BTO_ZEROS_TEST tests R8BTO_ZEROS. Licensing: This code is distributed under the MIT license. Modified: 06 July 2016 Author: John Burkardt */ { # define L 3 # define M 2 double *a; printf ( "\n" ); printf ( "R8BTO_ZEROS_TEST\n" ); printf ( " R8BTO_ZEROS zeros an R8BTO matrix.\n" ); printf ( "\n" ); printf ( " Block order M = %d\n", M ); printf ( " Block number L = %d\n", L ); printf ( " Matrix order N = %d\n", M * L ); a = r8bto_zeros ( M, L ); r8bto_print ( M, L, a, " The zero R8BTO matrix:" ); free ( a ); return; # undef L # undef M } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* 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: 24 September 2003 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 }