# include # include # include # include # include using namespace std; # include "r8ccs.hpp" int main ( ); void r8ccs_dif2_test ( ); void r8ccs_get_test ( ); void r8ccs_ijk_test ( ); void r8ccs_inc_test ( ); void r8ccs_indicator_test ( ); void r8ccs_kij_test ( ); void r8ccs_mtv_test ( ); void r8ccs_mv_test ( ); void r8ccs_print_test ( ); void r8ccs_print_some_test ( ); void r8ccs_random_test ( ); void r8ccs_read_test ( ); void r8ccs_set_test ( ); void r8ccs_to_r8ge_test ( ); void r8ccs_write_test ( ); void r8ccs_zeros_test ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // r8ccs_test() tests r8ccs(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 21 August 2022 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "r8ccs_test():\n"; cout << " C++ version\n"; cout << " Test r8ccs().\n"; r8ccs_dif2_test ( ); r8ccs_get_test ( ); r8ccs_ijk_test ( ); r8ccs_inc_test ( ); r8ccs_indicator_test ( ); r8ccs_kij_test ( ); r8ccs_mtv_test ( ); r8ccs_mv_test ( ); r8ccs_print_test ( ); r8ccs_print_some_test ( ); r8ccs_random_test ( ); r8ccs_read_test ( ); r8ccs_set_test ( ); r8ccs_to_r8ge_test ( ); r8ccs_write_test ( ); r8ccs_zeros_test ( ); // // Terminate. // cout << "\n"; cout << "r8ccs_test():\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void r8ccs_dif2_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_DIF2_TEST tests r8ccs_DIF2. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; int *colptr; int m = 5; int n = 5; int nz_num = 13; int *rowind; cout << "\n"; cout << "r8ccs_DIF2_TEST\n"; cout << " r8ccs_DIF2 sets the second difference as an r8ccs matrix;\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; colptr = new int[n+1]; rowind = new int[nz_num]; a = new double[nz_num]; r8ccs_dif2 ( m, n, nz_num, colptr, rowind, a ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); delete [] a; delete [] colptr; delete [] rowind; return; } //****************************************************************************80 void r8ccs_get_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_GET_TEST tests r8ccs_GET. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int i; int j; int k; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; int test; double value; cout << "\n"; cout << "r8ccs_GET_TEST\n"; cout << " r8ccs_GET gets entries of an r8ccs matrix;\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; i4vec_print ( n + 1, colptr, " The COLPTR vector:" ); i4vec_print ( nz_num, rowind, " The ROWIND vector:" ); // // Initialize the matrix to random values. // a = r8ccs_random ( m, n, nz_num, colptr, rowind, seed ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); cout << "\n"; cout << " r8ccs_GET retrieves 10 entries.\n"; cout << "\n"; cout << " I J K VALUE\n"; cout << "\n"; for ( test = 1; test <= 10; test++ ) { k = i4_uniform_ab ( 0, nz_num - 1, seed ); r8ccs_kij ( m, n, nz_num, colptr, rowind, k, i, j ); value = r8ccs_get ( m, n, nz_num, colptr, rowind, a, i, j ); cout << " " << setw(8) << i << " " << setw(8) << j << " " << setw(8) << k << " " << setw(14) << value << "\n"; } delete [] a; return; } //****************************************************************************80 void r8ccs_ijk_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_IJK_TEST tests r8ccs_IJK. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int i; int j; int k; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; int test; cout << "\n"; cout << "r8ccs_IJK_TEST\n"; cout << " r8ccs_IJK gets K from (I,J) for an r8ccs matrix.\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; i4vec_print ( n + 1, colptr, " The COLPTR vector:" ); i4vec_print ( nz_num, rowind, " The ROWIND vector:" ); // // Initialize the matrix to random values. // a = r8ccs_random ( m, n, nz_num, colptr, rowind, seed ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The initial r8ccs matrix:" ); cout << "\n"; cout << " r8ccs_IJK locates some (I,J) entries.\n"; cout << "\n"; cout << " I J K\n"; cout << "\n"; for ( test = 1; test <= 10; test++ ) { i = i4_uniform_ab ( 0, m - 1, seed ); j = i4_uniform_ab ( 0, n - 1, seed ); k = r8ccs_ijk ( m, n, nz_num, colptr, rowind, i, j ); cout << " " << setw(8) << i << " " << setw(8) << j << " " << setw(8) << k << "\n"; } delete [] a; return; } //****************************************************************************80 void r8ccs_inc_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_INC_TEST tests r8ccs_INC. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int i; int j; int k; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; int test; double value; cout << "\n"; cout << "r8ccs_INC_TEST\n"; cout << " r8ccs_INC increments the entries of an r8ccs matrix;\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; i4vec_print ( n + 1, colptr, " The COLPTR vector:" ); i4vec_print ( nz_num, rowind, " The ROWIND vector:" ); // // Initialize the matrix to random values. // a = r8ccs_random ( m, n, nz_num, colptr, rowind, seed ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The initial r8ccs matrix:" ); cout << "\n"; cout << " r8ccs_INC increments 10 entries at random.\n"; cout << "\n"; cout << " I J K NEW_VALUE\n"; cout << "\n"; for ( test = 1; test <= 10; test++ ) { k = i4_uniform_ab ( 0, nz_num - 1, seed ); r8ccs_kij ( m, n, nz_num, colptr, rowind, k, i, j ); value = 20.0 + ( double ) ( test ); r8ccs_inc ( m, n, nz_num, colptr, rowind, a, i, j, value ); value = r8ccs_get ( m, n, nz_num, colptr, rowind, a, i, j ); cout << " " << setw(8) << i << " " << setw(8) << j << " " << setw(8) << k << " " << setw(14) << value << "\n"; } r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The final r8ccs matrix:" ); delete [] a; return; } //****************************************************************************80 void r8ccs_indicator_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_INDICATOR_TEST tests r8ccs_INDICATOR. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 01 September 2006 // // Author: // // John Burkardt // { double *a; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; cout << "\n"; cout << "r8ccs_INDICATOR_TEST\n"; cout << " r8ccs_INDICATOR sets up an r8ccs indicator matrix;\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; a = r8ccs_indicator ( m, n, nz_num, colptr, rowind ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs indicator matrix:" ); delete [] a; return; } //****************************************************************************80 void r8ccs_kij_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_KIJ_TEST tests r8ccs_KIJ. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int i; int j; int k; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; int test; cout << "\n"; cout << "r8ccs_KIJ_TEST\n"; cout << " r8ccs_KIJ gets (I,J) from K for an r8ccs matrix;\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; i4vec_print ( n + 1, colptr, " The COLPTR vector:" ); i4vec_print ( nz_num, rowind, " The ROWIND vector:" ); // // Initialize the matrix to random values. // a = r8ccs_random ( m, n, nz_num, colptr, rowind, seed ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); cout << "\n"; cout << " r8ccs_KIJ locates some K entries.\n"; cout << "\n"; cout << " K I J\n"; cout << "\n"; for ( test = 1; test <= 10; test++ ) { k = i4_uniform_ab ( 0, nz_num - 1, seed ); r8ccs_kij ( m, n, nz_num, colptr, rowind, k, i, j ); cout << " " << setw(8) << k << " " << setw(8) << i << " " << setw(8) << j << "\n"; } delete [] a; return; } //****************************************************************************80 void r8ccs_mtv_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_MTV_TEST tests r8ccs_MTV. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; double *b; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int i; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; double *x; cout << "\n"; cout << "r8ccs_MTV_TEST\n"; cout << " r8ccs_MTV computes b=A'*x, where A is an r8ccs matrix;\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; // // Set the matrix. // a = r8ccs_random ( m, n, nz_num, colptr, rowind, seed ); // // Print the matrix. // r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); // // Compute A'*x = b. // x = ( double * ) malloc ( m * sizeof ( double ) ); x[0] = 1.0; for ( i = 1; i < m - 1; i++ ) { x[i] = 0.0; } x[m-1] = -1.0; b = r8ccs_mtv ( m, n, nz_num, colptr, rowind, a, x ); r8vec_print ( n, b, " b=A'*x:" ); delete [] a; delete [] b; delete [] x; return; } //****************************************************************************80 void r8ccs_mv_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_MV_TEST tests r8ccs_MV. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; double *b; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int i; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; double *x; cout << "\n"; cout << "r8ccs_MV_TEST\n"; cout << " r8ccs_MV computes b=A*x, where A is an r8ccs matrix.\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; // // Set the matrix. // a = r8ccs_random ( m, n, nz_num, colptr, rowind, seed ); // // Print the matrix. // r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); // // Compute A * x = b. // x = ( double * ) malloc ( n * sizeof ( double ) ); x[0] = 1.0; for ( i = 1; i < n - 1; i++ ) { x[i] = 0.0; } x[n-1] = -1.0; r8vec_print ( n, x, " x:" ); b = r8ccs_mv ( m, n, nz_num, colptr, rowind, a, x ); r8vec_print ( m, b, " b=A*x:" ); delete [] a; delete [] b; delete [] x; return; } //****************************************************************************80 void r8ccs_print_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_PRINT_TEST tests r8ccs_PRINT. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 01 September 2006 // // Author: // // John Burkardt // { double *a; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; cout << "\n"; cout << "r8ccs_PRINT_TEST\n"; cout << " r8ccs_PRINT prints an r8ccs matrix.\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; // // Set the matrix. // a = r8ccs_random ( m, n, nz_num, colptr, rowind, seed ); // // Print the matrix. // r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); delete [] a; return; } //****************************************************************************80 void r8ccs_print_some_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_PRINT_SOME_TEST tests r8ccs_PRINT_SOME. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; int colptr[11] = { 0, 2, 5, 8, 11, 14, 17, 20, 23, 26, 28 }; int m = 10; int n = 10; int nz_num = 28; int rowind[28] = { 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9, 8, 9 }; cout << "\n"; cout << "r8ccs_PRINT_SOME_TEST\n"; cout << " r8ccs_PRINT_SOME prints some of an r8ccs matrix.\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; // // Set the matrix. // a = r8ccs_indicator ( m, n, nz_num, colptr, rowind ); // // Print the matrix. // r8ccs_print_some ( m, n, nz_num, colptr, rowind, a, 1, 4, 5, 7, " Rows 1:5, Cols 4:7:" ); delete [] a; return; } //****************************************************************************80 void r8ccs_random_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_RANDOM_TEST tests r8ccs_RANDOM. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; cout << "\n"; cout << "r8ccs_RANDOM_TEST\n"; cout << " r8ccs_RANDOM randomizes an r8ccs matrix;\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; a = r8ccs_random ( m, n, nz_num, colptr, rowind, seed ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); delete [] a; return; } //****************************************************************************80 void r8ccs_read_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_READ_TEST tests r8ccs_READ. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; string a_file = "r8ccs_a.txt"; int *col; string col_file = "r8ccs_col.txt"; int m; int n; int nz_num; int *row; string row_file = "r8ccs_row.txt"; cout << "\n"; cout << "r8ccs_READ_TEST\n"; cout << " r8ccs_READ reads an r8ccs matrix from 3 files.\n"; r8ccs_read_size ( col_file, row_file, m, n, nz_num ); cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; a = new double[nz_num]; col = new int[n+1]; row = new int[nz_num]; r8ccs_read ( col_file, row_file, a_file, m, n, nz_num, col, row, a ); i4vec_print ( n+1, col, " The COL vector:" ); i4vec_print ( nz_num, row, " The ROW vector:" ); r8ccs_print ( m, n, nz_num, col, row, a, " The r8ccs matrix:" ); delete [] a; delete [] col; delete [] row; return; } //****************************************************************************80 void r8ccs_set_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_SET_TEST tests r8ccs_SET. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int i; int j; int k; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; int test; double value; cout << "\n"; cout << "r8ccs_SET_TEST\n"; cout << " r8ccs_SET sets entries of an r8ccs matrix;\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; i4vec_print ( n + 1, colptr, " The COLPTR vector:" ); i4vec_print ( nz_num, rowind, " The ROWIND vector:" ); // // Initialize the matrix to random values. // a = r8ccs_random ( m, n, nz_num, colptr, rowind, seed ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The initial r8ccs matrix:" ); cout << "\n"; cout << " r8ccs_SET sets 10 entries at random.\n"; cout << "\n"; cout << " I J K NEW_VALUE\n"; cout << "\n"; for ( test = 1; test <= 10; test++ ) { k = i4_uniform_ab ( 0, nz_num - 1, seed ); r8ccs_kij ( m, n, nz_num, colptr, rowind, k, i, j ); value = 100.0 + ( double ) ( test ); r8ccs_set ( m, n, nz_num, colptr, rowind, a, i, j, value ); cout << " " << setw(8) << i << " " << setw(8) << j << " " << setw(8) << k << " " << setw(14) << value << "\n"; } r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The final r8ccs matrix:" ); delete [] a; return; } //****************************************************************************80 void r8ccs_to_r8ge_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_TO_R8GE_TEST tests r8ccs_TO_R8GE. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a_r8ccs; double *a_r8ge; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; cout << "\n"; cout << "r8ccs_TO_R8GE_TEST\n"; cout << " r8ccs_TO_R8GE converts a matrix from r8ccs to R8GE format\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; a_r8ccs = r8ccs_random ( m, n, nz_num, colptr, rowind, seed ); r8ccs_print ( m, n, nz_num, colptr, rowind, a_r8ccs, " The r8ccs matrix:" ); a_r8ge = r8ccs_to_r8ge ( m, n, nz_num, colptr, rowind, a_r8ccs ); r8ge_print ( m, n, a_r8ge, " The R8GE matrix:" ); delete [] a_r8ccs; delete [] a_r8ge; return; } //****************************************************************************80 void r8ccs_write_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_WRITE_TEST tests r8ccs_WRITE. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 30 August 2006 // // Author: // // John Burkardt // { double *a; string a_file = "r8ccs_a.txt"; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; string col_file = "r8ccs_col.txt"; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; string row_file = "r8ccs_row.txt"; cout << "\n"; cout << "r8ccs_WRITE_TEST\n"; cout << " r8ccs_WRITE writes an r8ccs matrix to 3 files.\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; i4vec_print ( n + 1, colptr, " The COL vector:" ); i4vec_print ( nz_num, rowind, " The ROW vector:" ); a = r8ccs_indicator ( m, n, nz_num, colptr, rowind ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); r8ccs_write ( col_file, row_file, a_file, m, n, nz_num, colptr, rowind, a ); delete [] a; return; } //****************************************************************************80 void r8ccs_zeros_test ( ) //****************************************************************************80 // // Purpose: // // r8ccs_ZEROS_TEST tests r8ccs_ZEROS. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 03 October 2015 // // Author: // // John Burkardt // { double *a; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int m = 5; int n = 5; int nz_num = 12; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; cout << "\n"; cout << "r8ccs_ZEROS_TEST\n"; cout << " r8ccs_ZEROS zeros an r8ccs matrix;\n"; cout << "\n"; cout << " Matrix rows M = " << m << "\n"; cout << " Matrix columns N = " << n << "\n"; cout << " Nonzeros NZ_NUM = " << nz_num << "\n"; a = r8ccs_zeros ( m, n, nz_num, colptr, rowind ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); delete [] a; return; } //****************************************************************************80 void timestamp ( ) //****************************************************************************80 // // 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: // // 08 July 2009 // // Author: // // John Burkardt // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct std::tm *tm_ptr; std::time_t now; now = std::time ( NULL ); tm_ptr = std::localtime ( &now ); std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr ); std::cout << time_buffer << "\n"; return; # undef TIME_SIZE }