@@ -60,22 +60,20 @@ csr_matrix<T, I> read_csr_matrix(std::string fname, Allocator&& alloc) {
60
60
61
61
auto binsparse_metadata = data[" binsparse" ];
62
62
63
- if (binsparse_metadata[" format" ] == " CSR" ) {
64
- auto nrows = binsparse_metadata[" shape" ][0 ];
65
- auto ncols = binsparse_metadata[" shape" ][1 ];
66
- auto nnz = binsparse_metadata[" nnz" ];
63
+ assert (binsparse_metadata[" format" ] == " CSR" );
67
64
68
- typename std::allocator_traits<std::remove_cvref_t <Allocator>>
69
- :: template rebind_alloc<I> i_alloc (alloc);
65
+ auto nrows = binsparse_metadata[" shape" ][0 ];
66
+ auto ncols = binsparse_metadata[" shape" ][1 ];
67
+ auto nnz = binsparse_metadata[" nnz" ];
70
68
71
- auto values = hdf5_tools::read_dataset<T>(f, " values" , alloc);
72
- auto colind = hdf5_tools::read_dataset<I>(f, " indices_1" , i_alloc);
73
- auto row_ptr = hdf5_tools::read_dataset<I>(f, " pointers_to_1" , i_alloc);
69
+ typename std::allocator_traits<std::remove_cvref_t <Allocator>>
70
+ :: template rebind_alloc<I> i_alloc (alloc);
74
71
75
- return csr_matrix<T, I>{values.data (), colind.data (), row_ptr.data (), nrows, ncols, nnz};
76
- } else {
77
- assert (false );
78
- }
72
+ auto values = hdf5_tools::read_dataset<T>(f, " values" , alloc);
73
+ auto colind = hdf5_tools::read_dataset<I>(f, " indices_1" , i_alloc);
74
+ auto row_ptr = hdf5_tools::read_dataset<I>(f, " pointers_to_1" , i_alloc);
75
+
76
+ return csr_matrix<T, I>{values.data (), colind.data (), row_ptr.data (), nrows, ncols, nnz};
79
77
}
80
78
81
79
template <typename T, typename I>
@@ -130,22 +128,20 @@ coo_matrix<T, I> read_coo_matrix(std::string fname, Allocator&& alloc) {
130
128
131
129
auto binsparse_metadata = data[" binsparse" ];
132
130
133
- if (binsparse_metadata[" format" ] == " COO" ) {
134
- auto nrows = binsparse_metadata[" shape" ][0 ];
135
- auto ncols = binsparse_metadata[" shape" ][1 ];
136
- auto nnz = binsparse_metadata[" nnz" ];
131
+ assert (binsparse_metadata[" format" ] == " COO" );
137
132
138
- typename std::allocator_traits<std::remove_cvref_t <Allocator>>
139
- :: template rebind_alloc<I> i_alloc (alloc);
133
+ auto nrows = binsparse_metadata[" shape" ][0 ];
134
+ auto ncols = binsparse_metadata[" shape" ][1 ];
135
+ auto nnz = binsparse_metadata[" nnz" ];
140
136
141
- auto values = hdf5_tools::read_dataset<T>(f, " values" , alloc);
142
- auto rows = hdf5_tools::read_dataset<I>(f, " indices_0" , i_alloc);
143
- auto cols = hdf5_tools::read_dataset<I>(f, " indices_1" , i_alloc);
137
+ typename std::allocator_traits<std::remove_cvref_t <Allocator>>
138
+ :: template rebind_alloc<I> i_alloc (alloc);
144
139
145
- return coo_matrix<T, I>{values.data (), rows.data (), cols.data (), nrows, ncols, nnz};
146
- } else {
147
- assert (false );
148
- }
140
+ auto values = hdf5_tools::read_dataset<T>(f, " values" , alloc);
141
+ auto rows = hdf5_tools::read_dataset<I>(f, " indices_0" , i_alloc);
142
+ auto cols = hdf5_tools::read_dataset<I>(f, " indices_1" , i_alloc);
143
+
144
+ return coo_matrix<T, I>{values.data (), rows.data (), cols.data (), nrows, ncols, nnz};
149
145
}
150
146
151
147
template <typename T, typename I>
@@ -163,11 +159,9 @@ inline auto inspect(std::string fname) {
163
159
164
160
auto binsparse_metadata = data[" binsparse" ];
165
161
166
- if (binsparse_metadata[" version" ] >= 0.1 ) {
167
- return data;
168
- } else {
169
- assert (false );
170
- }
162
+ assert (binsparse_metadata[" version" ] >= 0.1 );
163
+
164
+ return data;
171
165
}
172
166
173
167
} // end binsparse
0 commit comments