Skip to content

Commit

Permalink
from PR #253: bug fix to MMWrite for dense matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTimothyAldenDavis committed Jul 1, 2024
1 parent 8270262 commit 19d8f3f
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 @@ -439,8 +439,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 19d8f3f

Please sign in to comment.