| 66 | //------------------------------------------------------------------------------ |
| 67 | |
| 68 | int main (int argc, char **argv) |
| 69 | { |
| 70 | GrB_Index m = 3, k = 5, n = 4 ; |
| 71 | GrB_Matrix A, B, C ; |
| 72 | |
| 73 | // initialize GraphBLAS and create the user-defined Complex type |
| 74 | GrB_Info info ; |
| 75 | GrB_init (GrB_NONBLOCKING) ; |
| 76 | int nthreads ; |
| 77 | GxB_Global_Option_get (GxB_GLOBAL_NTHREADS, &nthreads) ; |
| 78 | fprintf (stderr, "complex_demo: nthreads: %d\n", nthreads) ; |
| 79 | |
| 80 | // print in 1-based notation |
| 81 | GxB_Global_Option_set (GxB_PRINT_1BASED, true) ; |
| 82 | |
| 83 | bool predefined = (argc > 1) ; |
| 84 | if (predefined) |
| 85 | { |
| 86 | fprintf (stderr, "Using pre-defined GxB_FC64 complex type\n") ; |
| 87 | } |
| 88 | else |
| 89 | { |
| 90 | fprintf (stderr, "Using user-defined Complex type\n") ; |
| 91 | } |
| 92 | |
| 93 | info = Complex_init (predefined) ; |
| 94 | if (info != GrB_SUCCESS) |
| 95 | { |
| 96 | fprintf (stderr, "Complex init failed\n") ; |
| 97 | abort ( ) ; |
| 98 | } |
| 99 | |
| 100 | // generate random matrices A and B |
| 101 | simple_rand_seed (1) ; |
| 102 | random_matrix (&A, false, false, m, k, 6, 0, true) ; |
| 103 | random_matrix (&B, false, false, k, n, 8, 0, true) ; |
| 104 | |
| 105 | GxB_Matrix_fprint (A, "A", GxB_SHORT, stderr) ; |
| 106 | GxB_Matrix_fprint (B, "B", GxB_SHORT, stderr) ; |
| 107 | |
| 108 | // C = A*B |
| 109 | GrB_Matrix_new (&C, Complex, m, n) ; |
| 110 | GrB_mxm (C, NULL, NULL, Complex_plus_times, A, B, NULL) ; |
| 111 | |
| 112 | GxB_Matrix_fprint (C, "C", GxB_SHORT, stderr) ; |
| 113 | |
| 114 | // print the results |
| 115 | printf ("\n%% run this output of this program as a script:\n") ; |
| 116 | print_complex_matrix (A, "A") ; |
| 117 | print_complex_matrix (B, "B") ; |
| 118 | print_complex_matrix (C, "C") ; |
| 119 | |
| 120 | printf ("E = A*B\n") ; |
| 121 | printf ("err = norm (C-E,1)\n") ; |
| 122 | printf ("assert (err < 1e-12)\n") ; |
| 123 | |
| 124 | // free all matrices |
| 125 | GrB_Matrix_free (&A) ; |
nothing calls this directly
no test coverage detected