65 error (
"%s type invalid as index value", nm.c_str ());
105 "real sparse matrix",
"real scalar");
127 "real sparse matrix",
"complex scalar");
245 ::warning (
"range error for conversion to character value");
251 static_cast<char> (ival);
278 os.write (reinterpret_cast<char *> (&itmp), 4);
281 os.write (reinterpret_cast<char *> (&itmp), 4);
284 os.write (reinterpret_cast<char *> (&itmp), 4);
287 os.write (reinterpret_cast<char *> (&itmp), 4);
294 warning (
"save: some values too large to save as floats --");
295 warning (
"save: saving as doubles instead");
302 double max_val, min_val;
309 for (
int i = 0; i < nc+1; i++)
313 os.write (reinterpret_cast<char *> (&itmp), 4);
316 for (
int i = 0; i < nz; i++)
320 os.write (reinterpret_cast<char *> (&itmp), 4);
332 int32_t nz, nc, nr, tmp;
335 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
343 error (
"load: only 2-D sparse matrices are supported");
347 if (! is.read (reinterpret_cast<char *> (&nr), 4))
349 if (! is.read (reinterpret_cast<char *> (&nc), 4))
351 if (! is.read (reinterpret_cast<char *> (&nz), 4))
362 static_cast<octave_idx_type> (nc),
363 static_cast<octave_idx_type> (nz));
365 for (
int i = 0; i < nc+1; i++)
368 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
375 for (
int i = 0; i < nz; i++)
378 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
385 if (! is.read (reinterpret_cast<char *> (&ctmp), 1))
401 #if defined (HAVE_HDF5)
416 hid_t group_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT,
419 hid_t group_hid = H5Gcreate (loc_id, name, 0);
424 hid_t space_hid = -1, data_hid = -1;
430 space_hid = H5Screate_simple (0, hdims, 0);
433 H5Gclose (group_hid);
438 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
445 H5Sclose (space_hid);
446 H5Gclose (group_hid);
451 retval = H5Dwrite (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
456 H5Sclose (space_hid);
457 H5Gclose (group_hid);
462 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
469 H5Sclose (space_hid);
470 H5Gclose (group_hid);
475 retval = H5Dwrite (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
480 H5Sclose (space_hid);
481 H5Gclose (group_hid);
487 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
494 H5Sclose (space_hid);
495 H5Gclose (group_hid);
500 retval = H5Dwrite (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
505 H5Sclose (space_hid);
506 H5Gclose (group_hid);
510 H5Sclose (space_hid);
512 hdims[0] = m.
cols () + 1;
515 space_hid = H5Screate_simple (2, hdims, 0);
519 H5Gclose (group_hid);
524 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
525 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
527 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
532 H5Sclose (space_hid);
533 H5Gclose (group_hid);
538 retval = H5Dwrite (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
543 H5Sclose (space_hid);
544 H5Gclose (group_hid);
548 H5Sclose (space_hid);
553 space_hid = H5Screate_simple (2, hdims, 0);
557 H5Gclose (group_hid);
561 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
562 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
564 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
569 H5Sclose (space_hid);
570 H5Gclose (group_hid);
575 retval = H5Dwrite (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
580 H5Sclose (space_hid);
581 H5Gclose (group_hid);
585 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
591 warning (
"save: some values too large to save as floats --");
592 warning (
"save: saving as doubles instead");
595 save_type_hid = H5T_NATIVE_FLOAT;
597 #if HAVE_HDF5_INT2FLOAT_CONVERSIONS
601 double max_val, min_val;
610 data_hid = H5Dcreate (group_hid,
"data", save_type_hid, space_hid,
611 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
613 data_hid = H5Dcreate (group_hid,
"data", save_type_hid, space_hid,
618 H5Sclose (space_hid);
619 H5Gclose (group_hid);
623 double * dtmp = m.
xdata ();
624 retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL,
625 H5P_DEFAULT, dtmp) >= 0;
627 H5Sclose (space_hid);
628 H5Gclose (group_hid);
637 hid_t group_hid, data_hid, space_hid;
648 group_hid = H5Gopen (loc_id, name, H5P_DEFAULT);
650 group_hid = H5Gopen (loc_id, name);
652 if (group_hid < 0)
return false;
655 data_hid = H5Dopen (group_hid,
"nr", H5P_DEFAULT);
657 data_hid = H5Dopen (group_hid,
"nr");
659 space_hid = H5Dget_space (data_hid);
660 rank = H5Sget_simple_extent_ndims (space_hid);
665 H5Gclose (group_hid);
670 H5P_DEFAULT, &nr) < 0)
673 H5Gclose (group_hid);
680 data_hid = H5Dopen (group_hid,
"nc", H5P_DEFAULT);
682 data_hid = H5Dopen (group_hid,
"nc");
684 space_hid = H5Dget_space (data_hid);
685 rank = H5Sget_simple_extent_ndims (space_hid);
690 H5Gclose (group_hid);
695 H5P_DEFAULT, &nc) < 0)
698 H5Gclose (group_hid);
705 data_hid = H5Dopen (group_hid,
"nz", H5P_DEFAULT);
707 data_hid = H5Dopen (group_hid,
"nz");
709 space_hid = H5Dget_space (data_hid);
710 rank = H5Sget_simple_extent_ndims (space_hid);
715 H5Gclose (group_hid);
720 H5P_DEFAULT, &nz) < 0)
723 H5Gclose (group_hid);
730 static_cast<octave_idx_type> (nc),
731 static_cast<octave_idx_type> (nz));
734 data_hid = H5Dopen (group_hid,
"cidx", H5P_DEFAULT);
736 data_hid = H5Dopen (group_hid,
"cidx");
738 space_hid = H5Dget_space (data_hid);
739 rank = H5Sget_simple_extent_ndims (space_hid);
743 H5Sclose (space_hid);
745 H5Gclose (group_hid);
752 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
754 if (static_cast<int> (hdims[0]) != nc + 1
755 || static_cast<int> (hdims[1]) != 1)
757 H5Sclose (space_hid);
759 H5Gclose (group_hid);
765 H5P_DEFAULT, itmp) < 0)
767 H5Sclose (space_hid);
769 H5Gclose (group_hid);
773 H5Sclose (space_hid);
777 data_hid = H5Dopen (group_hid,
"ridx", H5P_DEFAULT);
779 data_hid = H5Dopen (group_hid,
"ridx");
781 space_hid = H5Dget_space (data_hid);
782 rank = H5Sget_simple_extent_ndims (space_hid);
786 H5Sclose (space_hid);
788 H5Gclose (group_hid);
792 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
794 if (static_cast<int> (hdims[0]) != nz || static_cast<int> (hdims[1]) != 1)
796 H5Sclose (space_hid);
798 H5Gclose (group_hid);
804 H5P_DEFAULT, itmp) < 0)
806 H5Sclose (space_hid);
808 H5Gclose (group_hid);
812 H5Sclose (space_hid);
816 data_hid = H5Dopen (group_hid,
"data", H5P_DEFAULT);
818 data_hid = H5Dopen (group_hid,
"data");
820 space_hid = H5Dget_space (data_hid);
821 rank = H5Sget_simple_extent_ndims (space_hid);
825 H5Sclose (space_hid);
827 H5Gclose (group_hid);
831 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
833 if (static_cast<int> (hdims[0]) != nz || static_cast<int> (hdims[1]) != 1)
835 H5Sclose (space_hid);
837 H5Gclose (group_hid);
841 double *dtmp = m.
xdata ();
843 if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL,
844 H5P_DEFAULT, dtmp) >= 0
851 H5Sclose (space_hid);
853 H5Gclose (group_hid);
867 double *pr =
static_cast<double *
> (retval->
get_data ());
871 for (
mwIndex i = 0; i < nz; i++)
877 for (
mwIndex i = 0; i < nc + 1; i++)
896 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
897 case umap_ ## UMAP: \
898 return octave_value (matrix.FCN ())
902 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
903 case umap_ ## UMAP: \
904 return octave_value (matrix.map<TYPE> (FCN))