24 #if defined (HAVE_CONFIG_H) 56 "sparse complex matrix",
"double");
83 else if (nr == 0 || nc == 0)
109 if (! force_conversion)
111 "complex sparse matrix",
"real scalar");
119 "complex sparse matrix",
"real scalar");
129 if (! force_conversion)
131 "complex sparse matrix",
"real matrix");
147 "complex sparse matrix",
"real scalar");
171 "sparse complex matrix",
"string");
192 if (! force_conversion)
194 "complex sparse matrix",
195 "real sparse matrix");
208 ||
real (
matrix).any_element_not_one_or_zero ()))
238 os.
write (reinterpret_cast<char *> (&itmp), 4);
241 os.
write (reinterpret_cast<char *> (&itmp), 4);
244 os.
write (reinterpret_cast<char *> (&itmp), 4);
247 os.
write (reinterpret_cast<char *> (&itmp), 4);
254 warning (
"save: some values too large to save as floats --");
255 warning (
"save: saving as doubles instead");
262 double max_val, min_val;
269 for (
int i = 0;
i < nc+1;
i++)
273 os.
write (reinterpret_cast<char *> (&itmp), 4);
276 for (
int i = 0;
i < nz;
i++)
280 os.
write (reinterpret_cast<char *> (&itmp), 4);
293 int32_t nz, nc, nr,
tmp;
296 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
303 error (
"load: only 2-D sparse matrices are supported");
305 if (!
is.read (reinterpret_cast<char *> (&nr), 4))
307 if (!
is.read (reinterpret_cast<char *> (&nc), 4))
309 if (!
is.read (reinterpret_cast<char *> (&nz), 4))
320 static_cast<octave_idx_type> (nc),
321 static_cast<octave_idx_type> (nz));
323 for (
int i = 0;
i < nc+1;
i++)
326 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
333 for (
int i = 0;
i < nz;
i++)
336 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
343 if (!
is.read (reinterpret_cast<char *> (&ctmp), 1))
347 static_cast<save_type> (ctmp), 2 * nz,
swap, fmt);
366 #if defined (HAVE_HDF5) 376 #if defined (HAVE_HDF5_18) 380 hid_t group_hid = H5Gcreate (loc_id,
name, 0);
385 hid_t space_hid, data_hid;
386 space_hid = data_hid = -1;
391 space_hid = H5Screate_simple (0, hdims,
nullptr);
394 H5Gclose (group_hid);
398 #if defined (HAVE_HDF5_18) 407 H5Sclose (space_hid);
408 H5Gclose (group_hid);
418 H5Sclose (space_hid);
419 H5Gclose (group_hid);
423 #if defined (HAVE_HDF5_18) 432 H5Sclose (space_hid);
433 H5Gclose (group_hid);
443 H5Sclose (space_hid);
444 H5Gclose (group_hid);
448 #if defined (HAVE_HDF5_18) 457 H5Sclose (space_hid);
458 H5Gclose (group_hid);
468 H5Sclose (space_hid);
469 H5Gclose (group_hid);
473 H5Sclose (space_hid);
475 hdims[0] = m.
cols () + 1;
478 space_hid = H5Screate_simple (2, hdims,
nullptr);
482 H5Gclose (group_hid);
486 #if defined (HAVE_HDF5_18) 487 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
490 data_hid = H5Dcreate (group_hid,
"cidx",
H5T_NATIVE_IDX, space_hid,
495 H5Sclose (space_hid);
496 H5Gclose (group_hid);
506 H5Sclose (space_hid);
507 H5Gclose (group_hid);
511 H5Sclose (space_hid);
516 space_hid = H5Screate_simple (2, hdims,
nullptr);
520 H5Gclose (group_hid);
524 #if defined (HAVE_HDF5_18) 525 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
528 data_hid = H5Dcreate (group_hid,
"ridx",
H5T_NATIVE_IDX, space_hid,
533 H5Sclose (space_hid);
534 H5Gclose (group_hid);
544 H5Sclose (space_hid);
545 H5Gclose (group_hid);
549 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
555 warning (
"save: some values too large to save as floats --");
556 warning (
"save: saving as doubles instead");
559 save_type_hid = H5T_NATIVE_FLOAT;
561 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS) 565 double max_val, min_val;
576 H5Sclose (space_hid);
577 H5Gclose (group_hid);
580 #if defined (HAVE_HDF5_18) 581 data_hid = H5Dcreate (group_hid,
"data", type_hid, space_hid,
584 data_hid = H5Dcreate (group_hid,
"data", type_hid, space_hid,
589 H5Sclose (space_hid);
591 H5Gclose (group_hid);
597 if (complex_type_hid >= 0)
606 H5Sclose (space_hid);
608 H5Gclose (group_hid);
611 octave_unused_parameter (loc_id);
612 octave_unused_parameter (
name);
627 #if defined (HAVE_HDF5) 630 hid_t group_hid, data_hid, space_hid;
640 #if defined (HAVE_HDF5_18) 643 group_hid = H5Gopen (loc_id,
name);
645 if (group_hid < 0)
return false;
647 #if defined (HAVE_HDF5_18) 650 data_hid = H5Dopen (group_hid,
"nr");
652 space_hid = H5Dget_space (data_hid);
653 rank = H5Sget_simple_extent_ndims (space_hid);
658 H5Gclose (group_hid);
666 H5Gclose (group_hid);
672 #if defined (HAVE_HDF5_18) 675 data_hid = H5Dopen (group_hid,
"nc");
677 space_hid = H5Dget_space (data_hid);
678 rank = H5Sget_simple_extent_ndims (space_hid);
683 H5Gclose (group_hid);
691 H5Gclose (group_hid);
697 #if defined (HAVE_HDF5_18) 700 data_hid = H5Dopen (group_hid,
"nz");
702 space_hid = H5Dget_space (data_hid);
703 rank = H5Sget_simple_extent_ndims (space_hid);
708 H5Gclose (group_hid);
716 H5Gclose (group_hid);
723 static_cast<octave_idx_type> (nc),
724 static_cast<octave_idx_type> (nz));
726 #if defined (HAVE_HDF5_18) 729 data_hid = H5Dopen (group_hid,
"cidx");
731 space_hid = H5Dget_space (data_hid);
732 rank = H5Sget_simple_extent_ndims (space_hid);
736 H5Sclose (space_hid);
738 H5Gclose (group_hid);
745 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
747 if (static_cast<int> (hdims[0]) != nc + 1
748 || static_cast<int> (hdims[1]) != 1)
750 H5Sclose (space_hid);
752 H5Gclose (group_hid);
760 H5Sclose (space_hid);
762 H5Gclose (group_hid);
766 H5Sclose (space_hid);
769 #if defined (HAVE_HDF5_18) 772 data_hid = H5Dopen (group_hid,
"ridx");
774 space_hid = H5Dget_space (data_hid);
775 rank = H5Sget_simple_extent_ndims (space_hid);
779 H5Sclose (space_hid);
781 H5Gclose (group_hid);
785 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
787 if (static_cast<int> (hdims[0]) != nz
788 || static_cast<int> (hdims[1]) != 1)
790 H5Sclose (space_hid);
792 H5Gclose (group_hid);
800 H5Sclose (space_hid);
802 H5Gclose (group_hid);
806 H5Sclose (space_hid);
809 #if defined (HAVE_HDF5_18) 812 data_hid = H5Dopen (group_hid,
"data");
814 hid_t type_hid = H5Dget_type (data_hid);
820 H5Tclose (complex_type);
822 H5Gclose (group_hid);
826 space_hid = H5Dget_space (data_hid);
827 rank = H5Sget_simple_extent_ndims (space_hid);
831 H5Sclose (space_hid);
833 H5Gclose (group_hid);
837 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
839 if (static_cast<int> (hdims[0]) != nz
840 || static_cast<int> (hdims[1]) != 1)
842 H5Sclose (space_hid);
844 H5Gclose (group_hid);
858 H5Tclose (complex_type);
859 H5Sclose (space_hid);
861 H5Gclose (group_hid);
864 octave_unused_parameter (loc_id);
865 octave_unused_parameter (
name);
879 double *pr =
static_cast<double *
> (
retval->get_data ());
880 double *
pi =
static_cast<double *
> (
retval->get_imag_data ());
909 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \ 910 case umap_ ## UMAP: \ 911 return octave_value (matrix.FCN ()) 915 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \ 916 case umap_ ## UMAP: \ 917 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)
charNDArray char_array_value(bool frc_str_conv=false) const
void resize(octave_idx_type r, octave_idx_type c)
bool all_elements_are_real(void) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
SparseComplexMatrix matrix
octave_base_value * try_narrowing_conversion(void)
Matrix matrix_value(bool=false) const
octave_idx_type nnz(void) const
std::complex< double > erfi(std::complex< double > z, double relerr=0)
void warn_logical_conversion(void)
identity matrix If supplied two scalar respectively For allows like xample val
const octave_hdf5_id octave_H5S_ALL
save_type get_save_type(double, double)
dim_vector dims(void) const
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
octave_idx_type * cidx(void)
double double_value(bool=false) const
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 error(const char *fmt,...)
std::complex< T > floor(const std::complex< T > &x)
ComplexNDArray complex_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)
mxArray * as_mxArray(void) const
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
ComplexMatrix matrix_value(void) const
Complex acos(const Complex &x)
Complex atan(const Complex &x)
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
bool any_element_is_nan(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)
void warn_load(const char *type) const
octave_idx_type nnz(void) const
Actual number of nonzero terms.
Complex expm1(const Complex &x)
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
ComplexColumnVector conj(const ComplexColumnVector &a)
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)
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
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)
bool hdf5_types_compatible(octave_hdf5_id t1, octave_hdf5_id t2)
octave_idx_type rows(void) const
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)
octave_value map(unary_mapper_t umap) const
void warn_save(const char *type) const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
Complex erf(const Complex &x)
Complex complex_value(bool=false) const
void warning(const char *fmt,...)
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)
octave_value map(octave_base_value::unary_mapper_t umap) const
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
bool indices_ok(void) const
bool all_integers(double &max_val, double &min_val) const
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)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Sparse< T > maybe_compress(bool remove_zeros=false)
ColumnVector imag(const ComplexColumnVector &a)
octave_idx_type columns(void) const
const octave_hdf5_id octave_H5P_DEFAULT
SparseMatrix sparse_matrix_value(bool=false) const
octave_idx_type ndims(void) const
Number of dimensions.
octave_value as_double(void) const
std::complex< double > Complex
size_t byte_size(void) const
octave_idx_type * xcidx(void)
ColumnVector real(const ComplexColumnVector &a)
write the output to stdout if nargout is
Vector representing the dimensions (size) of an Array.
octave_hdf5_id hdf5_make_complex_type(octave_hdf5_id num_type)
ComplexMatrix complex_matrix_value(bool=false) const
bool save_binary(std::ostream &os, bool &save_as_floats)
octave_idx_type rows(void) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
bool too_large_for_float(void) const
std::complex< double > erfc(std::complex< double > z, double relerr=0)