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))
407 #if defined (HAVE_HDF5)
418 hid_t group_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT,
421 hid_t group_hid = H5Gcreate (loc_id, name, 0);
426 hid_t space_hid, data_hid;
427 space_hid = data_hid = -1;
432 space_hid = H5Screate_simple (0, hdims, 0);
435 H5Gclose (group_hid);
440 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
447 H5Sclose (space_hid);
448 H5Gclose (group_hid);
453 retval = H5Dwrite (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
458 H5Sclose (space_hid);
459 H5Gclose (group_hid);
464 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
471 H5Sclose (space_hid);
472 H5Gclose (group_hid);
477 retval = H5Dwrite (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
482 H5Sclose (space_hid);
483 H5Gclose (group_hid);
489 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
496 H5Sclose (space_hid);
497 H5Gclose (group_hid);
502 retval = H5Dwrite (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
507 H5Sclose (space_hid);
508 H5Gclose (group_hid);
512 H5Sclose (space_hid);
514 hdims[0] = m.
cols () + 1;
517 space_hid = H5Screate_simple (2, hdims, 0);
521 H5Gclose (group_hid);
526 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
527 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
529 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
534 H5Sclose (space_hid);
535 H5Gclose (group_hid);
540 retval = H5Dwrite (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
545 H5Sclose (space_hid);
546 H5Gclose (group_hid);
550 H5Sclose (space_hid);
555 space_hid = H5Screate_simple (2, hdims, 0);
559 H5Gclose (group_hid);
563 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
564 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
566 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
571 H5Sclose (space_hid);
572 H5Gclose (group_hid);
577 retval = H5Dwrite (data_hid,
H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
582 H5Sclose (space_hid);
583 H5Gclose (group_hid);
587 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
593 warning (
"save: some values too large to save as floats --");
594 warning (
"save: saving as doubles instead");
597 save_type_hid = H5T_NATIVE_FLOAT;
599 #if HAVE_HDF5_INT2FLOAT_CONVERSIONS
603 double max_val, min_val;
612 data_hid = H5Dcreate (group_hid,
"data", save_type_hid, space_hid,
613 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
615 data_hid = H5Dcreate (group_hid,
"data", save_type_hid, space_hid,
620 H5Sclose (space_hid);
621 H5Gclose (group_hid);
625 double * dtmp = m.
xdata ();
626 retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL,
627 H5P_DEFAULT, dtmp) >= 0;
629 H5Sclose (space_hid);
630 H5Gclose (group_hid);
644 #if defined (HAVE_HDF5)
647 hid_t group_hid, data_hid, space_hid;
658 group_hid = H5Gopen (loc_id, name, H5P_DEFAULT);
660 group_hid = H5Gopen (loc_id, name);
662 if (group_hid < 0)
return false;
665 data_hid = H5Dopen (group_hid,
"nr", H5P_DEFAULT);
667 data_hid = H5Dopen (group_hid,
"nr");
669 space_hid = H5Dget_space (data_hid);
670 rank = H5Sget_simple_extent_ndims (space_hid);
675 H5Gclose (group_hid);
680 H5P_DEFAULT, &nr) < 0)
683 H5Gclose (group_hid);
690 data_hid = H5Dopen (group_hid,
"nc", H5P_DEFAULT);
692 data_hid = H5Dopen (group_hid,
"nc");
694 space_hid = H5Dget_space (data_hid);
695 rank = H5Sget_simple_extent_ndims (space_hid);
700 H5Gclose (group_hid);
705 H5P_DEFAULT, &nc) < 0)
708 H5Gclose (group_hid);
715 data_hid = H5Dopen (group_hid,
"nz", H5P_DEFAULT);
717 data_hid = H5Dopen (group_hid,
"nz");
719 space_hid = H5Dget_space (data_hid);
720 rank = H5Sget_simple_extent_ndims (space_hid);
725 H5Gclose (group_hid);
730 H5P_DEFAULT, &nz) < 0)
733 H5Gclose (group_hid);
740 static_cast<octave_idx_type> (nc),
741 static_cast<octave_idx_type> (nz));
744 data_hid = H5Dopen (group_hid,
"cidx", H5P_DEFAULT);
746 data_hid = H5Dopen (group_hid,
"cidx");
748 space_hid = H5Dget_space (data_hid);
749 rank = H5Sget_simple_extent_ndims (space_hid);
753 H5Sclose (space_hid);
755 H5Gclose (group_hid);
762 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
764 if (static_cast<int> (hdims[0]) != nc + 1
765 || static_cast<int> (hdims[1]) != 1)
767 H5Sclose (space_hid);
769 H5Gclose (group_hid);
775 H5P_DEFAULT, itmp) < 0)
777 H5Sclose (space_hid);
779 H5Gclose (group_hid);
783 H5Sclose (space_hid);
787 data_hid = H5Dopen (group_hid,
"ridx", H5P_DEFAULT);
789 data_hid = H5Dopen (group_hid,
"ridx");
791 space_hid = H5Dget_space (data_hid);
792 rank = H5Sget_simple_extent_ndims (space_hid);
796 H5Sclose (space_hid);
798 H5Gclose (group_hid);
802 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
804 if (static_cast<int> (hdims[0]) != nz || static_cast<int> (hdims[1]) != 1)
806 H5Sclose (space_hid);
808 H5Gclose (group_hid);
814 H5P_DEFAULT, itmp) < 0)
816 H5Sclose (space_hid);
818 H5Gclose (group_hid);
822 H5Sclose (space_hid);
826 data_hid = H5Dopen (group_hid,
"data", H5P_DEFAULT);
828 data_hid = H5Dopen (group_hid,
"data");
830 space_hid = H5Dget_space (data_hid);
831 rank = H5Sget_simple_extent_ndims (space_hid);
835 H5Sclose (space_hid);
837 H5Gclose (group_hid);
841 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
843 if (static_cast<int> (hdims[0]) != nz || static_cast<int> (hdims[1]) != 1)
845 H5Sclose (space_hid);
847 H5Gclose (group_hid);
851 double *dtmp = m.
xdata ();
853 if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL,
854 H5P_DEFAULT, dtmp) >= 0
861 H5Sclose (space_hid);
863 H5Gclose (group_hid);
879 double *pr =
static_cast<double *
> (retval->
get_data ());
883 for (
mwIndex i = 0; i < nz; i++)
889 for (
mwIndex i = 0; i < nc + 1; i++)
908 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
909 case umap_ ## UMAP: \
910 return octave_value (matrix.FCN ())
914 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
915 case umap_ ## UMAP: \
916 return octave_value (matrix.map<TYPE> (FCN))
void gripe_implicit_conversion(const char *id, const char *from, const char *to)
octave_idx_type * xridx(void)
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Complex rc_asin(double x)
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
octave_idx_type cols(void) const
Complex complex_value(bool=false) const
SparseMatrix sparse_matrix_value(bool=false) const
octave_idx_type rows(void) const
octave_idx_type numel(void) const
ComplexNDArray complex_array_value(bool=false) const
octave_idx_type columns(void) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
std::complex< double > erfi(std::complex< double > z, double relerr=0)
void gripe_load(const char *type) const
save_type get_save_type(double, double)
Complex rc_acos(double x)
octave_value convert_to_str_internal(bool pad, bool force, char type) const
octave_idx_type * xcidx(void)
void error(const char *fmt,...)
void * get_data(void) const
void write_doubles(std::ostream &os, const double *data, save_type type, octave_idx_type len)
#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 any_element_is_nan(void) const
bool load_binary(std::istream &is, bool swap, oct_mach_info::float_format fmt)
bool indices_ok(void) const
std::complex< double > erf(std::complex< double > z, double relerr=0)
octave_idx_type nzmax(void) const
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
F77_RET_T const double const double double * d
int load_hdf5_empty(hid_t loc_id, const char *name, dim_vector &d)
octave_value map(unary_mapper_t umap) const
boolNDArray bool_array_value(bool warn=false) const
octave_idx_type nnz(void) const
subroutine xgamma(x, result)
bool any_element_not_one_or_zero(void) const
Complex rc_log1p(double x)
mwIndex * get_ir(void) const
void swap_bytes< 4 >(void *ptr)
Complex rc_lgamma(double x)
bool save_binary(std::ostream &os, bool &save_as_floats)
bool all_integers(double &max_val, double &min_val) const
Matrix matrix_value(void) const
octave_idx_type numel(void) const
Sparse< T > maybe_compress(bool remove_zeros=false)
void gripe_nan_to_logical_conversion(void)
void resize(octave_idx_type r, octave_idx_type c)
std::complex< T > ceil(const std::complex< T > &x)
octave_value map(octave_base_value::unary_mapper_t umap) const
Complex rc_sqrt(double x)
mxArray * as_mxArray(void) const
size_t byte_size(void) const
void gripe_nan_to_character_conversion(void)
bool too_large_for_float(void) const
double double_value(bool=false) const
Complex rc_log2(double x)
std::complex< double > erfcx(std::complex< double > z, double relerr=0)
idx_vector index_vector(bool require_integers=false) const
bool any_element_not_one_or_zero(void) const
boolMatrix mx_el_ne(const boolMatrix &m1, const boolMatrix &m2)
Complex rc_atanh(double x)
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, oct_mach_info::float_format fmt)
Complex rc_log10(double x)
friend class octave_value
void warning(const char *fmt,...)
charNDArray max(char d, const charNDArray &m)
octave_idx_type * ridx(void)
void gripe_logical_conversion(void)
Complex rc_acosh(double x)
void gripe_invalid_conversion(const std::string &from, const std::string &to)
Matrix matrix_value(bool=false) const
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
NDArray array_value(bool=false) const
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
bool any_element_is_nan(void) const
Complex asin(const Complex &x)
ComplexMatrix complex_matrix_value(bool=false) const
std::complex< T > floor(const std::complex< T > &x)
std::complex< double > Complex
OCTAVE_EMPTY_CPP_ARG std::string type_name(void) const
Complex acos(const Complex &x)
Complex atan(const Complex &x)
dim_vector dims(void) const
octave_idx_type nnz(void) const
octave_idx_type rows(void) const
octave_base_value * try_narrowing_conversion(void)
charNDArray char_array_value(bool=false) const
bool octave_is_NA(double x)
std::complex< double > erfc(std::complex< double > z, double relerr=0)