13
13
14
14
namespace binsparse {
15
15
16
- inline constexpr double version = 0.1 ;
16
+ inline const std::string version = " 0.1" ;
17
17
18
18
template <typename T>
19
19
void write_dense_vector (H5::Group& f, std::span<T> v,
@@ -25,7 +25,7 @@ void write_dense_vector(H5::Group& f, std::span<T> v,
25
25
j[" binsparse" ][" version" ] = version;
26
26
j[" binsparse" ][" format" ] = " DVEC" ;
27
27
j[" binsparse" ][" shape" ] = {v.size ()};
28
- j[" binsparse" ][" nnz " ] = v.size ();
28
+ j[" binsparse" ][" number_of_stored_values " ] = v.size ();
29
29
j[" binsparse" ][" data_types" ][" values" ] = type_info<T>::label ();
30
30
31
31
for (auto && v : user_keys.items ()) {
@@ -51,7 +51,7 @@ auto read_dense_vector(std::string fname, Allocator&& alloc = Allocator{}) {
51
51
assert (format == " DVEC" );
52
52
53
53
auto nvalues = binsparse_metadata[" shape" ][0 ];
54
- auto nnz = binsparse_metadata[" nnz " ];
54
+ auto nnz = binsparse_metadata[" number_of_stored_values " ];
55
55
56
56
assert (nvalues == nnz);
57
57
@@ -76,8 +76,14 @@ void write_dense_matrix(H5::Group& f, dense_matrix<T, I, Order> m,
76
76
j[" binsparse" ][" version" ] = version;
77
77
j[" binsparse" ][" format" ] = __detail::get_matrix_format_string (m);
78
78
j[" binsparse" ][" shape" ] = {m.m , m.n };
79
- j[" binsparse" ][" nnz" ] = m.m * m.n ;
80
- j[" binsparse" ][" data_types" ][" values" ] = type_info<T>::label ();
79
+ j[" binsparse" ][" number_of_stored_values" ] = m.m * m.n ;
80
+
81
+ if (!m.is_iso ) {
82
+ j[" binsparse" ][" data_types" ][" values" ] =
83
+ std::string (" iso[" ) + type_info<T>::label () + " ]" ;
84
+ } else {
85
+ j[" binsparse" ][" data_types" ][" values" ] = type_info<T>::label ();
86
+ }
81
87
82
88
if (m.structure != general) {
83
89
j[" binsparse" ][" structure" ] =
@@ -118,7 +124,13 @@ auto read_dense_matrix(std::string fname, Allocator&& alloc = Allocator{}) {
118
124
119
125
auto nrows = binsparse_metadata[" shape" ][0 ];
120
126
auto ncols = binsparse_metadata[" shape" ][1 ];
121
- auto nnz = binsparse_metadata[" nnz" ];
127
+ auto nnz = binsparse_metadata[" number_of_stored_values" ];
128
+
129
+ bool is_iso = false ;
130
+ if (std::string (binsparse_metadata[" data_types" ][" values" ])
131
+ .starts_with (" iso" )) {
132
+ is_iso = true ;
133
+ }
122
134
123
135
auto values = hdf5_tools::read_dataset<T>(f, " values" , alloc);
124
136
@@ -128,7 +140,8 @@ auto read_dense_matrix(std::string fname, Allocator&& alloc = Allocator{}) {
128
140
structure = __detail::parse_structure (binsparse_metadata[" structure" ]);
129
141
}
130
142
131
- return dense_matrix<T, I, Order>{values.data (), nrows, ncols, structure};
143
+ return dense_matrix<T, I, Order>{values.data (), nrows, ncols, structure,
144
+ is_iso};
132
145
}
133
146
134
147
// CSR Format
@@ -149,10 +162,16 @@ void write_csr_matrix(H5::Group& f, csr_matrix<T, I> m,
149
162
j[" binsparse" ][" version" ] = version;
150
163
j[" binsparse" ][" format" ] = " CSR" ;
151
164
j[" binsparse" ][" shape" ] = {m.m , m.n };
152
- j[" binsparse" ][" nnz " ] = m.nnz ;
165
+ j[" binsparse" ][" number_of_stored_values " ] = m.nnz ;
153
166
j[" binsparse" ][" data_types" ][" pointers_to_1" ] = type_info<I>::label ();
154
167
j[" binsparse" ][" data_types" ][" indices_1" ] = type_info<I>::label ();
155
- j[" binsparse" ][" data_types" ][" values" ] = type_info<T>::label ();
168
+
169
+ if (!m.is_iso ) {
170
+ j[" binsparse" ][" data_types" ][" values" ] =
171
+ std::string (" iso[" ) + type_info<T>::label () + " ]" ;
172
+ } else {
173
+ j[" binsparse" ][" data_types" ][" values" ] = type_info<T>::label ();
174
+ }
156
175
157
176
if (m.structure != general) {
158
177
j[" binsparse" ][" structure" ] =
@@ -189,7 +208,13 @@ csr_matrix<T, I> read_csr_matrix(std::string fname, Allocator&& alloc) {
189
208
190
209
auto nrows = binsparse_metadata[" shape" ][0 ];
191
210
auto ncols = binsparse_metadata[" shape" ][1 ];
192
- auto nnz = binsparse_metadata[" nnz" ];
211
+ auto nnz = binsparse_metadata[" number_of_stored_values" ];
212
+
213
+ bool is_iso = false ;
214
+ if (std::string (binsparse_metadata[" data_types" ][" values" ])
215
+ .starts_with (" iso" )) {
216
+ is_iso = true ;
217
+ }
193
218
194
219
typename std::allocator_traits<
195
220
std::remove_cvref_t <Allocator>>::template rebind_alloc<I>
@@ -206,7 +231,7 @@ csr_matrix<T, I> read_csr_matrix(std::string fname, Allocator&& alloc) {
206
231
}
207
232
208
233
return csr_matrix<T, I>{values.data (), colind.data (), row_ptr.data (), nrows,
209
- ncols, nnz, structure};
234
+ ncols, nnz, structure, is_iso };
210
235
}
211
236
212
237
template <typename T, typename I>
@@ -232,10 +257,16 @@ void write_csc_matrix(H5::Group& f, csc_matrix<T, I> m,
232
257
j[" binsparse" ][" version" ] = version;
233
258
j[" binsparse" ][" format" ] = " CSR" ;
234
259
j[" binsparse" ][" shape" ] = {m.m , m.n };
235
- j[" binsparse" ][" nnz " ] = m.nnz ;
260
+ j[" binsparse" ][" number_of_stored_values " ] = m.nnz ;
236
261
j[" binsparse" ][" data_types" ][" pointers_to_1" ] = type_info<I>::label ();
237
262
j[" binsparse" ][" data_types" ][" indices_1" ] = type_info<I>::label ();
238
- j[" binsparse" ][" data_types" ][" values" ] = type_info<T>::label ();
263
+
264
+ if (!m.is_iso ) {
265
+ j[" binsparse" ][" data_types" ][" values" ] =
266
+ std::string (" iso[" ) + type_info<T>::label () + " ]" ;
267
+ } else {
268
+ j[" binsparse" ][" data_types" ][" values" ] = type_info<T>::label ();
269
+ }
239
270
240
271
if (m.structure != general) {
241
272
j[" binsparse" ][" structure" ] =
@@ -272,7 +303,13 @@ csc_matrix<T, I> read_csc_matrix(std::string fname, Allocator&& alloc) {
272
303
273
304
auto nrows = binsparse_metadata[" shape" ][0 ];
274
305
auto ncols = binsparse_metadata[" shape" ][1 ];
275
- auto nnz = binsparse_metadata[" nnz" ];
306
+ auto nnz = binsparse_metadata[" number_of_stored_values" ];
307
+
308
+ bool is_iso = false ;
309
+ if (std::string (binsparse_metadata[" data_types" ][" values" ])
310
+ .starts_with (" iso" )) {
311
+ is_iso = true ;
312
+ }
276
313
277
314
typename std::allocator_traits<
278
315
std::remove_cvref_t <Allocator>>::template rebind_alloc<I>
@@ -289,7 +326,7 @@ csc_matrix<T, I> read_csc_matrix(std::string fname, Allocator&& alloc) {
289
326
}
290
327
291
328
return csc_matrix<T, I>{values.data (), rowind.data (), col_ptr.data (), nrows,
292
- ncols, nnz, structure};
329
+ ncols, nnz, structure, is_iso };
293
330
}
294
331
295
332
template <typename T, typename I>
@@ -315,10 +352,16 @@ void write_coo_matrix(H5::Group& f, coo_matrix<T, I> m,
315
352
j[" binsparse" ][" version" ] = version;
316
353
j[" binsparse" ][" format" ] = " COO" ;
317
354
j[" binsparse" ][" shape" ] = {m.m , m.n };
318
- j[" binsparse" ][" nnz " ] = m.nnz ;
355
+ j[" binsparse" ][" number_of_stored_values " ] = m.nnz ;
319
356
j[" binsparse" ][" data_types" ][" indices_0" ] = type_info<I>::label ();
320
357
j[" binsparse" ][" data_types" ][" indices_1" ] = type_info<I>::label ();
321
- j[" binsparse" ][" data_types" ][" values" ] = type_info<T>::label ();
358
+
359
+ if (!m.is_iso ) {
360
+ j[" binsparse" ][" data_types" ][" values" ] =
361
+ std::string (" iso[" ) + type_info<T>::label () + " ]" ;
362
+ } else {
363
+ j[" binsparse" ][" data_types" ][" values" ] = type_info<T>::label ();
364
+ }
322
365
323
366
if (m.structure != general) {
324
367
j[" binsparse" ][" structure" ] =
@@ -357,7 +400,13 @@ coo_matrix<T, I> read_coo_matrix(std::string fname, Allocator&& alloc) {
357
400
358
401
auto nrows = binsparse_metadata[" shape" ][0 ];
359
402
auto ncols = binsparse_metadata[" shape" ][1 ];
360
- auto nnz = binsparse_metadata[" nnz" ];
403
+ auto nnz = binsparse_metadata[" number_of_stored_values" ];
404
+
405
+ bool is_iso = false ;
406
+ if (std::string (binsparse_metadata[" data_types" ][" values" ])
407
+ .starts_with (" iso" )) {
408
+ is_iso = true ;
409
+ }
361
410
362
411
typename std::allocator_traits<
363
412
std::remove_cvref_t <Allocator>>::template rebind_alloc<I>
@@ -374,7 +423,7 @@ coo_matrix<T, I> read_coo_matrix(std::string fname, Allocator&& alloc) {
374
423
}
375
424
376
425
return coo_matrix<T, I>{values.data (), rows.data (), cols.data (), nrows,
377
- ncols, nnz, structure};
426
+ ncols, nnz, structure, is_iso };
378
427
}
379
428
380
429
template <typename T, typename I>
0 commit comments