55 "sparse bool matrix",
"logical");
108 "bool sparse matrix",
"real scalar");
129 "bool sparse matrix",
"complex scalar");
229 os.write (reinterpret_cast<char *> (&itmp), 4);
232 os.write (reinterpret_cast<char *> (&itmp), 4);
235 os.write (reinterpret_cast<char *> (&itmp), 4);
238 os.write (reinterpret_cast<char *> (&itmp), 4);
242 for (
int i = 0; i < nc+1; i++)
246 os.write (reinterpret_cast<char *> (&itmp), 4);
249 for (
int i = 0; i < nz; i++)
253 os.write (reinterpret_cast<char *> (&itmp), 4);
258 for (
int i = 0; i < nz; i++)
270 int32_t nz, nc, nr, tmp;
271 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
279 error (
"load: only 2-D sparse matrices are supported");
283 if (! is.read (reinterpret_cast<char *> (&nr), 4))
285 if (! is.read (reinterpret_cast<char *> (&nc), 4))
287 if (! is.read (reinterpret_cast<char *> (&nz), 4))
298 static_cast<octave_idx_type> (nc),
299 static_cast<octave_idx_type> (nz));
301 for (
int i = 0; i < nc+1; i++)
304 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
311 for (
int i = 0; i < nz; i++)
314 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
326 if (! is.read (htmp, nz))
329 for (
int i = 0; i < nz; i++)
330 m.
data(i) = (htmp[i] ? 1 : 0);
340 #if defined (HAVE_HDF5)
353 hid_t group_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT,
356 hid_t group_hid = H5Gcreate (loc_id, name, 0);
361 hid_t space_hid = -1, data_hid = -1;
367 space_hid = H5Screate_simple (0, hdims, 0);
370 H5Gclose (group_hid);
375 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
382 H5Sclose (space_hid);
383 H5Gclose (group_hid);
389 H5S_ALL, H5P_DEFAULT, &tmp) >= 0;
393 H5Sclose (space_hid);
394 H5Gclose (group_hid);
400 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
407 H5Sclose (space_hid);
408 H5Gclose (group_hid);
414 H5P_DEFAULT, &tmp) >= 0;
418 H5Sclose (space_hid);
419 H5Gclose (group_hid);
425 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
432 H5Sclose (space_hid);
433 H5Gclose (group_hid);
439 H5P_DEFAULT, &tmp) >= 0;
443 H5Sclose (space_hid);
444 H5Gclose (group_hid);
448 H5Sclose (space_hid);
450 hdims[0] = m.
cols () + 1;
453 space_hid = H5Screate_simple (2, hdims, 0);
457 H5Gclose (group_hid);
462 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
463 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
465 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
470 H5Sclose (space_hid);
471 H5Gclose (group_hid);
477 H5P_DEFAULT, itmp) >= 0;
481 H5Sclose (space_hid);
482 H5Gclose (group_hid);
486 H5Sclose (space_hid);
491 space_hid = H5Screate_simple (2, hdims, 0);
495 H5Gclose (group_hid);
500 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
501 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
503 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
508 H5Sclose (space_hid);
509 H5Gclose (group_hid);
515 H5P_DEFAULT, itmp) >= 0;
519 H5Sclose (space_hid);
520 H5Gclose (group_hid);
525 data_hid = H5Dcreate (group_hid,
"data", H5T_NATIVE_HBOOL, space_hid,
526 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
528 data_hid = H5Dcreate (group_hid,
"data", H5T_NATIVE_HBOOL, space_hid,
533 H5Sclose (space_hid);
534 H5Gclose (group_hid);
539 for (
int i = 0; i < m.
nnz (); i++)
540 htmp[i] = m.
xdata(i);
542 retval = H5Dwrite (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL,
543 H5P_DEFAULT, htmp) >= 0;
545 H5Sclose (space_hid);
546 H5Gclose (group_hid);
555 hid_t group_hid, data_hid, space_hid;
566 group_hid = H5Gopen (loc_id, name, H5P_DEFAULT);
568 group_hid = H5Gopen (loc_id, name);
570 if (group_hid < 0 )
return false;
573 data_hid = H5Dopen (group_hid,
"nr", H5P_DEFAULT);
575 data_hid = H5Dopen (group_hid,
"nr");
577 space_hid = H5Dget_space (data_hid);
578 rank = H5Sget_simple_extent_ndims (space_hid);
583 H5Gclose (group_hid);
587 if (H5Dread (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nr)
591 H5Gclose (group_hid);
598 data_hid = H5Dopen (group_hid,
"nc", H5P_DEFAULT);
600 data_hid = H5Dopen (group_hid,
"nc");
602 space_hid = H5Dget_space (data_hid);
603 rank = H5Sget_simple_extent_ndims (space_hid);
608 H5Gclose (group_hid);
612 if (H5Dread (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nc)
616 H5Gclose (group_hid);
623 data_hid = H5Dopen (group_hid,
"nz", H5P_DEFAULT);
625 data_hid = H5Dopen (group_hid,
"nz");
627 space_hid = H5Dget_space (data_hid);
628 rank = H5Sget_simple_extent_ndims (space_hid);
633 H5Gclose (group_hid);
637 if (H5Dread (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nz)
641 H5Gclose (group_hid);
648 static_cast<octave_idx_type> (nc),
649 static_cast<octave_idx_type> (nz));
652 data_hid = H5Dopen (group_hid,
"cidx", H5P_DEFAULT);
654 data_hid = H5Dopen (group_hid,
"cidx");
656 space_hid = H5Dget_space (data_hid);
657 rank = H5Sget_simple_extent_ndims (space_hid);
661 H5Sclose (space_hid);
663 H5Gclose (group_hid);
670 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
672 if (static_cast<int> (hdims[0]) != nc + 1
673 || static_cast<int> (hdims[1]) != 1)
675 H5Sclose (space_hid);
677 H5Gclose (group_hid);
682 if (H5Dread (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, itmp)
685 H5Sclose (space_hid);
687 H5Gclose (group_hid);
691 H5Sclose (space_hid);
695 data_hid = H5Dopen (group_hid,
"ridx", H5P_DEFAULT);
697 data_hid = H5Dopen (group_hid,
"ridx");
699 space_hid = H5Dget_space (data_hid);
700 rank = H5Sget_simple_extent_ndims (space_hid);
704 H5Sclose (space_hid);
706 H5Gclose (group_hid);
710 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
712 if (static_cast<int> (hdims[0]) != nz
713 || static_cast<int> (hdims[1]) != 1)
715 H5Sclose (space_hid);
717 H5Gclose (group_hid);
723 H5P_DEFAULT, itmp) < 0)
725 H5Sclose (space_hid);
727 H5Gclose (group_hid);
731 H5Sclose (space_hid);
735 data_hid = H5Dopen (group_hid,
"data", H5P_DEFAULT);
737 data_hid = H5Dopen (group_hid,
"data");
739 space_hid = H5Dget_space (data_hid);
740 rank = H5Sget_simple_extent_ndims (space_hid);
744 H5Sclose (space_hid);
746 H5Gclose (group_hid);
750 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
752 if (static_cast<int> (hdims[0]) != nz
753 || static_cast<int> (hdims[1]) != 1)
755 H5Sclose (space_hid);
757 H5Gclose (group_hid);
763 if (H5Dread (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL,
764 H5P_DEFAULT, htmp) >= 0
769 for (
int i = 0; i < nz; i++)
770 m.
xdata(i) = htmp[i];
775 H5Sclose (space_hid);
777 H5Gclose (group_hid);
790 bool *pr =
static_cast<bool *
> (retval->
get_data ());
794 for (
mwIndex i = 0; i < nz; i++)