# include # include # include # include "r8to.h" int main ( ); void r8to_dif2_test ( ); void r8to_indicator_test ( ); void r8to_mtv_test ( ); void r8to_mv_test ( ); void r8to_print_test ( ); void r8to_print_some_test ( ); void r8to_random_test ( ); void r8to_sl_test ( ); void r8to_slt_test ( ); void r8to_to_r8ge_test ( ); void r8to_zeros_test ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: MAIN is the main program for R8TO_TEST. Discussion: R8TO_TEST tests the R8TO library. Licensing: This code is distributed under the GNU LGPL license. Modified: 26 September 2015 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "R8TO_TEST\n" ); printf ( " C version\n" ); printf ( " Test the R8TO library.\n" ); r8to_dif2_test ( ); r8to_indicator_test ( ); r8to_mtv_test ( ); r8to_mv_test ( ); r8to_print_test ( ); r8to_print_some_test ( ); r8to_random_test ( ); r8to_sl_test ( ); r8to_slt_test ( ); r8to_to_r8ge_test ( ); r8to_zeros_test ( ); /* Terminate. */ printf ( "\n" ); printf ( "R8TO_TEST\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void r8to_dif2_test ( ) /******************************************************************************/ /* Purpose: R8TO_DIF2_TEST tests R8TO_DIF2. Licensing: This code is distributed under the GNU LGPL license. Modified: 25 September 2015 Author: John Burkardt */ { double *a; int n = 5; printf ( "\n" ); printf ( "R8TO_DIF2_TEST\n" ); printf ( " R8TO_DIF2 sets the second difference as an R8TO matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r8to_dif2 ( n ); r8to_print ( n, a, " The R8TO matrix:" ); free ( a ); return; } /******************************************************************************/ void r8to_indicator_test ( ) /******************************************************************************/ /* Purpose: R8TO_INDICATOR_TEST tests R8TO_INDICATOR. Licensing: This code is distributed under the GNU LGPL license. Modified: 07 April 2013 Author: John Burkardt */ { double *a; int n = 5; printf ( "\n" ); printf ( "R8TO_INDICATOR_TEST\n" ); printf ( " R8TO_INDICATOR sets up an R8TO indicator matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r8to_indicator ( n ); r8to_print ( n, a, " The R8TO indicator matrix:" ); free ( a ); return; } /******************************************************************************/ void r8to_mtv_test ( ) /******************************************************************************/ /* Purpose: R8TO_MTV_TEST tests R8TO_MTV. Licensing: This code is distributed under the GNU LGPL license. Modified: 26 September 2015 Author: John Burkardt */ { double *a; double *b; int n = 5; int seed = 123456789; double *x; printf ( "\n" ); printf ( "R8TO_MTV_TEST\n" ); printf ( " R8TO_MTV computes b=A'*x=b, where A is an R8TO matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r8to_indicator ( n ); r8to_print ( n, a, " The Toeplitz matrix:" ); x = r8vec_indicator1_new ( n ); r8vec_print ( n, x, " x:" ); /* Compute b=A'*x. */ b = r8to_mtv ( n, a, x ); r8vec_print ( n, b, " b=A'*x:" ); free ( a ); free ( b ); free ( x ); return; } /******************************************************************************/ void r8to_mv_test ( ) /******************************************************************************/ /* Purpose: R8TO_MV_TEST tests R8TO_MV. Licensing: This code is distributed under the GNU LGPL license. Modified: 26 September 2015 Author: John Burkardt */ { double *a; double *b; int n = 5; int seed = 123456789; double *x; printf ( "\n" ); printf ( "R8TO_MV_TEST\n" ); printf ( " R8TO_MV computes b=A*x=b, where A is an R8TO matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r8to_indicator ( n ); r8to_print ( n, a, " The Toeplitz matrix:" ); x = r8vec_indicator1_new ( n ); r8vec_print ( n, x, " x:" ); /* Compute b=A*x. */ b = r8to_mv ( n, a, x ); r8vec_print ( n, b, " b=A*x:" ); free ( a ); free ( b ); free ( x ); return; } /******************************************************************************/ void r8to_print_test ( ) /******************************************************************************/ /* Purpose: R8TO_PRINT_TEST tests R8TO_PRINT. Licensing: This code is distributed under the GNU LGPL license. Modified: 26 September 2015 Author: John Burkardt */ { double *a; int n = 5; printf ( "\n" ); printf ( "R8TO_PRINT_TEST\n" ); printf ( " R8TO_PRINT prints an R8TO matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r8to_indicator ( n ); r8to_print ( n, a, " The R8TO indicator matrix:" ); free ( a ); return; } /******************************************************************************/ void r8to_print_some_test ( ) /******************************************************************************/ /* Purpose: R8TO_PRINT_SOME_TEST tests R8TO_PRINT_SOME. Licensing: This code is distributed under the GNU LGPL license. Modified: 26 September 2015 Author: John Burkardt */ { double *a; int n = 5; printf ( "\n" ); printf ( "R8TO_PRINT_SOME_TEST\n" ); printf ( " R8TO_PRINT_SOME prints some of an R8TO matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r8to_indicator ( n ); r8to_print_some ( n, a, 1, 0, 4, 2, " Rows 1:4, Cols 0:2" ); free ( a ); return; } /******************************************************************************/ void r8to_random_test ( ) /******************************************************************************/ /* Purpose: R8TO_RANDOM_TEST tests R8TO_RANDOM. Licensing: This code is distributed under the GNU LGPL license. Modified: 26 September 2015 Author: John Burkardt */ { double *a; int n = 5; int seed = 123456789; printf ( "\n" ); printf ( "R8TO_RANDOM_TEST\n" ); printf ( " R8TO_RANDOM randomizes an R8TO matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); /* Set the matrix. */ a = r8to_random ( n, &seed ); r8to_print ( n, a, " The Toeplitz matrix:" ); free ( a ); return; } /******************************************************************************/ void r8to_sl_test ( ) /******************************************************************************/ /* Purpose: R8TO_SL_TEST tests R8TO_SL. Licensing: This code is distributed under the GNU LGPL license. Modified: 25 September 2015 Author: John Burkardt */ { double *a; double *b; int n = 5; int seed = 123456789; double *x; printf ( "\n" ); printf ( "R8TO_SL_TEST\n" ); printf ( " R8TO_SL solves a Toeplitz system.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); /* Set the matrix. */ a = r8to_random ( n, &seed ); r8to_print ( n, a, " The Toeplitz matrix:" ); // // Set the desired solution. // x = r8vec_indicator1_new ( n ); // // Compute the corresponding right hand side. // b = r8to_mv ( n, a, x ); // // Solve the linear system. // free ( x ); x = r8to_sl ( n, a, b ); r8vec_print ( n, x, " Solution:" ); free ( a ); free ( b ); free ( x ); return; } /******************************************************************************/ void r8to_slt_test ( ) /******************************************************************************/ /* Purpose: R8TO_SLT_TEST tests R8TO_SLT. Licensing: This code is distributed under the GNU LGPL license. Modified: 06 April 2013 Author: John Burkardt */ { double *a; double *b; int n = 5; int seed = 123456789; double *x; printf ( "\n" ); printf ( "R8TO_SLT_TEST\n" ); printf ( " R8TO_SLT solves A'*x=b, where A is an R8TO matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); /* Set the matrix. */ a = r8to_random ( n, &seed ); r8to_print ( n, a, " The Toeplitz matrix:" ); // // Set the desired solution. // x = r8vec_indicator1_new ( n ); // // Compute the corresponding right hand side. // b = r8to_mtv ( n, a, x ); // // Solve the linear system. // free ( x ); x = r8to_slt ( n, a, b ); r8vec_print ( n, x, " Solution to transposed system:" ); free ( a ); free ( b ); free ( x ); return; } /******************************************************************************/ void r8to_to_r8ge_test ( ) /******************************************************************************/ /* Purpose: R8TO_TO_R8GE_TEST tests R8TO_TO_R8GE. Licensing: This code is distributed under the GNU LGPL license. Modified: 26 September 2015 Author: John Burkardt */ { double *a_r8ge; double *a_r8to; int n = 5; int seed = 123456789; printf ( "\n" ); printf ( "R8TO_TO_R8GE_TEST\n" ); printf ( " R8TO_TO_R8GE converts an R8TO matrix to R8GE format.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a_r8to = r8to_random ( n, &seed ); r8to_print ( n, a_r8to, " The R8TO matrix:" ); a_r8ge = r8to_to_r8ge ( n, a_r8to ); r8ge_print ( n, n, a_r8ge, " The R8GE matrix:" ); free ( a_r8ge ); free ( a_r8to ); return; } /******************************************************************************/ void r8to_zeros_test ( ) /******************************************************************************/ /* Purpose: R8TO_ZEROS_TEST tests R8TO_ZEROS. Licensing: This code is distributed under the GNU LGPL license. Modified: 26 September 2015 Author: John Burkardt */ { double *a; int n = 5; printf ( "\n" ); printf ( "R8TO_ZEROS_TEST\n" ); printf ( " R8TO_ZEROS zeros an R8TO matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r8to_zeros ( n ); r8to_print ( n, a, " The R8TO matrix:" ); free ( a ); return; }