24 #if defined (HAVE_CONFIG_H) 103 "real sparse matrix",
"real scalar");
117 "real sparse matrix",
"complex scalar");
225 ::warning (
"range error for conversion to character value");
230 chm(
matrix.
ridx (
i) + j * nr) = static_cast<char> (ival);
262 os.
write (reinterpret_cast<char *> (&itmp), 4);
265 os.
write (reinterpret_cast<char *> (&itmp), 4);
268 os.
write (reinterpret_cast<char *> (&itmp), 4);
271 os.
write (reinterpret_cast<char *> (&itmp), 4);
278 warning (
"save: some values too large to save as floats --");
279 warning (
"save: saving as doubles instead");
286 double max_val, min_val;
293 for (
int i = 0;
i < nc+1;
i++)
297 os.
write (reinterpret_cast<char *> (&itmp), 4);
300 for (
int i = 0;
i < nz;
i++)
304 os.
write (reinterpret_cast<char *> (&itmp), 4);
316 int32_t nz, nc, nr,
tmp;
319 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
326 error (
"load: only 2-D sparse matrices are supported");
328 if (!
is.read (reinterpret_cast<char *> (&nr), 4))
330 if (!
is.read (reinterpret_cast<char *> (&nc), 4))
332 if (!
is.read (reinterpret_cast<char *> (&nz), 4))
343 static_cast<octave_idx_type> (nc),
344 static_cast<octave_idx_type> (nz));
346 for (
int i = 0;
i < nc+1;
i++)
349 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
356 for (
int i = 0;
i < nz;
i++)
359 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
366 if (!
is.read (reinterpret_cast<char *> (&ctmp), 1))
388 #if defined (HAVE_HDF5) 398 #if defined (HAVE_HDF5_18) 402 hid_t group_hid = H5Gcreate (loc_id,
name, 0);
407 hid_t space_hid, data_hid;
408 space_hid = data_hid = -1;
413 space_hid = H5Screate_simple (0, hdims,
nullptr);
416 H5Gclose (group_hid);
419 #if defined (HAVE_HDF5_18) 428 H5Sclose (space_hid);
429 H5Gclose (group_hid);
439 H5Sclose (space_hid);
440 H5Gclose (group_hid);
443 #if defined (HAVE_HDF5_18) 452 H5Sclose (space_hid);
453 H5Gclose (group_hid);
463 H5Sclose (space_hid);
464 H5Gclose (group_hid);
468 #if defined (HAVE_HDF5_18) 477 H5Sclose (space_hid);
478 H5Gclose (group_hid);
488 H5Sclose (space_hid);
489 H5Gclose (group_hid);
493 H5Sclose (space_hid);
495 hdims[0] = m.
cols () + 1;
498 space_hid = H5Screate_simple (2, hdims,
nullptr);
502 H5Gclose (group_hid);
506 #if defined (HAVE_HDF5_18) 507 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
510 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
515 H5Sclose (space_hid);
516 H5Gclose (group_hid);
526 H5Sclose (space_hid);
527 H5Gclose (group_hid);
531 H5Sclose (space_hid);
536 space_hid = H5Screate_simple (2, hdims,
nullptr);
540 H5Gclose (group_hid);
543 #if defined (HAVE_HDF5_18) 544 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
547 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
552 H5Sclose (space_hid);
553 H5Gclose (group_hid);
563 H5Sclose (space_hid);
564 H5Gclose (group_hid);
568 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
574 warning (
"save: some values too large to save as floats --");
575 warning (
"save: saving as doubles instead");
578 save_type_hid = H5T_NATIVE_FLOAT;
580 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS) 584 double max_val, min_val;
592 #if defined (HAVE_HDF5_18) 593 data_hid = H5Dcreate (group_hid,
"data", save_type_hid, space_hid,
596 data_hid = H5Dcreate (group_hid,
"data", save_type_hid, space_hid,
601 H5Sclose (space_hid);
602 H5Gclose (group_hid);
606 double *dtmp = m.
xdata ();
610 H5Sclose (space_hid);
611 H5Gclose (group_hid);
614 octave_unused_parameter (loc_id);
615 octave_unused_parameter (
name);
629 #if defined (HAVE_HDF5) 632 hid_t group_hid, data_hid, space_hid;
642 #if defined (HAVE_HDF5_18) 645 group_hid = H5Gopen (loc_id,
name);
647 if (group_hid < 0)
return false;
649 #if defined (HAVE_HDF5_18) 652 data_hid = H5Dopen (group_hid,
"nr");
654 space_hid = H5Dget_space (data_hid);
655 rank = H5Sget_simple_extent_ndims (space_hid);
660 H5Gclose (group_hid);
668 H5Gclose (group_hid);
674 #if defined (HAVE_HDF5_18) 677 data_hid = H5Dopen (group_hid,
"nc");
679 space_hid = H5Dget_space (data_hid);
680 rank = H5Sget_simple_extent_ndims (space_hid);
685 H5Gclose (group_hid);
693 H5Gclose (group_hid);
699 #if defined (HAVE_HDF5_18) 702 data_hid = H5Dopen (group_hid,
"nz");
704 space_hid = H5Dget_space (data_hid);
705 rank = H5Sget_simple_extent_ndims (space_hid);
710 H5Gclose (group_hid);
718 H5Gclose (group_hid);
725 static_cast<octave_idx_type> (nc),
726 static_cast<octave_idx_type> (nz));
728 #if defined (HAVE_HDF5_18) 731 data_hid = H5Dopen (group_hid,
"cidx");
733 space_hid = H5Dget_space (data_hid);
734 rank = H5Sget_simple_extent_ndims (space_hid);
738 H5Sclose (space_hid);
740 H5Gclose (group_hid);
747 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
749 if (static_cast<int> (hdims[0]) != nc + 1
750 || static_cast<int> (hdims[1]) != 1)
752 H5Sclose (space_hid);
754 H5Gclose (group_hid);
762 H5Sclose (space_hid);
764 H5Gclose (group_hid);
768 H5Sclose (space_hid);
771 #if defined (HAVE_HDF5_18) 774 data_hid = H5Dopen (group_hid,
"ridx");
776 space_hid = H5Dget_space (data_hid);
777 rank = H5Sget_simple_extent_ndims (space_hid);
781 H5Sclose (space_hid);
783 H5Gclose (group_hid);
787 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
789 if (static_cast<int> (hdims[0]) != nz || static_cast<int> (hdims[1]) != 1)
791 H5Sclose (space_hid);
793 H5Gclose (group_hid);
801 H5Sclose (space_hid);
803 H5Gclose (group_hid);
807 H5Sclose (space_hid);
810 #if defined (HAVE_HDF5_18) 813 data_hid = H5Dopen (group_hid,
"data");
815 space_hid = H5Dget_space (data_hid);
816 rank = H5Sget_simple_extent_ndims (space_hid);
820 H5Sclose (space_hid);
822 H5Gclose (group_hid);
826 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
828 if (static_cast<int> (hdims[0]) != nz || static_cast<int> (hdims[1]) != 1)
830 H5Sclose (space_hid);
832 H5Gclose (group_hid);
836 double *dtmp = m.
xdata ();
846 H5Sclose (space_hid);
848 H5Gclose (group_hid);
851 octave_unused_parameter (loc_id);
852 octave_unused_parameter (
name);
867 double *pr =
static_cast<double *
> (
retval->get_data ());
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))
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)
bool any_element_is_nan(void) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
octave_value convert_to_str_internal(bool pad, bool force, char type) const
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
void resize(octave_idx_type r, octave_idx_type c)
Complex rc_log10(double x)
bool too_large_for_float(void) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
ComplexMatrix complex_matrix_value(bool=false) const
octave_value map(unary_mapper_t umap) const
double double_value(bool=false) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
octave_idx_type nnz(void) const
Complex rc_acosh(double x)
Complex rc_sqrt(double x)
std::complex< double > erfi(std::complex< double > z, double relerr=0)
void warn_logical_conversion(void)
const octave_hdf5_id octave_H5S_ALL
save_type get_save_type(double, double)
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
dim_vector dims(void) const
octave_idx_type * cidx(void)
Complex rc_lgamma(double x)
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the base of natural logarithms The constant ex $e satisfies the equation log(e)
std::complex< T > ceil(const std::complex< T > &x)
void err_invalid_index(const std::string &idx, octave_idx_type nd, octave_idx_type dim, const std::string &)
void error(const char *fmt,...)
std::complex< T > floor(const std::complex< T > &x)
charNDArray char_array_value(bool=false) 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)
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
Complex acos(const Complex &x)
Complex atan(const Complex &x)
bool any_element_not_one_or_zero(void) const
Complex asin(const Complex &x)
void err_nan_to_logical_conversion(void)
Complex log2(const Complex &x)
Complex erfc(const Complex &x)
std::complex< double > erf(std::complex< double > z, double relerr=0)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
ComplexNDArray complex_array_value(bool=false) const
Matrix matrix_value(bool=false) const
void warn_load(const char *type) const
Complex rc_atanh(double x)
octave_idx_type nnz(void) const
Actual number of nonzero terms.
idx_vector index_vector(bool require_integers=false) const
bool all_integers(double &max_val, double &min_val) const
Complex complex_value(bool=false) const
octave_idx_type numel(void) const
Complex expm1(const Complex &x)
mxArray * as_mxArray(void) 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
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
void swap_bytes< 4 >(void *ptr)
bool save_binary(std::ostream &os, bool &save_as_floats)
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
Complex log1p(const Complex &x)
octave_idx_type rows(void) const
Complex rc_log2(double x)
octave_hdf5_id save_type_to_hdf5(save_type st)
std::complex< double > erfcx(std::complex< double > z, double relerr=0)
octave_idx_type * ridx(void)
octave_idx_type * xridx(void)
boolMatrix mx_el_ne(const boolMatrix &m1, const boolMatrix &m2)
void warn_save(const char *type) const
Complex erf(const Complex &x)
friend class octave_value
Complex rc_acos(double x)
void warning(const char *fmt,...)
octave_idx_type cols(void) const
charNDArray max(char d, const charNDArray &m)
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)
octave_value map(octave_base_value::unary_mapper_t umap) const
Matrix matrix_value(void) const
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
bool any_element_not_one_or_zero(void) const
bool indices_ok(void) const
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
octave_idx_type numel(void) const
octave_idx_type nzmax(void) const
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Complex rc_asin(double x)
Complex rc_log1p(double x)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Sparse< T > maybe_compress(bool remove_zeros=false)
NDArray array_value(bool=false) const
const octave_hdf5_id octave_H5P_DEFAULT
octave_idx_type columns(void) const
octave_value as_double(void) const
octave_idx_type ndims(void) const
Number of dimensions.
boolNDArray bool_array_value(bool warn=false) const
std::complex< double > Complex
size_t byte_size(void) const
octave_idx_type * xcidx(void)
write the output to stdout if nargout is
void err_nan_to_character_conversion(void)
Vector representing the dimensions (size) of an Array.
std::string type_name(void) const
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
SparseMatrix sparse_matrix_value(bool=false) const
octave_idx_type rows(void) const
octave_base_value * try_narrowing_conversion(void)
bool any_element_is_nan(void) const
std::complex< double > erfc(std::complex< double > z, double relerr=0)