Skip to content

Commit 73a57a8

Browse files
committed
Update convert_matrixmarket.cpp
1 parent befea01 commit 73a57a8

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ endfunction()
66
add_example(convert_binsparse)
77
add_example(text2hdf5)
88
add_example(inspect_binsparse)
9+
add_example(convert_matrixmarket)

examples/convert_matrixmarket.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
int main(int argc, char** argv) {
77

88
if (argc < 2) {
9-
std::cout << "usage: ./inspect_binsparse [input_file.mtx]\n";
9+
std::cout << "usage: ./inspect_binsparse [matrix.bsp.h5]\n";
1010
return 1;
1111
}
1212

1313
std::string input_file(argv[1]);
1414

15-
auto metadata = binsparse::inspect(input_file);
15+
auto json = binsparse::inspect(input_file);
16+
17+
auto metadata = json["binsparse"];
1618

1719
std::cout << "Inspecting Binsparse v" << metadata["version"] << " file...\n";
1820
std::cout << metadata["format"] << " format matrix of dimension "

include/binsparse/type_info.hpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ template <typename Fn, typename... Args>
116116
void invoke_visit_fn_impl_(std::vector<std::string> type_labels, Fn&& fn,
117117
Args&&... args) {
118118
if constexpr (sizeof...(Args) <= 3) {
119-
if (type_labels.size() == 1) {
119+
// The first label we consume is the value label
120+
if (type_labels.size() == 3) {
120121
auto type_label = type_labels.front();
121122
if (type_label == "uint8") {
122123
invoke_if_able(std::forward<Fn>(fn), std::uint8_t(),
@@ -155,6 +156,7 @@ void invoke_visit_fn_impl_(std::vector<std::string> type_labels, Fn&& fn,
155156
assert(false);
156157
}
157158
} else {
159+
// The next two types are index types, which must be integrals.
158160
auto type_label = type_labels.back();
159161
type_labels.pop_back();
160162
if (type_label == "uint8") {
@@ -181,15 +183,6 @@ void invoke_visit_fn_impl_(std::vector<std::string> type_labels, Fn&& fn,
181183
} else if (type_label == "int64") {
182184
invoke_visit_fn_impl_(type_labels, std::forward<Fn>(fn), std::int64_t(),
183185
std::forward<Args>(args)...);
184-
} else if (type_label == "float32") {
185-
invoke_visit_fn_impl_(type_labels, std::forward<Fn>(fn), float(),
186-
std::forward<Args>(args)...);
187-
} else if (type_label == "float64") {
188-
invoke_visit_fn_impl_(type_labels, std::forward<Fn>(fn), double(),
189-
std::forward<Args>(args)...);
190-
} else if (type_label == "bint8") {
191-
invoke_visit_fn_impl_(type_labels, std::forward<Fn>(fn), bool(),
192-
std::forward<Args>(args)...);
193186
} else {
194187
assert(false);
195188
}

0 commit comments

Comments
 (0)