Skip to content

Commit

Permalink
Merge pull request #253 from tweska/knobel
Browse files Browse the repository at this point in the history
bug fix for MMWrite (invalid output on array format)
  • Loading branch information
DrTimothyAldenDavis authored Jul 1, 2024
2 parents 1beaf9d + 275a986 commit 64a629f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data/comments_full.mtx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%%GraphBLAS type double
% comments for full.mtx
% this file was created by test_MMRead.c
3 3 9
3 3
.646
.709
.754
Expand Down
14 changes: 12 additions & 2 deletions src/utility/LAGraph_MMWrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,18 @@ int LAGraph_MMWrite
nvals_to_print = nself_edges + (nvals - nself_edges) / 2 ;
}

FPRINTF (f, "%" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
nrows, ncols, nvals_to_print) ;
if (MM_fmt == MM_array)
{
// write `nrows ncols` if the array format is used
FPRINTF (f, "%" PRIu64 " %" PRIu64 "\n",
nrows, ncols) ;
}
else
{
// otherwise write `nrows ncols nvals` for the coordinate format
FPRINTF (f, "%" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
nrows, ncols, nvals_to_print) ;
}

if (nvals_to_print == 0)
{
Expand Down

0 comments on commit 64a629f

Please sign in to comment.