MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / _compare_matrices

Function _compare_matrices

tests/unit/test_algebraic_expression.c:223–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223bool _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
277void _compare_algebraic_operand(AlgebraicExpression *a, AlgebraicExpression *b) {
278 TEST_ASSERT(a->type == AL_OPERAND);

Callers 6

test_Exp_OP_ADDFunction · 0.85
test_Exp_OP_MULFunction · 0.85
test_ExpressionExecuteFunction · 0.85

Calls 7

RG_Matrix_exportFunction · 0.85
GrB_Matrix_ncolsFunction · 0.85
GrB_Matrix_nrowsFunction · 0.85
GrB_Matrix_nvalsFunction · 0.85
GrB_Matrix_freeFunction · 0.85
GrB_Matrix_waitFunction · 0.85
_print_matrixFunction · 0.85

Tested by

no test coverage detected