Skip to content

Commit 8e70931

Browse files
committed
fix free matrices
get format from adj matrix fix free matrices
1 parent d201cd6 commit 8e70931

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎experimental/algorithm/LAGraph_CFL_AllPaths_advanced.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ GrB_Info LAGraph_CFL_AllPaths_adv(
224224
GRB_TRY(GrB_Scalar_setElement_UDT(bottom_scalar, (void*)(&bottom)));
225225

226226
GRB_TRY(GrB_BinaryOp_new(&AllPaths_add, (void*)add_all_paths, AllPaths_type, AllPaths_type, AllPaths_type));
227-
GRB_TRY(GrB_Monoid_new(&AllPaths_monoid, AllPaths_add, (void*)(&bottom)));
227+
GRB_TRY(GrB_Monoid_new_UDT(&AllPaths_monoid, AllPaths_add, (void*)(&bottom)));
228228

229229
GRB_TRY(GxB_IndexBinaryOp_new(&IAllPaths_mult, (void*)mult_all_paths_post, AllPaths_type,
230230
GrB_BOOL, GrB_BOOL, GrB_BOOL, "mult_all_paths_post", MULT_PATH_POST_INDEX_DEFN));
@@ -240,11 +240,14 @@ GrB_Info LAGraph_CFL_AllPaths_adv(
240240
LAGraph_Calloc((void**)&outputs_reachability, symbols_amount, sizeof(GrB_Matrix), msg);
241241
LG_TRY(LAGraph_CFL_reachability_adv(outputs_reachability, adj_matrices, symbols_amount, rules, rules_count, msg, optimizations));
242242

243+
int32_t format;
244+
GRB_TRY(GrB_get(adj_matrices[0], &format, GrB_STORAGE_ORIENTATION_HINT));
245+
243246
LG_TRY(LAGraph_Calloc((void**)&reachability_matrices, symbols_amount, sizeof(GrB_Matrix), msg));
244247
for (size_t i = 0; i < symbols_amount; i++) {
245248
reachability_matrices[i] = outputs_reachability[i] != NULL ? outputs_reachability[i] : adj_matrices[i];
246249
if (outputs_reachability[i] != NULL) {
247-
GRB_TRY(GrB_set(outputs_reachability[i], GrB_ROWMAJOR,
250+
GRB_TRY(GrB_set(outputs_reachability[i], format,
248251
GrB_STORAGE_ORIENTATION_HINT));
249252
}
250253
}
@@ -402,13 +405,13 @@ static void free_AllPaths_matrix(GrB_Matrix* ptr_output)
402405

403406
// Free outputs and all_paths_ptr_t after you have finished working with the output matrices from LAGraph_CFL_AllPaths.
404407
// do outputs = NULL, all_paths_ptr_t = NULL after LAGraph_CFL_AllPaths_free_outputs
405-
GrB_Info LAGraph_CFL_AllPaths_adv_free_outputs(GrB_Matrix* outputs, int64_t nonterms_count, GrB_Type* all_paths_ptr_t)
408+
GrB_Info LAGraph_CFL_AllPaths_adv_free_outputs(GrB_Matrix* outputs, int64_t symbols_amount, GrB_Type* all_paths_ptr_t)
406409
{
407410
#if GxB_IMPLEMENTATION < GxB_VERSION(9, 4, 5)
408411
return (GrB_NOT_IMPLEMENTED);
409412
#else
410413
if (outputs) {
411-
for (size_t i = 0; i < nonterms_count; i++) {
414+
for (size_t i = 0; i < symbols_amount; i++) {
412415
if (outputs[i] == NULL)
413416
continue;
414417
free_AllPaths_matrix(&outputs[i]);

‎include/LAGraphX.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ GrB_Info LAGraph_CFL_AllPaths_adv(
12961296
// do outputs = NULL, all_paths_ptr_t = NULL after LAGraph_CFL_AllPaths_adv_free_outputs
12971297
GrB_Info LAGraph_CFL_AllPaths_adv_free_outputs(
12981298
GrB_Matrix* outputs,
1299-
int64_t nonterms_count,
1299+
int64_t symbols_amount,
13001300
GrB_Type* all_paths_ptr_t);
13011301

13021302
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)