# include # include # include # include "r8but.h" int main ( ); void test05 ( ); void r8but_det_test ( ); void r8but_indicator_test ( ); void r8but_mtv_test ( ); void r8but_mv_test ( ); void r8but_print_test ( ); void r8but_print_some_test ( ); void r8but_random_test ( ); void r8but_sl_test ( ); void r8but_slt_test ( ); void r8but_to_r8ge_test ( ); void r8but_zeros_test ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: MAIN is the main program for R8BUT_TEST. Discussion: R8BUT_TEST tests R8BUT. Licensing: This code is distributed under the GNU LGPL license. Modified: 12 October 2015 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "R8BUT_TEST\n" ); printf ( " C version\n" ); printf ( " Test the R8BUT library.\n" ); r8but_det_test ( ); r8but_indicator_test ( ); r8but_mtv_test ( ); r8but_mv_test ( ); r8but_print_test ( ); r8but_print_some_test ( ); r8but_random_test ( ); r8but_sl_test ( ); r8but_slt_test ( ); r8but_to_r8ge_test ( ); r8but_zeros_test ( ); /* Terminate. */ printf ( "\n" ); printf ( "R8BUT_TEST\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void r8but_det_test ( ) /******************************************************************************/ /* Purpose: R8BUT_DET_TEST tests R8BUT_DET. Licensing: This code is distributed under the GNU LGPL license. Modified: 08 October 2015 Author: John Burkardt */ { # define MU 3 # define N 5 double *a; double det; int seed = 123456789; printf ( "\n" ); printf ( "R8BUT_DET\n" ); printf ( " R8BUT_DET computes the determinant of an R8BUT matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); printf ( " Upper bandwidth MU = %d\n", MU ); a = r8but_random ( N, MU, &seed ); r8but_print ( N, MU, a, " The R8BUT matrix:" ); det = r8but_det ( N, MU, a ); printf ( "\n" ); printf ( " Determinant = %g\n", det ); free ( a ); return; # undef MU # undef N } /******************************************************************************/ void r8but_indicator_test ( ) /******************************************************************************/ /* Purpose: R8BUT_INDICATOR_TEST tests R8BUT_INDICATOR. Licensing: This code is distributed under the GNU LGPL license. Modified: 08 October 2015 Author: John Burkardt */ { # define N 5 # define MU 3 double *a; printf ( "\n" ); printf ( "R8BUT_INDICATOR_TEST\n" ); printf ( " R8BUT_INDICATOR sets an R8BUT indicator matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); printf ( " Upper bandwidth MU = %d\n", MU ); /* Set the matrix. */ a = r8but_indicator ( N, MU ); r8but_print ( N, MU, a, " The R8BUT matrix:" ); free ( a ); return; # undef N # undef MU } /******************************************************************************/ void r8but_mtv_test ( ) /******************************************************************************/ /* Purpose: R8BUT_MTV_TEST tests R8BUT_MTV. Licensing: This code is distributed under the GNU LGPL license. Modified: 12 March 2013 Author: John Burkardt */ { # define MU 3 # define N 5 double *a; double *b; int i; int j; int seed = 123456789; double *x; printf ( "\n" ); printf ( "R8BUT_MTV_TEST\n" ); printf ( " R8BUT_MTV computes b=A'*x, where A is an R8BUT matrix;\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); printf ( " Upper bandwidth MU = %d\n", MU ); a = r8but_random ( N, MU, &seed ); r8but_print ( N, MU, a, " The R8BUT matrix:" ); /* Set the desired solution. */ x = r8vec_indicator1_new ( N ); r8vec_print ( N, x, " x:" ); /* Compute the corresponding right hand side. */ b = r8but_mtv ( N, MU, a, x ); r8vec_print ( N, b, " b=A'*x:" ); free ( a ); free ( b ); free ( x ); return; # undef MU # undef N } /******************************************************************************/ void r8but_mv_test ( ) /******************************************************************************/ /* Purpose: R8BUT_MV_TEST tests R8BUT_MV. Licensing: This code is distributed under the GNU LGPL license. Modified: 12 March 2013 Author: John Burkardt */ { # define MU 3 # define N 5 double *a; double *b; int i; int j; int seed = 123456789; double *x; printf ( "\n" ); printf ( "R8BUT_MV_TEST\n" ); printf ( " R8BUT_MV computes b=A*x, where A is an R8BUT matrix;\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); printf ( " Upper bandwidth MU = %d\n", MU ); a = r8but_random ( N, MU, &seed ); r8but_print ( N, MU, a, " The R8BUT matrix:" ); /* Set the desired solution. */ x = r8vec_indicator1_new ( N ); r8vec_print ( N, x, " x:" ); /* Compute the corresponding right hand side. */ b = r8but_mv ( N, MU, a, x ); r8vec_print ( N, b, " b=A*x:" ); free ( a ); free ( b ); free ( x ); return; # undef MU # undef N } /******************************************************************************/ void r8but_print_test ( ) /******************************************************************************/ /* Purpose: R8BUT_PRINT_TEST tests R8BUT_PRINT. Licensing: This code is distributed under the GNU LGPL license. Modified: 08 October 2015 Author: John Burkardt */ { # define N 5 # define MU 3 double *a; printf ( "\n" ); printf ( "R8BUT_PRINT_TEST\n" ); printf ( " R8BUT_PRINT prints an R8BUT matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); printf ( " Upper bandwidth MU = %d\n", MU ); /* Set the matrix. */ a = r8but_indicator ( N, MU ); r8but_print ( N, MU, a, " The R8BUT matrix:" ); free ( a ); return; # undef N # undef MU } /******************************************************************************/ void r8but_print_some_test ( ) /******************************************************************************/ /* Purpose: R8BUT_PRINT_SOME_TEST tests R8BUT_PRINT_SOME. Licensing: This code is distributed under the GNU LGPL license. Modified: 08 October 2015 Author: John Burkardt */ { # define N 5 # define MU 3 double *a; printf ( "\n" ); printf ( "R8BUT_PRINT_SOME_TEST\n" ); printf ( " R8BUT_PRINT_SOME prints some of an R8BUT matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); printf ( " Upper bandwidth MU = %d\n", MU ); /* Set the matrix. */ a = r8but_indicator ( N, MU ); r8but_print_some ( N, MU, a, 1, 2, 4, 4, " Rows 1:4, Cols 2:4:" ); free ( a ); return; # undef N # undef MU } /******************************************************************************/ void r8but_random_test ( ) /******************************************************************************/ /* Purpose: R8BUT_RANDOM_TEST tests R8BUT_RANDOM. Licensing: This code is distributed under the GNU LGPL license. Modified: 08 October 2015 Author: John Burkardt */ { # define MU 3 # define N 5 double *a; int seed = 123456789; printf ( "\n" ); printf ( "R8BUT_RANDOM\n" ); printf ( " R8BUT_RANDOM sets a random R8BUT matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); printf ( " Upper bandwidth MU = %d\n", MU ); a = r8but_random ( N, MU, &seed ); r8but_print ( N, MU, a, " The R8BUT matrix:" ); free ( a ); return; # undef MU # undef N } /******************************************************************************/ void r8but_sl_test ( ) /******************************************************************************/ /* Purpose: R8BUT_SL_TEST tests R8BUT_SL. Licensing: This code is distributed under the GNU LGPL license. Modified: 08 October 2015 Author: John Burkardt */ { # define MU 3 # define N 5 double *a; double *b; int i; int j; int seed = 123456789; double *x; printf ( "\n" ); printf ( "R8BUT_SL_TEST\n" ); printf ( " R8BUT_SL solves A*x=b, where A is an R8BUT matrix;\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); printf ( " Upper bandwidth MU = %d\n", MU ); a = r8but_random ( N, MU, &seed ); r8but_print ( N, MU, a, " The R8BUT matrix:" ); /* Set the desired solution. */ x = r8vec_indicator1_new ( N ); r8vec_print ( N, x, " x:" ); /* Compute the corresponding right hand side. */ b = r8but_mv ( N, MU, a, x ); r8vec_print ( N, b, " b=A*x" ); /* Solve the linear system. */ free ( x ); x = r8but_sl ( N, MU, a, b ); r8vec_print ( N, x, " x:" ); free ( a ); free ( b ); free ( x ); return; # undef MU # undef N } /******************************************************************************/ void r8but_slt_test ( ) /******************************************************************************/ /* Purpose: R8BUT_SLT_TEST tests R8BUT_SLT. Licensing: This code is distributed under the GNU LGPL license. Modified: 08 October 2015 Author: John Burkardt */ { # define MU 3 # define N 5 double *a; double *b; int i; int j; int seed = 123456789; double *x; printf ( "\n" ); printf ( "R8BUT_SLT_TEST\n" ); printf ( " R8BUT_SLT solves A'*x=b, where A is an R8BUT matrix;\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); printf ( " Upper bandwidth MU = %d\n", MU ); a = r8but_random ( N, MU, &seed ); r8but_print ( N, MU, a, " The R8BUT matrix:" ); /* Set the desired solution. */ x = r8vec_indicator1_new ( N ); r8vec_print ( N, x, " x:" ); /* Compute the corresponding right hand side. */ b = r8but_mtv ( N, MU, a, x ); r8vec_print ( N, b, " b=A'*x" ); /* Solve the linear system. */ free ( x ); x = r8but_slt ( N, MU, a, b ); r8vec_print ( N, x, " x:" ); free ( a ); free ( b ); free ( x ); return; # undef MU # undef N } /******************************************************************************/ void r8but_to_r8ge_test ( ) /******************************************************************************/ /* Purpose: R8BUT_TO_R8GE_TEST tests R8BUT_TO_R8GE. Licensing: This code is distributed under the GNU LGPL license. Modified: 08 October 2015 Author: John Burkardt */ { # define MU 3 # define N 5 double *a_r8but; double *a_r8ge; int seed = 123456789; printf ( "\n" ); printf ( "R8BUT_TO_R8GE\n" ); printf ( " R8BUT_TO_R8GE converts a matrix from R8BUT to R8GE format.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); printf ( " Upper bandwidth MU = %d\n", MU ); a_r8but = r8but_random ( N, MU, &seed ); r8but_print ( N, MU, a_r8but, " The R8BUT matrix:" ); a_r8ge = r8but_to_r8ge ( N, MU, a_r8but ); r8ge_print ( N, N, a_r8ge, " The R8GE matrix:" ); free ( a_r8but ); free ( a_r8ge ); return; # undef MU # undef N } /******************************************************************************/ void r8but_zeros_test ( ) /******************************************************************************/ /* Purpose: R8BUT_ZEROS_TEST tests R8BUT_ZEROS. Licensing: This code is distributed under the GNU LGPL license. Modified: 08 October 2015 Author: John Burkardt */ { # define MU 3 # define N 5 double *a; int seed = 123456789; printf ( "\n" ); printf ( "R8BUT_ZEROS\n" ); printf ( " R8BUT_ZEROS zeros an R8BUT matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); printf ( " Upper bandwidth MU = %d\n", MU ); a = r8but_zeros ( N, MU ); r8but_print ( N, MU, a, " The R8BUT matrix:" ); free ( a ); return; # undef MU # undef N }