| 22 | #include "graphblas_demos.h" |
| 23 | |
| 24 | GB_PUBLIC |
| 25 | GrB_Info get_matrix // get a matrix from stdin, or create random one |
| 26 | ( |
| 27 | GrB_Matrix *A_output, // matrix to create |
| 28 | int argc, // command-line arguments |
| 29 | char **argv, |
| 30 | bool no_self_edges, // if true, ensure the matrix has no self-edges |
| 31 | bool boolean, // if true, file is read as GrB_BOOL, else GrB_FP64 |
| 32 | bool spones // if true, return all entries equal to 1 |
| 33 | ) |
| 34 | { |
| 35 | |
| 36 | GrB_Info info ; |
| 37 | GrB_Index nrows = 1, ncols = 1, ntuples = 1, nvals ; |
| 38 | GrB_Matrix A = NULL ; |
| 39 | GrB_Matrix Mask = NULL ; |
| 40 | GrB_Descriptor desc = NULL ; |
| 41 | int kind = 0 ; |
| 42 | |
| 43 | if (argc > 2) |
| 44 | { |
| 45 | |
| 46 | //---------------------------------------------------------------------- |
| 47 | // create a random matrix |
| 48 | //---------------------------------------------------------------------- |
| 49 | |
| 50 | kind = strtol (argv [1], NULL, 0) ; |
| 51 | |
| 52 | if (kind == 0) |
| 53 | { |
| 54 | |
| 55 | //------------------------------------------------------------------ |
| 56 | // random pattern |
| 57 | //------------------------------------------------------------------ |
| 58 | |
| 59 | // usage: ./main 0 nrows ncols ntuples method |
| 60 | |
| 61 | int method = 0 ; // 0:setElement, 1:build |
| 62 | |
| 63 | if (argc > 2) nrows = strtol (argv [2], NULL, 0) ; |
| 64 | if (argc > 3) ncols = strtol (argv [3], NULL, 0) ; |
| 65 | if (argc > 4) ntuples = strtol (argv [4], NULL, 0) ; |
| 66 | if (argc > 5) method = strtol (argv [5], NULL, 0) ; |
| 67 | |
| 68 | OK (random_matrix (&A, true, no_self_edges, |
| 69 | nrows, ncols, ntuples, method, false)) ; |
| 70 | |
| 71 | // force completion, just to check timing |
| 72 | GrB_Matrix_nvals (&nvals, A) ; |
| 73 | |
| 74 | // printf format warnings can vary with different compilers, so |
| 75 | // punt and type cast to double |
| 76 | printf ( "random %.16g by %.16g, nz: %.16g, method %d\n", |
| 77 | (double) nrows, (double) ncols, (double) nvals, method) ; |
| 78 | |
| 79 | fprintf (stderr, "random %.16g by %.16g, nz: %.16g, method %d\n", |
| 80 | (double) nrows, (double) ncols, (double) nvals, method) ; |
| 81 |
nothing calls this directly
no test coverage detected