# include # include # include # include # include "r8ccs.h" 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 ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: r8ccs_test() tests r8ccs(). Licensing: This code is distributed under the MIT license. Modified: 21 August 2022 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "r8ccs_test():\n" ); printf ( " C version\n" ); printf ( " 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. */ printf ( "\n" ); printf ( "r8ccs_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void r8ccs_dif2_test ( ) /******************************************************************************/ /* 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; printf ( "\n" ); printf ( "r8ccs_DIF2_TEST\n" ); printf ( " r8ccs_DIF2 sets the second difference as an r8ccs matrix;\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); colptr = ( int * ) malloc ( ( n + 1 ) * sizeof ( int ) ); rowind = ( int * ) malloc ( nz_num * sizeof ( int ) ); a = ( double * ) malloc ( nz_num * sizeof ( double ) ); r8ccs_dif2 ( m, n, nz_num, colptr, rowind, a ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); free ( a ); free ( colptr ); free ( rowind ); return; } /******************************************************************************/ void r8ccs_get_test ( ) /******************************************************************************/ /* 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; printf ( "\n" ); printf ( "r8ccs_GET_TEST\n" ); printf ( " r8ccs_GET gets an entry from an r8ccs matrix;\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); 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:" ); printf ( "\n" ); printf ( " I J K VALUE\n" ); printf ( "\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 ); printf ( " %8d %8d %8d %14g\n", i, j, k, value ); } free ( a ); return; } /******************************************************************************/ void r8ccs_ijk_test ( ) /******************************************************************************/ /* 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; printf ( "\n" ); printf ( "r8ccs_IJK_TEST\n" ); printf ( " r8ccs_IJK gets K from (I,J) for an r8ccs matrix;\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); 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:" ); printf ( "\n" ); printf ( " r8ccs_IJK locates some (I,J) entries.\n" ); printf ( "\n" ); printf ( " I J K\n" ); printf ( "\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 ); printf ( " %8d %8d %8d\n", i, j, k ); } free ( a ); return; } /******************************************************************************/ void r8ccs_inc_test ( ) /******************************************************************************/ /* 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; printf ( "\n" ); printf ( "r8ccs_INC_TEST\n" ); printf ( " r8ccs_INC increments entries of an r8ccs matrix;\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); 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:" ); printf ( "\n" ); printf ( " r8ccs_INC increments 10 entries at random.\n" ); printf ( "\n" ); printf ( " I J K NEW_VALUE\n" ); printf ( "\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 ); printf ( " %8d %8d %8d %14g\n", i, j, k, value ); } r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The final r8ccs matrix:" ); free ( a ); return; } /******************************************************************************/ void r8ccs_indicator_test ( ) /******************************************************************************/ /* Purpose: r8ccs_INDICATOR_TEST tests r8ccs_INDICATOR. 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 }; printf ( "\n" ); printf ( "r8ccs_INDICATOR_TEST\n" ); printf ( " r8ccs_INDICATOR sets up an r8ccs indicator matrix;\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); a = r8ccs_indicator ( m, n, nz_num, colptr, rowind ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs indicator matrix:" ); free ( a ); return; } /******************************************************************************/ void r8ccs_kij_test ( ) /******************************************************************************/ /* 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; printf ( "\n" ); printf ( "r8ccs_KIJ_TEST\n" ); printf ( " r8ccs_KIJ gets (I,J) from K for an r8ccs matrix;\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); 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:" ); printf ( "\n" ); printf ( " r8ccs_KIJ locates some K entries.\n" ); printf ( "\n" ); printf ( " K I J\n" ); printf ( "\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 ); printf ( " %8d %8d %8d\n", k, i, j ); } free ( a ); return; } /******************************************************************************/ void r8ccs_mtv_test ( ) /******************************************************************************/ /* Purpose: r8ccs_MTV_TEST tests r8ccs_MTV. Licensing: This code is distributed under the MIT license. Modified: 02 October 2015 Author: John Burkardt */ { double *a; double *b; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int i; int m; int n; int nz_num; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; double *x; m = 5; n = 5; nz_num = 12; printf ( "\n" ); printf ( "r8ccs_MTV_TEST\n" ); printf ( " r8ccs_MTV computes b=A'*x, where A is an r8ccs matrix.\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); /* Set the matrix. */ a = r8ccs_random ( m, n, nz_num, colptr, rowind, &seed ); /* Set x; */ x = ( double * ) malloc ( m * sizeof ( double ) ); x[0] = 1.0; for ( i = 1; i < n-1; i++ ) { x[i] = 0.0; } x[n-1] = -1.0; r8vec_print ( m, x, " x:" ); /* Compute b=A*x. */ b = r8ccs_mtv ( m, n, nz_num, colptr, rowind, a, x ); r8vec_print ( n, b, " b=A'*x:" ); free ( a ); free ( b ); free ( x ); return; } /******************************************************************************/ void r8ccs_mv_test ( ) /******************************************************************************/ /* Purpose: r8ccs_MV_TEST tests r8ccs_MV. Licensing: This code is distributed under the MIT license. Modified: 02 October 2015 Author: John Burkardt */ { double *a; double *b; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int i; int m; int n; int nz_num; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; int seed = 123456789; double *x; m = 5; n = 5; nz_num = 12; printf ( "\n" ); printf ( "r8ccs_MV_TEST\n" ); printf ( " r8ccs_MV computes b=A*x, where A is an r8ccs matrix.\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); /* Set the matrix. */ a = r8ccs_random ( m, n, nz_num, colptr, rowind, &seed ); /* Set x; */ 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:" ); /* Compute b=A*x. */ b = r8ccs_mv ( m, n, nz_num, colptr, rowind, a, x ); r8vec_print ( m, b, " b=A*x:" ); free ( a ); free ( b ); free ( x ); return; } /******************************************************************************/ void r8ccs_print_test ( ) /******************************************************************************/ /* Purpose: r8ccs_PRINT_TEST tests r8ccs_PRINT. Licensing: This code is distributed under the MIT license. Modified: 12 April 2013 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; printf ( "\n" ); printf ( "r8ccs_PRINT_TEST\n" ); printf ( " r8ccs_PRINT prints an r8ccs matrix.\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); /* 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:" ); free ( a ); return; } /******************************************************************************/ void r8ccs_print_some_test ( ) /******************************************************************************/ /* 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 }; printf ( "\n" ); printf ( "r8ccs_PRINT_SOME_TEST\n" ); printf ( " r8ccs_PRINT_SOME prints some of an r8ccs matrix.\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); /* 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:" ); free ( a ); return; } /******************************************************************************/ void r8ccs_random_test ( ) /******************************************************************************/ /* 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; printf ( "\n" ); printf ( "r8ccs_RANDOM_TEST\n" ); printf ( " r8ccs_RANDOM randomizes an r8ccs matrix;\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); a = r8ccs_random ( m, n, nz_num, colptr, rowind, &seed ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); free ( a ); return; } /******************************************************************************/ void r8ccs_read_test ( ) /******************************************************************************/ /* 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; char *a_file = "r8ccs_a.txt"; int *col; char *col_file = "r8ccs_col.txt"; int m; int n; int nz_num; int *row; char *row_file = "r8ccs_row.txt"; printf ( "\n" ); printf ( "r8ccs_READ_TEST\n" ); printf ( " r8ccs_READ reads an r8ccs matrix from 3 files.\n" ); r8ccs_read_size ( col_file, row_file, &m, &n, &nz_num ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); a = ( double * ) malloc ( nz_num * sizeof ( double ) ); col = ( int * ) malloc ( ( n + 1 ) * sizeof ( int ) ); row = ( int * ) malloc ( nz_num * sizeof ( int ) ); 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:" ); free ( a ); free ( col ); free ( row ); return; } /******************************************************************************/ void r8ccs_set_test ( ) /******************************************************************************/ /* 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; printf ( "\n" ); printf ( "r8ccs_SET_TEST\n" ); printf ( " r8ccs_SET sets an entry of an r8ccs matrix;\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); 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:" ); printf ( "\n" ); printf ( " r8ccs_SET sets entries at random.\n" ); printf ( "\n" ); printf ( " I J K NEW_VALUE\n" ); printf ( "\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 ); printf ( " %8d %8d %8d %14g\n", i, j, k, value ); } r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The final r8ccs matrix:" ); free ( a ); return; } /******************************************************************************/ void r8ccs_to_r8ge_test ( ) /******************************************************************************/ /* 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 }; printf ( "\n" ); printf ( "r8ccs_TO_R8GE_TEST\n" ); printf ( " r8ccs_TO_R8GE converts a matrix from r8ccs to R8GE format.\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); a_r8ccs = r8ccs_indicator ( m, n, nz_num, colptr, rowind ); 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:" ); free ( a_r8ccs ); free ( a_r8ge ); return; } /******************************************************************************/ void r8ccs_write_test ( ) /******************************************************************************/ /* Purpose: r8ccs_WRITE_TEST tests r8ccs_WRITE. Licensing: This code is distributed under the MIT license. Modified: 03 October 2015 Author: John Burkardt */ { double *a; char *a_file = "r8ccs_a.txt"; char *col_file = "r8ccs_col.txt"; int colptr[6] = { 0, 3, 5, 7, 9, 12 }; int m = 5; int n = 5; int nz_num = 12; char *row_file = "r8ccs_row.txt"; int rowind[12] = { 0, 1, 3, 0, 1, 2, 4, 3, 4, 0, 1, 4 }; printf ( "\n" ); printf ( "r8ccs_WRITE_TEST\n" ); printf ( " r8ccs_WRITE writes an r8ccs matrix to files.\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); 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 ); free ( a ); return; } /******************************************************************************/ void r8ccs_zeros_test ( ) /******************************************************************************/ /* 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 }; printf ( "\n" ); printf ( "r8ccs_ZEROS_TEST\n" ); printf ( " r8ccs_ZEROS zeros an r8ccs matrix;\n" ); printf ( "\n" ); printf ( " Matrix rows M = %d\n", m ); printf ( " Matrix columns N = %d\n", n ); printf ( " Nonzeros NZ_NUM = %d\n", nz_num ); a = r8ccs_zeros ( m, n, nz_num, colptr, rowind ); r8ccs_print ( m, n, nz_num, colptr, rowind, a, " The r8ccs matrix:" ); free ( a ); return; } /******************************************************************************/ 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 }