26 #if defined (HAVE_CONFIG_H)
57 "sparse bool matrix",
"logical");
110 "bool sparse matrix",
"real scalar");
123 "bool sparse matrix",
"complex scalar");
223 os.write (
reinterpret_cast<char *
> (&itmp), 4);
226 os.write (
reinterpret_cast<char *
> (&itmp), 4);
229 os.write (
reinterpret_cast<char *
> (&itmp), 4);
232 os.write (
reinterpret_cast<char *
> (&itmp), 4);
236 for (
int i = 0; i < nc+1; i++)
240 os.write (
reinterpret_cast<char *
> (&itmp), 4);
243 for (
int i = 0; i < nz; i++)
247 os.write (
reinterpret_cast<char *
> (&itmp), 4);
252 for (
int i = 0; i < nz; i++)
264 int32_t nz, nc, nr, tmp;
265 if (! is.read (
reinterpret_cast<char *
> (&tmp), 4))
272 error (
"load: only 2-D sparse matrices are supported");
274 if (! is.read (
reinterpret_cast<char *
> (&nr), 4))
276 if (! is.read (
reinterpret_cast<char *
> (&nc), 4))
278 if (! is.read (
reinterpret_cast<char *
> (&nz), 4))
292 for (
int i = 0; i < nc+1; i++)
295 if (! is.read (
reinterpret_cast<char *
> (&tmp), 4))
302 for (
int i = 0; i < nz; i++)
305 if (! is.read (
reinterpret_cast<char *
> (&tmp), 4))
317 if (! is.read (htmp, nz))
320 for (
int i = 0; i < nz; i++)
321 m.data(i) = (htmp[i] ? 1 : 0);
323 if (!
m.indices_ok ())
337 #if defined (HAVE_HDF5)
346 #if defined (HAVE_HDF5_18)
350 hid_t group_hid = H5Gcreate (loc_id,
name, 0);
355 hid_t space_hid, data_hid;
356 space_hid = data_hid = -1;
361 space_hid = H5Screate_simple (0, hdims,
nullptr);
364 H5Gclose (group_hid);
367 #if defined (HAVE_HDF5_18)
377 H5Sclose (space_hid);
378 H5Gclose (group_hid);
388 H5Sclose (space_hid);
389 H5Gclose (group_hid);
393 #if defined (HAVE_HDF5_18)
403 H5Sclose (space_hid);
404 H5Gclose (group_hid);
414 H5Sclose (space_hid);
415 H5Gclose (group_hid);
419 #if defined (HAVE_HDF5_18)
429 H5Sclose (space_hid);
430 H5Gclose (group_hid);
440 H5Sclose (space_hid);
441 H5Gclose (group_hid);
445 H5Sclose (space_hid);
447 hdims[0] =
m.cols () + 1;
450 space_hid = H5Screate_simple (2, hdims,
nullptr);
454 H5Gclose (group_hid);
458 #if defined (HAVE_HDF5_18)
459 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
463 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
468 H5Sclose (space_hid);
469 H5Gclose (group_hid);
479 H5Sclose (space_hid);
480 H5Gclose (group_hid);
484 H5Sclose (space_hid);
489 space_hid = H5Screate_simple (2, hdims,
nullptr);
493 H5Gclose (group_hid);
497 #if defined (HAVE_HDF5_18)
498 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
502 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
507 H5Sclose (space_hid);
508 H5Gclose (group_hid);
518 H5Sclose (space_hid);
519 H5Gclose (group_hid);
523 #if defined (HAVE_HDF5_18)
524 data_hid = H5Dcreate (group_hid,
"data", H5T_NATIVE_HBOOL, space_hid,
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);
545 H5Sclose (space_hid);
546 H5Gclose (group_hid);
549 octave_unused_parameter (loc_id);
550 octave_unused_parameter (
name);
563 #if defined (HAVE_HDF5)
566 hid_t group_hid, data_hid, space_hid;
576 #if defined (HAVE_HDF5_18)
579 group_hid = H5Gopen (loc_id,
name);
581 if (group_hid < 0)
return false;
583 #if defined (HAVE_HDF5_18)
586 data_hid = H5Dopen (group_hid,
"nr");
588 space_hid = H5Dget_space (data_hid);
589 rank = H5Sget_simple_extent_ndims (space_hid);
594 H5Gclose (group_hid);
603 H5Gclose (group_hid);
609 #if defined (HAVE_HDF5_18)
612 data_hid = H5Dopen (group_hid,
"nc");
614 space_hid = H5Dget_space (data_hid);
615 rank = H5Sget_simple_extent_ndims (space_hid);
620 H5Gclose (group_hid);
629 H5Gclose (group_hid);
635 #if defined (HAVE_HDF5_18)
638 data_hid = H5Dopen (group_hid,
"nz");
640 space_hid = H5Dget_space (data_hid);
641 rank = H5Sget_simple_extent_ndims (space_hid);
646 H5Gclose (group_hid);
655 H5Gclose (group_hid);
665 #if defined (HAVE_HDF5_18)
668 data_hid = H5Dopen (group_hid,
"cidx");
670 space_hid = H5Dget_space (data_hid);
671 rank = H5Sget_simple_extent_ndims (space_hid);
675 H5Sclose (space_hid);
677 H5Gclose (group_hid);
684 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
686 if (
static_cast<int> (hdims[0]) != nc + 1
687 ||
static_cast<int> (hdims[1]) != 1)
689 H5Sclose (space_hid);
691 H5Gclose (group_hid);
700 H5Sclose (space_hid);
702 H5Gclose (group_hid);
706 H5Sclose (space_hid);
709 #if defined (HAVE_HDF5_18)
712 data_hid = H5Dopen (group_hid,
"ridx");
714 space_hid = H5Dget_space (data_hid);
715 rank = H5Sget_simple_extent_ndims (space_hid);
719 H5Sclose (space_hid);
721 H5Gclose (group_hid);
725 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
727 if (
static_cast<int> (hdims[0]) != nz
728 ||
static_cast<int> (hdims[1]) != 1)
730 H5Sclose (space_hid);
732 H5Gclose (group_hid);
740 H5Sclose (space_hid);
742 H5Gclose (group_hid);
746 H5Sclose (space_hid);
749 #if defined (HAVE_HDF5_18)
752 data_hid = H5Dopen (group_hid,
"data");
754 space_hid = H5Dget_space (data_hid);
755 rank = H5Sget_simple_extent_ndims (space_hid);
759 H5Sclose (space_hid);
761 H5Gclose (group_hid);
765 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
767 if (
static_cast<int> (hdims[0]) != nz
768 ||
static_cast<int> (hdims[1]) != 1)
770 H5Sclose (space_hid);
772 H5Gclose (group_hid);
784 for (
int i = 0; i < nz; i++)
785 m.xdata(i) = htmp[i];
790 H5Sclose (space_hid);
792 H5Gclose (group_hid);
795 octave_unused_parameter (loc_id);
796 octave_unused_parameter (
name);
810 bool *pr =
static_cast<bool *
> (
retval->get_data ());
814 for (
mwIndex i = 0; i < nz; i++)
void swap_bytes< 4 >(void *ptr)
boolMatrix matrix_value(void) const
octave_idx_type cols(void) const
octave_idx_type * cidx(void)
void resize(octave_idx_type r, octave_idx_type c)
octave_idx_type rows(void) const
size_t byte_size(void) const
Sparse< T > maybe_compress(bool remove_zeros=false)
octave_idx_type * ridx(void)
Vector representing the dimensions (size) of an Array.
octave_idx_type ndims(void) const
Number of dimensions.
octave_idx_type nnz(void) const
octave_idx_type nzmax(void) const
octave_idx_type numel(void) const
dim_vector dims(void) const
octave_idx_type columns(void) const
void warn_load(const char *type) const
octave_idx_type rows(void) const
friend class octave_value
void warn_save(const char *type) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
double double_value(bool=false) const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
NDArray array_value(bool=false) const
Complex complex_value(bool=false) const
mxArray * as_mxArray(void) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
charNDArray char_array_value(bool=false) const
ComplexMatrix complex_matrix_value(bool=false) const
boolMatrix bool_matrix_value(bool=false) const
ComplexNDArray complex_array_value(bool=false) const
octave_value as_double(void) const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
SparseMatrix sparse_matrix_value(bool=false) const
octave_base_value * try_narrowing_conversion(void)
SparseBoolMatrix sparse_bool_matrix_value(bool=false) const
bool save_binary(std::ostream &os, bool save_as_floats)
Matrix matrix_value(bool=false) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
type_conv_info numeric_conversion_function(void) const
boolNDArray bool_array_value(bool=false) const
static int static_type_id(void)
octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
void error(const char *fmt,...)
void err_invalid_conversion(const std::string &from, const std::string &to)
void warn_implicit_conversion(const char *id, const char *from, const char *to)
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
std::complex< double > Complex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
static octave_base_value * default_numeric_conversion_function(const octave_base_value &a)
octave_value::octave_value(const Array< char > &chm, char type) return retval