24 #if defined (HAVE_CONFIG_H) 55 "sparse bool matrix",
"logical");
108 "bool sparse matrix",
"real scalar");
121 "bool sparse matrix",
"complex scalar");
131 return tmp.convert_to_str (pad, force,
type);
221 os.
write (reinterpret_cast<char *> (&itmp), 4);
224 os.
write (reinterpret_cast<char *> (&itmp), 4);
227 os.
write (reinterpret_cast<char *> (&itmp), 4);
230 os.
write (reinterpret_cast<char *> (&itmp), 4);
234 for (
int i = 0;
i < nc+1;
i++)
238 os.
write (reinterpret_cast<char *> (&itmp), 4);
241 for (
int i = 0;
i < nz;
i++)
245 os.
write (reinterpret_cast<char *> (&itmp), 4);
250 for (
int i = 0;
i < nz;
i++)
262 int32_t nz, nc, nr,
tmp;
263 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
270 error (
"load: only 2-D sparse matrices are supported");
272 if (!
is.read (reinterpret_cast<char *> (&nr), 4))
274 if (!
is.read (reinterpret_cast<char *> (&nc), 4))
276 if (!
is.read (reinterpret_cast<char *> (&nz), 4))
287 static_cast<octave_idx_type> (nc),
288 static_cast<octave_idx_type> (nz));
290 for (
int i = 0;
i < nc+1;
i++)
293 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
300 for (
int i = 0;
i < nz;
i++)
303 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
315 if (!
is.read (htmp, nz))
318 for (
int i = 0;
i < nz;
i++)
319 m.
data(
i) = (htmp[
i] ? 1 : 0);
335 #if defined (HAVE_HDF5) 344 #if defined (HAVE_HDF5_18) 348 hid_t group_hid = H5Gcreate (loc_id,
name, 0);
353 hid_t space_hid, data_hid;
354 space_hid = data_hid = -1;
359 space_hid = H5Screate_simple (0, hdims,
nullptr);
362 H5Gclose (group_hid);
365 #if defined (HAVE_HDF5_18) 375 H5Sclose (space_hid);
376 H5Gclose (group_hid);
386 H5Sclose (space_hid);
387 H5Gclose (group_hid);
391 #if defined (HAVE_HDF5_18) 401 H5Sclose (space_hid);
402 H5Gclose (group_hid);
412 H5Sclose (space_hid);
413 H5Gclose (group_hid);
417 #if defined (HAVE_HDF5_18) 427 H5Sclose (space_hid);
428 H5Gclose (group_hid);
438 H5Sclose (space_hid);
439 H5Gclose (group_hid);
443 H5Sclose (space_hid);
445 hdims[0] = m.
cols () + 1;
448 space_hid = H5Screate_simple (2, hdims,
nullptr);
452 H5Gclose (group_hid);
456 #if defined (HAVE_HDF5_18) 457 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
461 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
466 H5Sclose (space_hid);
467 H5Gclose (group_hid);
477 H5Sclose (space_hid);
478 H5Gclose (group_hid);
482 H5Sclose (space_hid);
487 space_hid = H5Screate_simple (2, hdims,
nullptr);
491 H5Gclose (group_hid);
495 #if defined (HAVE_HDF5_18) 496 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
500 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
505 H5Sclose (space_hid);
506 H5Gclose (group_hid);
516 H5Sclose (space_hid);
517 H5Gclose (group_hid);
521 #if defined (HAVE_HDF5_18) 522 data_hid = H5Dcreate (group_hid,
"data", H5T_NATIVE_HBOOL, space_hid,
526 data_hid = H5Dcreate (group_hid,
"data", H5T_NATIVE_HBOOL, space_hid,
531 H5Sclose (space_hid);
532 H5Gclose (group_hid);
537 for (
int i = 0;
i < m.
nnz ();
i++)
543 H5Sclose (space_hid);
544 H5Gclose (group_hid);
547 octave_unused_parameter (loc_id);
548 octave_unused_parameter (
name);
561 #if defined (HAVE_HDF5) 564 hid_t group_hid, data_hid, space_hid;
574 #if defined (HAVE_HDF5_18) 577 group_hid = H5Gopen (loc_id,
name);
579 if (group_hid < 0)
return false;
581 #if defined (HAVE_HDF5_18) 584 data_hid = H5Dopen (group_hid,
"nr");
586 space_hid = H5Dget_space (data_hid);
587 rank = H5Sget_simple_extent_ndims (space_hid);
592 H5Gclose (group_hid);
601 H5Gclose (group_hid);
607 #if defined (HAVE_HDF5_18) 610 data_hid = H5Dopen (group_hid,
"nc");
612 space_hid = H5Dget_space (data_hid);
613 rank = H5Sget_simple_extent_ndims (space_hid);
618 H5Gclose (group_hid);
627 H5Gclose (group_hid);
633 #if defined (HAVE_HDF5_18) 636 data_hid = H5Dopen (group_hid,
"nz");
638 space_hid = H5Dget_space (data_hid);
639 rank = H5Sget_simple_extent_ndims (space_hid);
644 H5Gclose (group_hid);
653 H5Gclose (group_hid);
660 static_cast<octave_idx_type> (nc),
661 static_cast<octave_idx_type> (nz));
663 #if defined (HAVE_HDF5_18) 666 data_hid = H5Dopen (group_hid,
"cidx");
668 space_hid = H5Dget_space (data_hid);
669 rank = H5Sget_simple_extent_ndims (space_hid);
673 H5Sclose (space_hid);
675 H5Gclose (group_hid);
682 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
684 if (static_cast<int> (hdims[0]) != nc + 1
685 || static_cast<int> (hdims[1]) != 1)
687 H5Sclose (space_hid);
689 H5Gclose (group_hid);
698 H5Sclose (space_hid);
700 H5Gclose (group_hid);
704 H5Sclose (space_hid);
707 #if defined (HAVE_HDF5_18) 710 data_hid = H5Dopen (group_hid,
"ridx");
712 space_hid = H5Dget_space (data_hid);
713 rank = H5Sget_simple_extent_ndims (space_hid);
717 H5Sclose (space_hid);
719 H5Gclose (group_hid);
723 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
725 if (static_cast<int> (hdims[0]) != nz
726 || static_cast<int> (hdims[1]) != 1)
728 H5Sclose (space_hid);
730 H5Gclose (group_hid);
738 H5Sclose (space_hid);
740 H5Gclose (group_hid);
744 H5Sclose (space_hid);
747 #if defined (HAVE_HDF5_18) 750 data_hid = H5Dopen (group_hid,
"data");
752 space_hid = H5Dget_space (data_hid);
753 rank = H5Sget_simple_extent_ndims (space_hid);
757 H5Sclose (space_hid);
759 H5Gclose (group_hid);
763 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
765 if (static_cast<int> (hdims[0]) != nz
766 || static_cast<int> (hdims[1]) != 1)
768 H5Sclose (space_hid);
770 H5Gclose (group_hid);
782 for (
int i = 0;
i < nz;
i++)
788 H5Sclose (space_hid);
790 H5Gclose (group_hid);
793 octave_unused_parameter (loc_id);
794 octave_unused_parameter (
name);
808 bool *pr =
static_cast<bool *
> (
retval->get_data ());
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, mach_info::float_format flt_fmt)
double double_value(bool=false) const
void resize(octave_idx_type r, octave_idx_type c)
charNDArray char_array_value(bool=false) const
octave_idx_type nnz(void) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
boolNDArray bool_array_value(bool=false) const
const octave_hdf5_id octave_H5S_ALL
boolMatrix matrix_value(void) const
mxArray * as_mxArray(void) const
dim_vector dims(void) const
octave_idx_type * cidx(void)
octave_value as_double(void) const
void error(const char *fmt,...)
bool save_binary(std::ostream &os, bool &save_as_floats)
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
SparseBoolMatrix sparse_bool_matrix_value(bool=false) const
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
ComplexMatrix complex_matrix_value(bool=false) const
void warn_load(const char *type) const
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
octave_idx_type nnz(void) const
Actual number of nonzero terms.
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
ComplexNDArray complex_array_value(bool=false) const
create a structure array and initialize its values The dimensions of each cell array of values must match Singleton cells and non cell values are repeated so that they fill the entire array If the cells are empty
nd deftypefn *std::string name
void swap_bytes< 4 >(void *ptr)
static int static_type_id(void)
type_conv_info numeric_conversion_function(void) const
NDArray array_value(bool=false) const
octave_idx_type rows(void) const
octave_idx_type * ridx(void)
octave_idx_type * xridx(void)
void warn_save(const char *type) const
friend class octave_value
Complex complex_value(bool=false) const
boolMatrix bool_matrix_value(bool=false) const
octave_idx_type cols(void) const
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
void err_invalid_conversion(const std::string &from, const std::string &to)
bool indices_ok(void) const
static octave_base_value * default_numeric_conversion_function(const octave_base_value &a)
octave_idx_type numel(void) const
octave_idx_type nzmax(void) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
void warn_implicit_conversion(const char *id, const char *from, const char *to)
octave_value convert_to_str_internal(bool pad, bool force, char type) const
Matrix matrix_value(bool=false) const
SparseMatrix sparse_matrix_value(bool=false) const
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Sparse< T > maybe_compress(bool remove_zeros=false)
const octave_hdf5_id octave_H5P_DEFAULT
octave_idx_type columns(void) const
octave_base_value * try_narrowing_conversion(void)
octave_idx_type ndims(void) const
Number of dimensions.
std::complex< double > Complex
size_t byte_size(void) const
octave_idx_type * xcidx(void)
write the output to stdout if nargout is
Vector representing the dimensions (size) of an Array.
octave_idx_type rows(void) const