56 "sparse bool matrix",
"logical");
109 "bool sparse matrix",
"real scalar");
130 "bool sparse matrix",
"complex scalar");
230 os.write (reinterpret_cast<char *> (&itmp), 4);
233 os.write (reinterpret_cast<char *> (&itmp), 4);
236 os.write (reinterpret_cast<char *> (&itmp), 4);
239 os.write (reinterpret_cast<char *> (&itmp), 4);
243 for (
int i = 0; i < nc+1; i++)
247 os.write (reinterpret_cast<char *> (&itmp), 4);
250 for (
int i = 0; i < nz; i++)
254 os.write (reinterpret_cast<char *> (&itmp), 4);
259 for (
int i = 0; i < nz; i++)
271 int32_t nz, nc, nr, tmp;
272 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
280 error (
"load: only 2-D sparse matrices are supported");
284 if (! is.read (reinterpret_cast<char *> (&nr), 4))
286 if (! is.read (reinterpret_cast<char *> (&nc), 4))
288 if (! is.read (reinterpret_cast<char *> (&nz), 4))
299 static_cast<octave_idx_type> (nc),
300 static_cast<octave_idx_type> (nz));
302 for (
int i = 0; i < nc+1; i++)
305 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
312 for (
int i = 0; i < nz; i++)
315 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
327 if (! is.read (htmp, nz))
330 for (
int i = 0; i < nz; i++)
331 m.
data(i) = (htmp[i] ? 1 : 0);
346 #if defined (HAVE_HDF5)
356 hid_t group_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT,
359 hid_t group_hid = H5Gcreate (loc_id, name, 0);
364 hid_t space_hid, data_hid;
365 space_hid = data_hid = -1;
370 space_hid = H5Screate_simple (0, hdims, 0);
373 H5Gclose (group_hid);
378 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
385 H5Sclose (space_hid);
386 H5Gclose (group_hid);
392 H5S_ALL, H5P_DEFAULT, &tmp) >= 0;
396 H5Sclose (space_hid);
397 H5Gclose (group_hid);
403 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
410 H5Sclose (space_hid);
411 H5Gclose (group_hid);
417 H5P_DEFAULT, &tmp) >= 0;
421 H5Sclose (space_hid);
422 H5Gclose (group_hid);
428 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
435 H5Sclose (space_hid);
436 H5Gclose (group_hid);
442 H5P_DEFAULT, &tmp) >= 0;
446 H5Sclose (space_hid);
447 H5Gclose (group_hid);
451 H5Sclose (space_hid);
453 hdims[0] = m.
cols () + 1;
456 space_hid = H5Screate_simple (2, hdims, 0);
460 H5Gclose (group_hid);
465 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
466 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
468 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
473 H5Sclose (space_hid);
474 H5Gclose (group_hid);
480 H5P_DEFAULT, itmp) >= 0;
484 H5Sclose (space_hid);
485 H5Gclose (group_hid);
489 H5Sclose (space_hid);
494 space_hid = H5Screate_simple (2, hdims, 0);
498 H5Gclose (group_hid);
503 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
504 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
506 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
511 H5Sclose (space_hid);
512 H5Gclose (group_hid);
518 H5P_DEFAULT, itmp) >= 0;
522 H5Sclose (space_hid);
523 H5Gclose (group_hid);
528 data_hid = H5Dcreate (group_hid,
"data", H5T_NATIVE_HBOOL, space_hid,
529 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
531 data_hid = H5Dcreate (group_hid,
"data", H5T_NATIVE_HBOOL, space_hid,
536 H5Sclose (space_hid);
537 H5Gclose (group_hid);
542 for (
int i = 0; i < m.
nnz (); i++)
543 htmp[i] = m.
xdata(i);
545 retval = H5Dwrite (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL,
546 H5P_DEFAULT, htmp) >= 0;
548 H5Sclose (space_hid);
549 H5Gclose (group_hid);
563 #if defined (HAVE_HDF5)
566 hid_t group_hid, data_hid, space_hid;
577 group_hid = H5Gopen (loc_id, name, H5P_DEFAULT);
579 group_hid = H5Gopen (loc_id, name);
581 if (group_hid < 0)
return false;
584 data_hid = H5Dopen (group_hid,
"nr", H5P_DEFAULT);
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);
598 if (H5Dread (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nr)
602 H5Gclose (group_hid);
609 data_hid = H5Dopen (group_hid,
"nc", H5P_DEFAULT);
611 data_hid = H5Dopen (group_hid,
"nc");
613 space_hid = H5Dget_space (data_hid);
614 rank = H5Sget_simple_extent_ndims (space_hid);
619 H5Gclose (group_hid);
623 if (H5Dread (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nc)
627 H5Gclose (group_hid);
634 data_hid = H5Dopen (group_hid,
"nz", H5P_DEFAULT);
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);
648 if (H5Dread (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nz)
652 H5Gclose (group_hid);
659 static_cast<octave_idx_type> (nc),
660 static_cast<octave_idx_type> (nz));
663 data_hid = H5Dopen (group_hid,
"cidx", H5P_DEFAULT);
665 data_hid = H5Dopen (group_hid,
"cidx");
667 space_hid = H5Dget_space (data_hid);
668 rank = H5Sget_simple_extent_ndims (space_hid);
672 H5Sclose (space_hid);
674 H5Gclose (group_hid);
681 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
683 if (static_cast<int> (hdims[0]) != nc + 1
684 || static_cast<int> (hdims[1]) != 1)
686 H5Sclose (space_hid);
688 H5Gclose (group_hid);
693 if (H5Dread (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, itmp)
696 H5Sclose (space_hid);
698 H5Gclose (group_hid);
702 H5Sclose (space_hid);
706 data_hid = H5Dopen (group_hid,
"ridx", H5P_DEFAULT);
708 data_hid = H5Dopen (group_hid,
"ridx");
710 space_hid = H5Dget_space (data_hid);
711 rank = H5Sget_simple_extent_ndims (space_hid);
715 H5Sclose (space_hid);
717 H5Gclose (group_hid);
721 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
723 if (static_cast<int> (hdims[0]) != nz
724 || static_cast<int> (hdims[1]) != 1)
726 H5Sclose (space_hid);
728 H5Gclose (group_hid);
734 H5P_DEFAULT, itmp) < 0)
736 H5Sclose (space_hid);
738 H5Gclose (group_hid);
742 H5Sclose (space_hid);
746 data_hid = H5Dopen (group_hid,
"data", H5P_DEFAULT);
748 data_hid = H5Dopen (group_hid,
"data");
750 space_hid = H5Dget_space (data_hid);
751 rank = H5Sget_simple_extent_ndims (space_hid);
755 H5Sclose (space_hid);
757 H5Gclose (group_hid);
761 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
763 if (static_cast<int> (hdims[0]) != nz
764 || static_cast<int> (hdims[1]) != 1)
766 H5Sclose (space_hid);
768 H5Gclose (group_hid);
774 if (H5Dread (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL,
775 H5P_DEFAULT, htmp) >= 0
780 for (
int i = 0; i < nz; i++)
781 m.
xdata(i) = htmp[i];
786 H5Sclose (space_hid);
788 H5Gclose (group_hid);
803 bool *pr =
static_cast<bool *
> (retval->
get_data ());
807 for (
mwIndex i = 0; i < nz; i++)
bool load_binary(std::istream &is, bool swap, oct_mach_info::float_format fmt)
void gripe_implicit_conversion(const char *id, const char *from, const char *to)
octave_idx_type * xridx(void)
ComplexMatrix complex_matrix_value(bool=false) const
octave_idx_type cols(void) const
boolMatrix matrix_value(void) const
octave_idx_type rows(void) const
octave_idx_type columns(void) const
void gripe_load(const char *type) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
SparseMatrix sparse_matrix_value(bool=false) const
octave_idx_type * xcidx(void)
void error(const char *fmt,...)
void * get_data(void) const
bool save_binary(std::ostream &os, bool &save_as_floats)
SparseBoolMatrix sparse_bool_matrix_value(bool=false) const
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
void gripe_save(const char *type) const
octave_idx_type * cidx(void)
double lo_ieee_nan_value(void)
bool indices_ok(void) const
octave_idx_type nzmax(void) const
Matrix matrix_value(bool=false) const
F77_RET_T const double const double double * d
int load_hdf5_empty(hid_t loc_id, const char *name, dim_vector &d)
octave_idx_type nnz(void) const
boolNDArray bool_array_value(bool=false) const
mwIndex * get_ir(void) const
double double_value(bool=false) const
void swap_bytes< 4 >(void *ptr)
ComplexNDArray complex_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
octave_idx_type numel(void) const
NDArray array_value(bool=false) const
Sparse< T > maybe_compress(bool remove_zeros=false)
void resize(octave_idx_type r, octave_idx_type c)
boolMatrix bool_matrix_value(bool=false) const
size_t byte_size(void) const
mxArray * as_mxArray(void) const
friend class octave_value
type_conv_info numeric_conversion_function(void) const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
charNDArray char_array_value(bool=false) const
octave_idx_type * ridx(void)
void gripe_invalid_conversion(const std::string &from, const std::string &to)
static octave_base_value * default_numeric_conversion_function(const octave_base_value &a)
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
int save_hdf5_empty(hid_t loc_id, const char *name, const dim_vector d)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
mwIndex * get_jc(void) const
octave_base_value * try_narrowing_conversion(void)
std::complex< double > Complex
octave_value convert_to_str_internal(bool pad, bool force, char type) const
Complex complex_value(bool=false) const
dim_vector dims(void) const
octave_idx_type nnz(void) const
octave_idx_type rows(void) const