# include # include # include # include "r85.h" int main ( ); void r85_dif2_test ( ); void r85_indicator_test ( ); void r85_mtv_test ( ); void r85_mv_test ( ); void r85_np_fs_test ( ); void r85_print_test ( ); void r85_print_some_test ( ); void r85_random_test ( ); void r85_to_r8ge_test ( ); void r85_zeros_test ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: MAIN is the main program for R85_TEST. Discussion: R85_TEST tests R85. Licensing: This code is distributed under the GNU LGPL license. Modified: 15 July 2016 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "R85_TEST\n" ); printf ( " C version\n" ); printf ( " Test the R85 library.\n" ); r85_dif2_test ( ); r85_indicator_test ( ); r85_mtv_test ( ); r85_mv_test ( ); r85_np_fs_test ( ); r85_print_test ( ); r85_print_some_test ( ); r85_random_test ( ); r85_to_r8ge_test ( ); r85_zeros_test ( ); /* Terminate. */ printf ( "\n" ); printf ( "R85_TEST\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void r85_dif2_test ( ) /******************************************************************************/ /* Purpose: R85_DIF2_TEST tests R85_DIF2. Licensing: This code is distributed under the GNU LGPL license. Modified: 12 July 2016 Author: John Burkardt */ { double *a; int n = 5; printf ( "\n" ); printf ( "R85_DIF2_TEST\n" ); printf ( " R85_DIF2 sets up an R85 second difference matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r85_dif2 ( n ); r85_print ( n, a, " The R85 second difference matrix:" ); free ( a ); return; } /******************************************************************************/ void r85_indicator_test ( ) /******************************************************************************/ /* Purpose: R85_INDICATOR_TEST tests R85_INDICATOR. Licensing: This code is distributed under the GNU LGPL license. Modified: 08 March 2013 Author: John Burkardt */ { double *a; int n = 5; printf ( "\n" ); printf ( "R85_INDICATOR_TEST\n" ); printf ( " R85_INDICATOR sets up an R85 indicator matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r85_indicator ( n ); r85_print ( n, a, " The R85 indicator matrix:" ); free ( a ); return; } /******************************************************************************/ void r85_mtv_test ( ) /******************************************************************************/ /* Purpose: R85_MTV_TEST tests R85_MTV. Licensing: This code is distributed under the GNU LGPL license. Modified: 14 July 2016 Author: John Burkardt */ { double *a; double *b; int n = 5; double *x; printf ( "\n" ); printf ( "R85_MTV_TEST\n" ); printf ( " R85_MTV computes b=A'*x, where A is an R85 matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r85_indicator ( n ); r85_print ( n, a, " The R85 matrix:" ); x = r8vec_indicator1_new ( n ); r8vec_print ( n, x, " The vector x:" ); b = r85_mtv ( n, a, x ); r8vec_print ( n, b, " The product b=A'*x:" ); free ( a ); free ( b ); free ( x ); return; } /******************************************************************************/ void r85_mv_test ( ) /******************************************************************************/ /* Purpose: R85_MV_TEST tests R85_MV. Licensing: This code is distributed under the GNU LGPL license. Modified: 14 July 2016 Author: John Burkardt */ { double *a; double *b; int n = 5; double *x; printf ( "\n" ); printf ( "R85_MV_TEST\n" ); printf ( " R85_MV computes b=A*x, where A is an R85 matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r85_indicator ( n ); r85_print ( n, a, " The R85 matrix:" ); x = r8vec_indicator1_new ( n ); r8vec_print ( n, x, " The vector x:" ); b = r85_mv ( n, a, x ); r8vec_print ( n, b, " The product b=A*x:" ); free ( a ); free ( b ); free ( x ); return; } /******************************************************************************/ void r85_np_fs_test ( ) /******************************************************************************/ /* Purpose: R85_NP_FS_TEST tests R85_NP_FS. Licensing: This code is distributed under the GNU LGPL license. Modified: 08 March 2013 Author: John Burkardt */ { # define N 10 double *a; double *b; int i; int seed = 123456789; double *x; printf ( "\n" ); printf ( "R85_NP_FS_TEST\n" ); printf ( " R85_NP_FS factors and solves a pentadiagonal\n" ); printf ( " linear system, with no pivoting.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", N ); /* Set the matrix to a random value. */ a = r85_random ( N, &seed ); r85_print ( N, a, " The pentadiagonal matrix:" ); /* Set the desired solution. */ x = r8vec_indicator1_new ( N ); /* Compute b = A * x. */ b = r85_mv ( N, a, x ); r8vec_print ( N, b, " Right hand side:" ); /* Wipe out the solution. */ for ( i = 0; i < N; i++ ) { x[i] = 0.0; } /* Solve the system. */ free ( x ); x = r85_np_fs ( N, a, b ); r8vec_print ( N, x, " Solution to A*x=b:" ); free ( a ); free ( b ); free ( x ); return; # undef N } /******************************************************************************/ void r85_print_test ( ) /******************************************************************************/ /* Purpose: R85_PRINT_TEST tests R85_PRINT. Licensing: This code is distributed under the GNU LGPL license. Modified: 14 July 2016 Author: John Burkardt */ { double *a; int n = 5; printf ( "\n" ); printf ( "R85_PRINT_TEST\n" ); printf ( " R85_PRINT prints an R85 matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r85_indicator ( n ); r85_print ( n, a, " The R85 matrix:" ); free ( a ); return; } /******************************************************************************/ void r85_print_some_test ( ) /******************************************************************************/ /* Purpose: R85_PRINT_SOME_TEST tests R85_PRINT_SOME. Licensing: This code is distributed under the GNU LGPL license. Modified: 14 July 2016 Author: John Burkardt */ { double *a; int n = 8; printf ( "\n" ); printf ( "R85_PRINT_SOME_TEST\n" ); printf ( " R85_PRINT_SOME prints some of an R85 matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r85_indicator ( n ); r85_print_some ( n, a, 1, 2, 5, 4, " Rows 1-5, Cols 2-4:" ); free ( a ); return; } /******************************************************************************/ void r85_random_test ( ) /******************************************************************************/ /* Purpose: R85_RANDOM_TEST tests R85_RANDOM. Licensing: This code is distributed under the GNU LGPL license. Modified: 12 July 2016 Author: John Burkardt */ { double *a; int n = 5; int seed; printf ( "\n" ); printf ( "R85_RANDOM_TEST\n" ); printf ( " R85_RANDOM randomizes an R85 matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); seed = 123456789; a = r85_random ( n, &seed ); r85_print ( n, a, " The R85 random matrix:" ); free ( a ); return; } /******************************************************************************/ void r85_to_r8ge_test ( ) /******************************************************************************/ /* Purpose: R85_TO_R8GE_TEST tests R85_TO_R8GE. Licensing: This code is distributed under the GNU LGPL license. Modified: 14 July 2016 Author: John Burkardt */ { double *a; double *a_r8ge; int n = 5; printf ( "\n" ); printf ( "R85_TO_R8GE_TEST\n" ); printf ( " R85_TO_R8GE converts an R85 matrix to R8GE format.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r85_indicator ( n ); r85_print ( n, a, " The R85 matrix:" ); a_r8ge = r85_to_r8ge ( n, a ); r8ge_print ( n, n, a_r8ge, " The R8GE matrix:" ); free ( a ); return; } /******************************************************************************/ void r85_zeros_test ( ) /******************************************************************************/ /* Purpose: R85_ZEROS_TEST tests R85_ZEROS. Licensing: This code is distributed under the GNU LGPL license. Modified: 12 July 2016 Author: John Burkardt */ { double *a; int n = 5; printf ( "\n" ); printf ( "R85_ZEROS_TEST\n" ); printf ( " R85_ZEROS zeros an R85 matrix.\n" ); printf ( "\n" ); printf ( " Matrix order N = %d\n", n ); a = r85_zeros ( n ); r85_print ( n, a, " The R85 zero matrix:" ); free ( a ); return; }