From b7b46c28cce78d90728778189d8c85352b52d823 Mon Sep 17 00:00:00 2001 From: LTLA Date: Thu, 3 Oct 2024 16:44:27 -0700 Subject: [PATCH] Shifted row= and parallel= to regular (non-template) arguments. This is easier to use and aligns with new tatami interface where the row/column layout is specified in the constructor. --- CMakeLists.txt | 2 +- include/tatami_mtx/load_matrix.hpp | 218 ++++++++++++++++------------- tests/src/load_matrix.cpp | 46 +++--- 3 files changed, 143 insertions(+), 123 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61e73a4..7ddea7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.14) project(tatami_mtx - VERSION 1.0.0 + VERSION 2.0.0 DESCRIPTION "Matrix Market to tatami matrices" LANGUAGES CXX) diff --git a/include/tatami_mtx/load_matrix.hpp b/include/tatami_mtx/load_matrix.hpp index aab6a90..ba401cb 100644 --- a/include/tatami_mtx/load_matrix.hpp +++ b/include/tatami_mtx/load_matrix.hpp @@ -22,12 +22,14 @@ struct Automatic {}; /** * @cond */ -template -std::shared_ptr > load_sparse_matrix_basic(Parser_& parser, eminem::Field field, size_t NR, size_t NC, size_t NL) { +namespace internal { + +template +std::shared_ptr > load_sparse_matrix_basic(Parser_& parser, eminem::Field field, size_t NR, size_t NC, size_t NL) { std::vector::type> rows; std::vector::type> columns; rows.reserve(NL), columns.reserve(NL); - std::vector values; + std::vector values; values.reserve(NL); if (field == eminem::Field::INTEGER) { @@ -56,57 +58,51 @@ std::shared_ptr > load_sparse_matrix_basic(Parser_ indices.swap(rows); } - return std::shared_ptr >( - new tatami::CompressedSparseMatrix( - NR, NC, std::move(values), std::move(indices), std::move(ptr), false + return std::shared_ptr >( + new tatami::CompressedSparseMatrix( + NR, NC, std::move(values), std::move(indices), std::move(ptr), row_, false ) ); } -template -std::shared_ptr > load_sparse_matrix_data(Parser_& parser, eminem::Field field, size_t NR, size_t NC, size_t NL) { - if constexpr(std::is_same::value) { +template +std::shared_ptr > load_sparse_matrix_data(Parser_& parser, eminem::Field field, size_t NR, size_t NC, size_t NL) { + if constexpr(std::is_same::value) { if (field == eminem::Field::REAL || field == eminem::Field::DOUBLE) { - return load_sparse_matrix_basic(parser, field, NR, NC, NL); + return load_sparse_matrix_basic(parser, field, NR, NC, NL); } if (field != eminem::Field::INTEGER) { throw std::runtime_error("unsupported Matrix Market field type"); } - return load_sparse_matrix_basic(parser, field, NR, NC, NL); + return load_sparse_matrix_basic(parser, field, NR, NC, NL); } else { - return load_sparse_matrix_basic(parser, field, NR, NC, NL); + return load_sparse_matrix_basic(parser, field, NR, NC, NL); } } -template -std::shared_ptr > load_sparse_matrix_index(Parser_& parser, eminem::Field field, size_t NR, size_t NC, size_t NL) { +template +std::shared_ptr > load_sparse_matrix_index(Parser_& parser, eminem::Field field, size_t NR, size_t NC, size_t NL) { if constexpr(std::is_same::value) { // Automatically choosing a smaller integer type, if it fits. constexpr size_t limit8 = std::numeric_limits::max(), limit16 = std::numeric_limits::max(); size_t target = (row_ ? NC : NR); if (target <= limit8) { - return load_sparse_matrix_data(parser, field, NR, NC, NL); + return load_sparse_matrix_data(parser, field, NR, NC, NL); } else if (target <= limit16) { - return load_sparse_matrix_data(parser, field, NR, NC, NL); + return load_sparse_matrix_data(parser, field, NR, NC, NL); } else { - return load_sparse_matrix_data(parser, field, NR, NC, NL); + return load_sparse_matrix_data(parser, field, NR, NC, NL); } } else { - return load_sparse_matrix_data(parser, field, NR, NC, NL); + return load_sparse_matrix_data(parser, field, NR, NC, NL); } } -/** - * @endcond - */ -/** - * @cond - */ -template -std::shared_ptr > load_dense_matrix_basic(Parser_& parser, eminem::Field field, size_t NR, size_t NC) { - std::vector values; +template +std::shared_ptr > load_dense_matrix_basic(Parser_& parser, eminem::Field field, size_t NR, size_t NC) { + std::vector values; if constexpr(row_) { values.resize(NR * NC); } else { @@ -135,67 +131,87 @@ std::shared_ptr > load_dense_matrix_basic(Parser_& throw std::runtime_error("unsupported Matrix Market field type"); } - return std::shared_ptr >( - new tatami::DenseMatrix(NR, NC, std::move(values)) + return std::shared_ptr >( + new tatami::DenseMatrix(NR, NC, std::move(values), row_) ); } -/** - * @endcond - */ -/** - * Load a `tatami::Matrix` from a Matrix Market file. - * Coordinate formats will yield a sparse matrix, while array formats will yield a dense matrix. - * The storage types depend on the Matrix Market field type as well as the settings of `StoredData_` and `StoredIndex_`. - * - * @tparam row_ Whether to produce a dense row-major or compressed sparse row matrix. - * If `false`, column-based matrices are returned instead. - * @tparam Data_ Data type for the `tatami::Matrix` interface. - * @tparam Index_ Integer index type for the `tatami::Matrix` interface. - * @tparam StoredData_ Matrix data type that is stored in memory. - * If set to `Automatic`, it defaults to `double` for real/double fields and `int` for integer fields. - * @tparam StoredIndex_ Index data type that is stored in memory for sparse matrices. - * If set to `Automatic`, it defaults to `uint8_t` if no dimension is greater than 255; `uint16_t` if no dimension is greater than 65536; and `int` otherwise. - * @tparam parallel_ Whether to parallelize the loading and parsing. - * - * @param reader A `byteme::Reader` instance containing bytes from a Matrix Market file. - * - * @return Pointer to a `tatami::Matrix` instance containing data from the Matrix Market file. - */ -template -std::shared_ptr > load_matrix(byteme::Reader& reader) { +template +std::shared_ptr > load_matrix(byteme::Reader& reader) { eminem::Parser parser(&reader); parser.scan_preamble(); const auto& banner = parser.get_banner(); auto field = banner.field; + auto format = banner.format; size_t NR = parser.get_nrows(), NC = parser.get_ncols(), NL = parser.get_nlines(); - if (banner.format == eminem::Format::COORDINATE) { + if (format == eminem::Format::COORDINATE) { // Automatically choosing a smaller integer type for the temporary index. constexpr size_t limit8 = std::numeric_limits::max(), limit16 = std::numeric_limits::max(); auto primary = (row_ ? NR : NC); if (primary <= limit8) { - return load_sparse_matrix_index(parser, field, NR, NC, NL); + return load_sparse_matrix_index(parser, field, NR, NC, NL); } else if (primary <= limit16) { - return load_sparse_matrix_index(parser, field, NR, NC, NL); + return load_sparse_matrix_index(parser, field, NR, NC, NL); } else { - return load_sparse_matrix_index(parser, field, NR, NC, NL); + return load_sparse_matrix_index(parser, field, NR, NC, NL); } } else { - if constexpr(std::is_same::value) { + if constexpr(std::is_same::value) { if (field == eminem::Field::REAL || field == eminem::Field::DOUBLE) { - return load_dense_matrix_basic(parser, field, NR, NC); + return load_dense_matrix_basic(parser, field, NR, NC); } if (field != eminem::Field::INTEGER) { throw std::runtime_error("unsupported Matrix Market field type"); } - return load_dense_matrix_basic(parser, field, NR, NC); + return load_dense_matrix_basic(parser, field, NR, NC); + + } else { + return load_dense_matrix_basic(parser, field, NR, NC); + } + } +} + +} +/** + * @endcond + */ +/** + * Load a `tatami::Matrix` from a Matrix Market file. + * Coordinate formats will yield a sparse matrix, while array formats will yield a dense matrix. + * The storage types depend on the Matrix Market field type as well as the settings of `StoredValue_` and `StoredIndex_`. + * + * @tparam Value_ Data type for the `tatami::Matrix` interface. + * @tparam Index_ Integer index type for the `tatami::Matrix` interface. + * @tparam StoredValue_ Matrix data type that is stored in memory. + * If set to `Automatic`, it defaults to `double` for real/double fields and `int` for integer fields. + * @tparam StoredIndex_ Index data type that is stored in memory for sparse matrices. + * If set to `Automatic`, it defaults to `uint8_t` if no dimension is greater than 255; `uint16_t` if no dimension is greater than 65536; and `int` otherwise. + * + * @param reader A `byteme::Reader` instance containing bytes from a Matrix Market file. + * @param row Whether to produce a dense row-major or compressed sparse row matrix. + * If `false`, column-based matrices are returned instead. + * @param parallel Whether to parallelize the loading and parsing. + * + * @return Pointer to a `tatami::Matrix` instance containing data from the Matrix Market file. + */ +template +std::shared_ptr > load_matrix(byteme::Reader& reader, bool row, bool parallel = false) { + if (row) { + if (parallel) { + return internal::load_matrix(reader); + } else { + return internal::load_matrix(reader); + } + } else { + if (parallel) { + return internal::load_matrix(reader); } else { - return load_dense_matrix_basic(parser, field, NR, NC); + return internal::load_matrix(reader); } } } @@ -203,22 +219,23 @@ std::shared_ptr > load_matrix(byteme::Reader& read /** * Load a `tatami::Matrix` from a Matrix Market text file, see `load_matrix()` for details. * - * @tparam row_ Whether to produce a row-based matrix, see `load_matrix()` for details. - * @tparam Data_ Data type for the `tatami::Matrix` interface. + * @tparam Value_ Data type for the `tatami::Matrix` interface. * @tparam Index_ Integer index type for the `tatami::Matrix` interface. - * @tparam StoredData_ Matrix data type that is stored in memory, see `load_matrix()` for details. + * @tparam StoredValue_ Matrix data type that is stored in memory, see `load_matrix()` for details. * @tparam StoredIndex_ Index data type that is stored in memory for sparse matrices, see `load_matrix()` for details. * @tparam parallel_ Whether to parallelize the loading and parsing. * * @param filepath Path to a Matrix Market file. + * @param row Whether to produce a row-based matrix, see `load_matrix()` for details. * @param bufsize Size of the buffer (in bytes) to use when reading from file. + * @param parallel Whether to parallelize the loading and parsing. * * @return Pointer to a `tatami::Matrix` instance containing data from the Matrix Market file. */ -template -std::shared_ptr > load_matrix_from_text_file(const char* filepath, size_t bufsize = 65536) { +template +std::shared_ptr > load_matrix_from_text_file(const char* filepath, bool row, size_t bufsize = 65536, bool parallel = false) { byteme::RawFileReader reader(filepath, bufsize); - return load_matrix(reader); + return load_matrix(reader, row, parallel); } #if __has_include("zlib.h") @@ -226,43 +243,45 @@ std::shared_ptr > load_matrix_from_text_file(const /** * Load a `tatami::Matrix` from a Gzip-compressed Matrix Market file, see `load_matrix()` for details. * - * @tparam row_ Whether to produce a row-based matrix, see `load_matrix()` for details. - * @tparam Data_ Data type for the `tatami::Matrix` interface. + * @tparam Value_ Data type for the `tatami::Matrix` interface. * @tparam Index_ Integer index type for the `tatami::Matrix` interface. - * @tparam StoredData_ Matrix data type that is stored in memory, see `load_matrix()` for details. + * @tparam StoredValue_ Matrix data type that is stored in memory, see `load_matrix()` for details. * @tparam StoredIndex_ Index data type that is stored in memory for sparse matrices, see `load_matrix()` for details. * @tparam parallel_ Whether to parallelize the loading and parsing. * * @param filepath Path to a Matrix Market file. + * @param row Whether to produce a row-based matrix, see `load_matrix()` for details. * @param bufsize Size of the buffer (in bytes) to use when reading from file. + * @param parallel Whether to parallelize the loading and parsing. * * @return Pointer to a `tatami::Matrix` instance containing data from the Matrix Market file. */ -template -std::shared_ptr > load_matrix_from_gzip_file(const char* filepath, size_t bufsize = 65536) { +template +std::shared_ptr > load_matrix_from_gzip_file(const char* filepath, bool row, size_t bufsize = 65536, bool parallel = false) { byteme::GzipFileReader reader(filepath, bufsize); - return load_matrix(reader); + return load_matrix(reader, row, parallel); } /** * Load a `tatami::Matrix` from a possibly Gzip-compressed Matrix Market file, see `load_matrix()` for details. * - * @tparam row_ Whether to produce a row-based matrix, see `load_matrix()` for details. - * @tparam Data_ Data type for the `tatami::Matrix` interface. + * @tparam Value_ Data type for the `tatami::Matrix` interface. * @tparam Index_ Integer index type for the `tatami::Matrix` interface. - * @tparam StoredData_ Matrix data type that is stored in memory, see `load_matrix()` for details. + * @tparam StoredValue_ Matrix data type that is stored in memory, see `load_matrix()` for details. * @tparam StoredIndex_ Index data type that is stored in memory for sparse matrices, see `load_matrix()` for details. * @tparam parallel_ Whether to parallelize the loading and parsing. * * @param filepath Path to a Matrix Market file. + * @param row Whether to produce a row-based matrix, see `load_matrix()` for details. * @param bufsize Size of the buffer (in bytes) to use when reading from file. + * @param parallel Whether to parallelize the loading and parsing. * * @return Pointer to a `tatami::Matrix` instance containing data from the Matrix Market file. */ -template -std::shared_ptr > load_matrix_from_some_file(const char* filepath, size_t bufsize = 65536) { +template +std::shared_ptr > load_matrix_from_some_file(const char* filepath, bool row, size_t bufsize = 65536, bool parallel = false) { byteme::SomeFileReader reader(filepath, bufsize); - return load_matrix(reader); + return load_matrix(reader, row, parallel); } #endif @@ -270,22 +289,22 @@ std::shared_ptr > load_matrix_from_some_file(const /** * Load a `tatami::Matrix` from a buffer containing a Matrix Market file, see `load_matrix()` for details. * - * @tparam row_ Whether to produce a row-based matrix, see `load_matrix()` for details. - * @tparam Data_ Data type for the `tatami::Matrix` interface. + * @tparam Value_ Data type for the `tatami::Matrix` interface. * @tparam Index_ Integer index type for the `tatami::Matrix` interface. - * @tparam StoredData_ Matrix data type that is stored in memory, see `load_matrix()` for details. + * @tparam StoredValue_ Matrix data type that is stored in memory, see `load_matrix()` for details. * @tparam StoredIndex_ Index data type that is stored in memory for sparse matrices, see `load_matrix()` for details. - * @tparam parallel_ Whether to parallelize the loading and parsing. * * @param buffer Array containing the contents of an uncompressed Matrix Market file. * @param n Length of the array. + * @param row Whether to produce a row-based matrix, see `load_matrix()` for details. + * @param parallel Whether to parallelize the loading and parsing. * * @return Pointer to a `tatami::Matrix` instance containing data from the Matrix Market file. */ -template -std::shared_ptr > load_matrix_from_text_buffer(const unsigned char* buffer, size_t n) { +template +std::shared_ptr > load_matrix_from_text_buffer(const unsigned char* buffer, size_t n, bool row, bool parallel = false) { byteme::RawBufferReader reader(buffer, n); - return load_matrix(reader); + return load_matrix(reader, row, parallel); } #if __has_include("zlib.h") @@ -293,47 +312,48 @@ std::shared_ptr > load_matrix_from_text_buffer(con /** * Load a `tatami::Matrix` from a buffer containing a Gzip/Zlib-compressed Matrix Market file, see `load_matrix()` for details. * - * @tparam row_ Whether to produce a row-based matrix, see `load_matrix()` for details. - * @tparam Data_ Data type for the `tatami::Matrix` interface. + * @tparam Value_ Data type for the `tatami::Matrix` interface. * @tparam Index_ Integer index type for the `tatami::Matrix` interface. - * @tparam StoredData_ Matrix data type that is stored in memory, see `load_matrix()` for details. + * @tparam StoredValue_ Matrix data type that is stored in memory, see `load_matrix()` for details. * @tparam StoredIndex_ Index data type that is stored in memory for sparse matrices, see `load_matrix()` for details. - * @tparam parallel_ Whether to parallelize the loading and parsing. * * @param buffer Array containing the contents of a Matrix Market file after Gzip/Zlib compression. * @param n Length of the array. + * @param row Whether to produce a row-based matrix, see `load_matrix()` for details. * @param compression Compression of the stream - DEFLATE (0), Zlib (1) or Gzip (2). * Default of 3 will auto-detect between Zlib and Gzip based on the headers. * @param bufsize Size of the buffer (in bytes) to use when decompressing the file contents. + * @param parallel Whether to parallelize the loading and parsing. * * @return Pointer to a `tatami::Matrix` instance containing data from the Matrix Market file. */ -template -std::shared_ptr > load_matrix_from_zlib_buffer(const unsigned char* buffer, size_t n, int compression = 3, size_t bufsize = 65536) { +template +std::shared_ptr > load_matrix_from_zlib_buffer(const unsigned char* buffer, size_t n, bool row, int compression = 3, size_t bufsize = 65536, bool parallel = false) { byteme::ZlibBufferReader reader(buffer, n, compression, bufsize); - return load_matrix(reader); + return load_matrix(reader, row, parallel); } /** * Load a `tatami::Matrix` from a buffer containing a possibly Gzip/Zlib-compressed Matrix Market file, see `load_matrix()` for details. * - * @tparam row_ Whether to produce a row-based matrix, see `load_matrix()` for details. - * @tparam Data_ Data type for the `tatami::Matrix` interface. + * @tparam Value_ Data type for the `tatami::Matrix` interface. * @tparam Index_ Integer index type for the `tatami::Matrix` interface. - * @tparam StoredData_ Matrix data type that is stored in memory, see `load_matrix()` for details. + * @tparam StoredValue_ Matrix data type that is stored in memory, see `load_matrix()` for details. * @tparam StoredIndex_ Index data type that is stored in memory for sparse matrices, see `load_matrix()` for details. * @tparam parallel_ Whether to parallelize the loading and parsing. * * @param buffer Array containing the contents of a Matrix Market file, possibly after Gzip/Zlib compression. * @param n Length of the array. + * @param row Whether to produce a row-based matrix, see `load_matrix()` for details. * @param bufsize Size of the buffer (in bytes) to use when decompressing the file contents. + * @param parallel Whether to parallelize the loading and parsing. * * @return Pointer to a `tatami::Matrix` instance containing data from the Matrix Market file. */ -template -std::shared_ptr > load_matrix_from_some_buffer(const unsigned char* buffer, size_t n, size_t bufsize = 65536) { +template +std::shared_ptr > load_matrix_from_some_buffer(const unsigned char* buffer, size_t n, bool row, size_t bufsize = 65536, bool parallel = false) { byteme::SomeBufferReader reader(buffer, n, bufsize); - return load_matrix(reader); + return load_matrix(reader, row, parallel); } #endif diff --git a/tests/src/load_matrix.cpp b/tests/src/load_matrix.cpp index c725b4a..8ea9673 100644 --- a/tests/src/load_matrix.cpp +++ b/tests/src/load_matrix.cpp @@ -119,7 +119,7 @@ TEST_F(LoadMatrixInputTest, SimpleBuffer) { // Uncompressed. { - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -128,7 +128,7 @@ TEST_F(LoadMatrixInputTest, SimpleBuffer) { // Automatic. { - auto out = tatami_mtx::load_matrix_from_some_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_some_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -145,7 +145,7 @@ TEST_F(LoadMatrixInputTest, SimpleText) { // Uncompressed. { - auto out = tatami_mtx::load_matrix_from_text_file(path.c_str()); + auto out = tatami_mtx::load_matrix_from_text_file(path.c_str(), /* row = */ true); EXPECT_TRUE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -154,7 +154,7 @@ TEST_F(LoadMatrixInputTest, SimpleText) { // Automatic. { - auto out = tatami_mtx::load_matrix_from_some_file(path.c_str()); + auto out = tatami_mtx::load_matrix_from_some_file(path.c_str(), /* row = */ true); EXPECT_TRUE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -171,7 +171,7 @@ TEST_F(LoadMatrixInputTest, ZlibBuffer) { // Compressed. { - auto out = tatami_mtx::load_matrix_from_zlib_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_zlib_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -180,7 +180,7 @@ TEST_F(LoadMatrixInputTest, ZlibBuffer) { // Automatic. { - auto out = tatami_mtx::load_matrix_from_some_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_some_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -197,7 +197,7 @@ TEST_F(LoadMatrixInputTest, GzipFile) { // Compressed. { - auto out = tatami_mtx::load_matrix_from_gzip_file(path.c_str()); + auto out = tatami_mtx::load_matrix_from_gzip_file(path.c_str(), /* row = */ true); EXPECT_TRUE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -206,7 +206,7 @@ TEST_F(LoadMatrixInputTest, GzipFile) { // Automatic. { - auto out = tatami_mtx::load_matrix_from_some_file(path.c_str()); + auto out = tatami_mtx::load_matrix_from_some_file(path.c_str(), /* row = */ true); EXPECT_TRUE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -227,7 +227,7 @@ TEST_F(LoadMatrixIndexTest, Index8) { write_coordinate(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -241,7 +241,7 @@ TEST_F(LoadMatrixIndexTest, Index16) { write_coordinate(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -255,7 +255,7 @@ TEST_F(LoadMatrixIndexTest, Index32) { write_coordinate(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -269,7 +269,7 @@ TEST_F(LoadMatrixIndexTest, IndexCustom) { write_coordinate(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -287,7 +287,7 @@ TEST_F(LoadMatrixIndexTest, TempIndex8) { write_coordinate(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ true); EXPECT_TRUE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -301,7 +301,7 @@ TEST_F(LoadMatrixIndexTest, TempIndex16) { write_coordinate(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ true); EXPECT_TRUE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -315,7 +315,7 @@ TEST_F(LoadMatrixIndexTest, TempIndex32) { write_coordinate(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ true); EXPECT_TRUE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -335,7 +335,7 @@ TEST_F(LoadMatrixIntegerTypeTest, CoordinateAutomatic) { write_coordinate(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ true); EXPECT_TRUE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -349,7 +349,7 @@ TEST_F(LoadMatrixIntegerTypeTest, CoordinateCustom) { write_coordinate(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -363,7 +363,7 @@ TEST_F(LoadMatrixIntegerTypeTest, ArrayAutomatic) { write_array(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ true); EXPECT_TRUE(out->prefer_rows()); EXPECT_FALSE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -377,7 +377,7 @@ TEST_F(LoadMatrixIntegerTypeTest, ArrayCustom) { write_array(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_FALSE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -397,7 +397,7 @@ TEST_F(LoadMatrixFloatTypeTest, CoordinateAutomatic) { write_coordinate(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ true); EXPECT_TRUE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -411,7 +411,7 @@ TEST_F(LoadMatrixFloatTypeTest, CoordinateCustom) { write_coordinate(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_TRUE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -425,7 +425,7 @@ TEST_F(LoadMatrixFloatTypeTest, ArrayAutomatic) { write_array(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ true); EXPECT_TRUE(out->prefer_rows()); EXPECT_FALSE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get()); @@ -439,7 +439,7 @@ TEST_F(LoadMatrixFloatTypeTest, ArrayCustom) { write_array(writer); const auto& buffer = writer.output; - auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size()); + auto out = tatami_mtx::load_matrix_from_text_buffer(buffer.data(), buffer.size(), /* row = */ false); EXPECT_FALSE(out->prefer_rows()); EXPECT_FALSE(out->sparse()); tatami_test::test_simple_row_access(out.get(), ref.get());