Skip to content

Commit 27a2d8a

Browse files
committed
fix: correct assertion
Signed-off-by: Rodion Suvorov <rodion.suvorov.94@mail.ru>
1 parent 0921d2c commit 27a2d8a

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

experimental/algorithm/LAGraph_RPQMatrix.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@
123123
} \
124124
}
125125

126-
#include "LAGraphX.h"
127126
#include <stdbool.h>
128127
#include <stdio.h>
129128

@@ -140,12 +139,14 @@ GrB_Info LAGraph_RPQMatrix_check(RPQMatrixPlan *plan, GrB_Index *dimension, char
140139
OK(GrB_Matrix_ncols(&ncols, plan->mat));
141140
if (*dimension == -1)
142141
{
143-
*dimension = nrows;
142+
LG_ASSERT_MSG(nrows == ncols, GrB_INVALID_VALUE,
143+
"all the matrices in the graph adjacency matrix decomposition "
144+
"should have the same dimensions and be square");
144145
*dimension = ncols;
145146
}
146147
else
147148
{
148-
LG_ASSERT_MSG(nrows != *dimension || ncols != *dimension, GrB_INVALID_VALUE,
149+
LG_ASSERT_MSG(nrows == *dimension || ncols == *dimension, GrB_INVALID_VALUE,
149150
"all the matrices in the graph adjacency matrix decomposition "
150151
"should have the same dimensions and be square");
151152
}
@@ -298,6 +299,7 @@ static GrB_Info LAGraph_RPQMatrixKleene(RPQMatrixPlan *plan, char *msg)
298299
GRB_TRY(GrB_Matrix_free(&BPE));
299300
return (GrB_SUCCESS);
300301
}
302+
301303
static GrB_Info LAGraph_RPQMatrixKleene_L(RPQMatrixPlan *plan, char *msg)
302304
{
303305
LG_ASSERT(plan != NULL, GrB_NULL_POINTER);
@@ -330,12 +332,10 @@ static GrB_Info LAGraph_RPQMatrixKleene_L(RPQMatrixPlan *plan, char *msg)
330332

331333
GRB_TRY(GrB_Vector_free(&v));
332334

333-
// B + E
334335
GrB_Matrix BPE;
335336
GRB_TRY(GrB_Matrix_new(&BPE, GrB_BOOL, n, n));
336337
GRB_TRY(GrB_eWiseAdd(BPE, GrB_NULL, GrB_NULL,
337338
op, B, E, GrB_DESC_R));
338-
// S <- S x (B + E)
339339
GrB_Matrix S, T;
340340
GRB_TRY(GrB_Matrix_dup(&S, A));
341341

@@ -344,7 +344,6 @@ static GrB_Info LAGraph_RPQMatrixKleene_L(RPQMatrixPlan *plan, char *msg)
344344

345345
while (changed)
346346
{
347-
// T = S * (B + E)
348347
GRB_TRY(GrB_Matrix_new(&T, GrB_BOOL, n, n));
349348
GRB_TRY(GrB_mxm(T, GrB_NULL, GrB_NULL,
350349
sr, S, BPE, GrB_DESC_R));
@@ -402,12 +401,10 @@ static GrB_Info LAGraph_RPQMatrixKleene_R(RPQMatrixPlan *plan, char *msg)
402401

403402
GRB_TRY(GrB_Vector_free(&v));
404403

405-
// B + E
406404
GrB_Matrix BPE;
407405
GRB_TRY(GrB_Matrix_new(&BPE, GrB_BOOL, n, n));
408406
GRB_TRY(GrB_eWiseAdd(BPE, GrB_NULL, GrB_NULL,
409407
GrB_LOR, B, E, GrB_DESC_R));
410-
// S <- S x (B + E)
411408
GrB_Matrix S, T;
412409
GRB_TRY(GrB_Matrix_dup(&S, A));
413410

@@ -416,7 +413,6 @@ static GrB_Info LAGraph_RPQMatrixKleene_R(RPQMatrixPlan *plan, char *msg)
416413

417414
while (changed)
418415
{
419-
// T = S * (B + E)
420416
GRB_TRY(GrB_Matrix_new(&T, GrB_BOOL, n, n));
421417
GRB_TRY(GrB_mxm(T, GrB_NULL, GrB_NULL,
422418
sr, BPE, S, GrB_DESC_R));
@@ -495,9 +491,9 @@ GrB_Info LAGrah_RPQMatrix(
495491
//--------------------------------------------------------------------------
496492

497493
LG_CLEAR_MSG;
498-
LG_ASSERT_MSG(plan != NULL, GrB_NULL_POINTER, "empty graph");
494+
LG_ASSERT(plan == NULL, GrB_NULL_POINTER);
499495
GrB_Index dimension = -1;
500-
GrB_Info info = LAGraph_RPQMatrix_check(plan, dimension, msg);
496+
GrB_Info info = LAGraph_RPQMatrix_check(plan, &dimension, msg);
501497
LG_ASSERT_MSG(info == GrB_SUCCESS, info, msg);
502498

503499
//--------------------------------------------------------------------------
@@ -511,7 +507,7 @@ GrB_Info LAGrah_RPQMatrix(
511507
//--------------------------------------------------------------------------
512508

513509
info = LAGraph_RPQMatrix_solver(plan, msg);
514-
LG_ASSERT_MSG(info = GrB_SUCCESS, info, msg);
510+
LG_ASSERT_MSG(info == GrB_SUCCESS, info, msg);
515511
GrB_Matrinx_nvals(nnz, plan->res_mat);
516512
return GrB_SUCCESS;
517513
}

0 commit comments

Comments
 (0)