1313
1414namespace binsparse {
1515
16- inline constexpr double version = 0.1 ;
16+ inline const std::string version = " 0.1" ;
1717
1818template <typename T>
1919void 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,
2525 j[" binsparse" ][" version" ] = version;
2626 j[" binsparse" ][" format" ] = " DVEC" ;
2727 j[" binsparse" ][" shape" ] = {v.size ()};
28- j[" binsparse" ][" nnz " ] = v.size ();
28+ j[" binsparse" ][" number_of_stored_values " ] = v.size ();
2929 j[" binsparse" ][" data_types" ][" values" ] = type_info<T>::label ();
3030
3131 for (auto && v : user_keys.items ()) {
@@ -51,7 +51,7 @@ auto read_dense_vector(std::string fname, Allocator&& alloc = Allocator{}) {
5151 assert (format == " DVEC" );
5252
5353 auto nvalues = binsparse_metadata[" shape" ][0 ];
54- auto nnz = binsparse_metadata[" nnz " ];
54+ auto nnz = binsparse_metadata[" number_of_stored_values " ];
5555
5656 assert (nvalues == nnz);
5757
@@ -76,8 +76,14 @@ void write_dense_matrix(H5::Group& f, dense_matrix<T, I, Order> m,
7676 j[" binsparse" ][" version" ] = version;
7777 j[" binsparse" ][" format" ] = __detail::get_matrix_format_string (m);
7878 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+ }
8187
8288 if (m.structure != general) {
8389 j[" binsparse" ][" structure" ] =
@@ -118,7 +124,13 @@ auto read_dense_matrix(std::string fname, Allocator&& alloc = Allocator{}) {
118124
119125 auto nrows = binsparse_metadata[" shape" ][0 ];
120126 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+ }
122134
123135 auto values = hdf5_tools::read_dataset<T>(f, " values" , alloc);
124136
@@ -128,7 +140,8 @@ auto read_dense_matrix(std::string fname, Allocator&& alloc = Allocator{}) {
128140 structure = __detail::parse_structure (binsparse_metadata[" structure" ]);
129141 }
130142
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};
132145}
133146
134147// CSR Format
@@ -149,10 +162,16 @@ void write_csr_matrix(H5::Group& f, csr_matrix<T, I> m,
149162 j[" binsparse" ][" version" ] = version;
150163 j[" binsparse" ][" format" ] = " CSR" ;
151164 j[" binsparse" ][" shape" ] = {m.m , m.n };
152- j[" binsparse" ][" nnz " ] = m.nnz ;
165+ j[" binsparse" ][" number_of_stored_values " ] = m.nnz ;
153166 j[" binsparse" ][" data_types" ][" pointers_to_1" ] = type_info<I>::label ();
154167 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+ }
156175
157176 if (m.structure != general) {
158177 j[" binsparse" ][" structure" ] =
@@ -189,7 +208,13 @@ csr_matrix<T, I> read_csr_matrix(std::string fname, Allocator&& alloc) {
189208
190209 auto nrows = binsparse_metadata[" shape" ][0 ];
191210 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+ }
193218
194219 typename std::allocator_traits<
195220 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) {
206231 }
207232
208233 return csr_matrix<T, I>{values.data (), colind.data (), row_ptr.data (), nrows,
209- ncols, nnz, structure};
234+ ncols, nnz, structure, is_iso };
210235}
211236
212237template <typename T, typename I>
@@ -232,10 +257,16 @@ void write_csc_matrix(H5::Group& f, csc_matrix<T, I> m,
232257 j[" binsparse" ][" version" ] = version;
233258 j[" binsparse" ][" format" ] = " CSR" ;
234259 j[" binsparse" ][" shape" ] = {m.m , m.n };
235- j[" binsparse" ][" nnz " ] = m.nnz ;
260+ j[" binsparse" ][" number_of_stored_values " ] = m.nnz ;
236261 j[" binsparse" ][" data_types" ][" pointers_to_1" ] = type_info<I>::label ();
237262 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+ }
239270
240271 if (m.structure != general) {
241272 j[" binsparse" ][" structure" ] =
@@ -272,7 +303,13 @@ csc_matrix<T, I> read_csc_matrix(std::string fname, Allocator&& alloc) {
272303
273304 auto nrows = binsparse_metadata[" shape" ][0 ];
274305 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+ }
276313
277314 typename std::allocator_traits<
278315 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) {
289326 }
290327
291328 return csc_matrix<T, I>{values.data (), rowind.data (), col_ptr.data (), nrows,
292- ncols, nnz, structure};
329+ ncols, nnz, structure, is_iso };
293330}
294331
295332template <typename T, typename I>
@@ -315,10 +352,16 @@ void write_coo_matrix(H5::Group& f, coo_matrix<T, I> m,
315352 j[" binsparse" ][" version" ] = version;
316353 j[" binsparse" ][" format" ] = " COO" ;
317354 j[" binsparse" ][" shape" ] = {m.m , m.n };
318- j[" binsparse" ][" nnz " ] = m.nnz ;
355+ j[" binsparse" ][" number_of_stored_values " ] = m.nnz ;
319356 j[" binsparse" ][" data_types" ][" indices_0" ] = type_info<I>::label ();
320357 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+ }
322365
323366 if (m.structure != general) {
324367 j[" binsparse" ][" structure" ] =
@@ -357,7 +400,13 @@ coo_matrix<T, I> read_coo_matrix(std::string fname, Allocator&& alloc) {
357400
358401 auto nrows = binsparse_metadata[" shape" ][0 ];
359402 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+ }
361410
362411 typename std::allocator_traits<
363412 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) {
374423 }
375424
376425 return coo_matrix<T, I>{values.data (), rows.data (), cols.data (), nrows,
377- ncols, nnz, structure};
426+ ncols, nnz, structure, is_iso };
378427}
379428
380429template <typename T, typename I>
0 commit comments