| 221 | } |
| 222 | |
| 223 | bool _compare_matrices(GrB_Matrix expected, RG_Matrix actual) { |
| 224 | GrB_Matrix a = expected; |
| 225 | GrB_Matrix b = NULL; |
| 226 | RG_Matrix_export(&b, actual); |
| 227 | |
| 228 | GrB_Index acols, arows, avals; |
| 229 | GrB_Index bcols, brows, bvals; |
| 230 | |
| 231 | GrB_Matrix_ncols(&acols, a); |
| 232 | GrB_Matrix_nrows(&arows, a); |
| 233 | GrB_Matrix_nvals(&avals, a); |
| 234 | GrB_Matrix_ncols(&bcols, b); |
| 235 | GrB_Matrix_nrows(&brows, b); |
| 236 | GrB_Matrix_nvals(&bvals, b); |
| 237 | |
| 238 | if(acols != bcols || arows != brows || avals != bvals) { |
| 239 | printf("acols: %lu bcols: %lu\n", acols, bcols); |
| 240 | printf("arows: %lu brows: %lu\n", arows, brows); |
| 241 | printf("avals: %lu bvals: %lu\n", avals, bvals); |
| 242 | |
| 243 | GrB_Matrix_free(&b); |
| 244 | return false; |
| 245 | } |
| 246 | |
| 247 | GrB_Index aI[avals]; // array for returning row indices of tuples |
| 248 | GrB_Index aJ[avals]; // array for returning col indices of tuples |
| 249 | bool aX[avals]; // array for returning values of tuples |
| 250 | GrB_Index bI[bvals]; // array for returning row indices of tuples |
| 251 | GrB_Index bJ[bvals]; // array for returning col indices of tuples |
| 252 | bool bX[bvals]; // array for returning values of tuples |
| 253 | |
| 254 | GrB_Matrix_wait(a, GrB_MATERIALIZE); |
| 255 | GrB_Matrix_wait(b, GrB_MATERIALIZE); |
| 256 | |
| 257 | GrB_Matrix_extractTuples_BOOL(aI, aJ, aX, &avals, a); |
| 258 | GrB_Matrix_extractTuples_BOOL(bI, bJ, bX, &bvals, b); |
| 259 | |
| 260 | for(int i = 0; i < avals; i++) { |
| 261 | if(aI[i] != bI[i] || aJ[i] != bJ[i] || aX[i] != bX[i]) { |
| 262 | printf("Matrix A \n"); |
| 263 | _print_matrix(a); |
| 264 | printf("\n\n"); |
| 265 | printf("Matrix B \n"); |
| 266 | _print_matrix(b); |
| 267 | printf("\n\n"); |
| 268 | GrB_Matrix_free(&b); |
| 269 | return false; |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | GrB_Matrix_free(&b); |
| 274 | return true; |
| 275 | } |
| 276 | |
| 277 | void _compare_algebraic_operand(AlgebraicExpression *a, AlgebraicExpression *b) { |
| 278 | TEST_ASSERT(a->type == AL_OPERAND); |
no test coverage detected