Skip to content

Commit

Permalink
Merge write_raw defaulting to sparse output format
Browse files Browse the repository at this point in the history
This changes the default to sparse output to avoid excessive storage requirements in the worst case.

Related PR: #1533
  • Loading branch information
upsj authored Jan 18, 2024
2 parents 7089030 + 6a9cddf commit 717f24e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions core/test/base/mtx_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ TEST(MatrixData, WritesDoubleRealMatrixToMatrixMarketArray)
// clang-format on
std::ostringstream oss{};

write_raw(oss, data);
write_raw(oss, data, gko::layout_type::array);

ASSERT_EQ(oss.str(),
"%%MatrixMarket matrix array real general\n"
Expand All @@ -666,7 +666,7 @@ TEST(MatrixData, WritesFloatRealMatrixToMatrixMarketCoordinate)
// clang-format on
std::ostringstream oss{};

write_raw(oss, data, gko::layout_type::coordinate);
write_raw(oss, data);

ASSERT_EQ(oss.str(),
"%%MatrixMarket matrix coordinate real general\n"
Expand All @@ -689,7 +689,7 @@ TEST(MatrixData, WritesDoubleRealMatrixToMatrixMarketArrayWith64Index)
// clang-format on
std::ostringstream oss{};

write_raw(oss, data);
write_raw(oss, data, gko::layout_type::array);

ASSERT_EQ(oss.str(),
"%%MatrixMarket matrix array real general\n"
Expand All @@ -713,7 +713,7 @@ TEST(MatrixData, WritesFloatRealMatrixToMatrixMarketCoordinateWith64Index)
// clang-format on
std::ostringstream oss{};

write_raw(oss, data, gko::layout_type::coordinate);
write_raw(oss, data);

ASSERT_EQ(oss.str(),
"%%MatrixMarket matrix coordinate real general\n"
Expand All @@ -736,7 +736,7 @@ TEST(MatrixData, WritesComplexDoubleMatrixToMatrixMarketArray)
// clang-format on
std::ostringstream oss{};

write_raw(oss, data);
write_raw(oss, data, gko::layout_type::array);

ASSERT_EQ(oss.str(),
"%%MatrixMarket matrix array complex general\n"
Expand All @@ -760,7 +760,7 @@ TEST(MatrixData, WritesComplexFloatMatrixToMatrixMarketCoordinate)
// clang-format on
std::ostringstream oss{};

write_raw(oss, data, gko::layout_type::coordinate);
write_raw(oss, data);

ASSERT_EQ(oss.str(),
"%%MatrixMarket matrix coordinate complex general\n"
Expand All @@ -783,7 +783,7 @@ TEST(MatrixData, WritesComplexDoubleMatrixToMatrixMarketArrayWith64Index)
// clang-format on
std::ostringstream oss{};

write_raw(oss, data);
write_raw(oss, data, gko::layout_type::array);

ASSERT_EQ(oss.str(),
"%%MatrixMarket matrix array complex general\n"
Expand All @@ -807,7 +807,7 @@ TEST(MatrixData, WritesComplexFloatMatrixToMatrixMarketCoordinateWith64Index)
// clang-format on
std::ostringstream oss{};

write_raw(oss, data, gko::layout_type::coordinate);
write_raw(oss, data);

ASSERT_EQ(oss.str(),
"%%MatrixMarket matrix coordinate complex general\n"
Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/base/mtx_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ enum class layout_type {
*/
template <typename ValueType, typename IndexType>
void write_raw(std::ostream& os, const matrix_data<ValueType, IndexType>& data,
layout_type layout = layout_type::array);
layout_type layout = layout_type::coordinate);


/**
Expand Down

0 comments on commit 717f24e

Please sign in to comment.