26 #if defined (HAVE_CONFIG_H)
70 "complex matrix",
"double");
111 if (! force_conversion)
113 "complex matrix",
"real scalar");
119 "complex matrix",
"real scalar");
127 if (! force_conversion)
129 "complex matrix",
"real scalar");
135 "complex matrix",
"real scalar");
145 if (! force_conversion)
147 "complex matrix",
"real matrix");
159 if (! force_conversion)
161 "complex matrix",
"real matrix");
173 if (! force_conversion)
175 "complex matrix",
"real matrix");
189 "complex matrix",
"complex scalar");
205 "complex matrix",
"complex scalar");
230 ||
real (
matrix).any_element_not_one_or_zero ()))
243 "complex matrix",
"string");
267 if (! force_conversion)
269 "complex matrix",
"real matrix");
312 error (
"diag: expecting vector argument");
327 os <<
"# ndims: " << dv.
ndims () <<
"\n";
329 for (
int i = 0; i < dv.
ndims (); i++)
338 os <<
"# rows: " <<
rows () <<
"\n"
339 <<
"# columns: " <<
columns () <<
"\n";
352 keywords[0] =
"ndims";
353 keywords[1] =
"rows";
359 error (
"load: failed to extract number of rows and columns");
363 int mdims =
static_cast<int> (val);
366 error (
"load: failed to extract number of dimensions");
371 for (
int i = 0; i < mdims; i++)
375 error (
"load: failed to read dimensions");
382 error (
"load: failed to load matrix constant");
386 else if (kw ==
"rows")
392 error (
"load: failed to extract number of rows and columns");
394 if (nr > 0 && nc > 0)
399 error (
"load: failed to load matrix constant");
403 else if (nr == 0 || nc == 0)
422 int32_t tmp = - dv.
ndims ();
423 os.write (
reinterpret_cast<char *
> (&tmp), 4);
424 for (
int i = 0; i < dv.
ndims (); i++)
427 os.write (
reinterpret_cast<char *
> (&tmp), 4);
434 if (
m.too_large_for_float ())
436 warning (
"save: some values too large to save as floats --");
437 warning (
"save: saving as doubles instead");
442 else if (dv.
numel () > 4096)
444 double max_val, min_val;
445 if (
m.all_integers (max_val, min_val))
450 write_doubles (os,
reinterpret_cast<const double *
> (mtmp), st,
462 if (! is.read (
reinterpret_cast<char *
> (&mdims), 4))
473 for (
int i = 0; i < mdims; i++)
475 if (! is.read (
reinterpret_cast<char *
> (&di), 4))
494 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
511 if (! is.read (
reinterpret_cast<char *
> (&nc), 4))
515 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
535 #if defined (HAVE_HDF5)
542 int rank = dv.
ndims ();
543 hid_t space_hid, data_hid, type_hid;
544 space_hid = data_hid = type_hid = -1;
551 for (
int i = 0; i < rank; i++)
552 hdims[i] = dv(rank-i-1);
554 space_hid = H5Screate_simple (rank, hdims,
nullptr);
555 if (space_hid < 0)
return false;
557 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
561 if (
m.too_large_for_float ())
563 warning (
"save: some values too large to save as floats --");
564 warning (
"save: saving as doubles instead");
567 save_type_hid = H5T_NATIVE_FLOAT;
569 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
573 double max_val, min_val;
575 if (
m.all_integers (max_val, min_val))
584 H5Sclose (space_hid);
587 #if defined (HAVE_HDF5_18)
588 data_hid = H5Dcreate (loc_id,
name, type_hid, space_hid,
595 H5Sclose (space_hid);
601 if (complex_type_hid < 0)
retval =
false;
610 H5Tclose (complex_type_hid);
615 H5Tclose (complex_type_hid);
618 H5Sclose (space_hid);
623 octave_unused_parameter (loc_id);
624 octave_unused_parameter (
name);
625 octave_unused_parameter (save_as_floats);
638 #if defined (HAVE_HDF5)
647 #if defined (HAVE_HDF5_18)
650 hid_t data_hid = H5Dopen (loc_id,
name);
652 hid_t type_hid = H5Dget_type (data_hid);
658 H5Tclose (complex_type);
663 hid_t space_id = H5Dget_space (data_hid);
665 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
669 H5Tclose (complex_type);
678 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
690 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
704 H5Tclose (complex_type);
709 octave_unused_parameter (loc_id);
710 octave_unused_parameter (
name);
720 bool pr_as_read_syntax)
const
731 double *pr =
static_cast<double *
> (
retval->get_data ());
732 double *
pi =
static_cast<double *
> (
retval->get_imag_data ());
738 for (
mwIndex i = 0; i < nel; i++)
765 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
766 case umap_ ## UMAP: \
767 return octave_value (matrix.FCN ())
774 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
775 case umap_ ## UMAP: \
776 return octave_value (matrix.map<TYPE> (FCN))
ComplexColumnVector conj(const ComplexColumnVector &a)
boolMatrix mx_el_ne(const boolMatrix &m1, const boolMatrix &m2)
void swap_bytes< 4 >(void *ptr)
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type columns(void) const
octave_idx_type numel(void) const
Number of elements in the array.
T & elem(octave_idx_type n)
Size of the specified dimension.
const T * data(void) const
Size of the specified dimension.
octave_idx_type rows(void) const
int ndims(void) const
Size of the specified dimension.
ComplexMatrix diag(octave_idx_type k=0) const
bool any_element_is_nan(void) const
bool all_elements_are_real(void) const
Vector representing the dimensions (size) of an Array.
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
void resize(int n, int fill_value=0)
octave_idx_type ndims(void) const
Number of dimensions.
octave_idx_type numel(void) const
octave_value diag(octave_idx_type k=0) const
dim_vector dims(void) const
octave_idx_type columns(void) const
int current_print_indent_level(void) const
virtual octave_value map(unary_mapper_t) const
void warn_load(const char *type) const
octave_idx_type rows(void) const
void warn_save(const char *type) const
NDArray array_value(bool=false) const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
float float_value(bool=false) const
octave_value as_double(void) const
charNDArray char_array_value(bool frc_str_conv=false) const
octave_value as_single(void) const
type_conv_info numeric_demotion_function(void) const
octave_value map(unary_mapper_t umap) const
boolNDArray bool_array_value(bool warn=false) const
octave_base_value * try_narrowing_conversion(void)
Complex complex_value(bool=false) const
FloatComplexMatrix float_complex_matrix_value(bool=false) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
ComplexNDArray complex_array_value(bool=false) const
FloatComplexNDArray float_complex_array_value(bool=false) const
Matrix matrix_value(bool=false) const
SparseMatrix sparse_matrix_value(bool=false) const
ComplexMatrix complex_matrix_value(bool=false) const
double double_value(bool=false) const
FloatComplex float_complex_value(bool=false) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
octave_value diag(octave_idx_type k=0) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
bool load_ascii(std::istream &is)
bool save_binary(std::ostream &os, bool save_as_floats)
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
bool save_ascii(std::ostream &os)
mxArray * as_mxArray(void) const
FloatMatrix float_matrix_value(bool=false) const
static int static_type_id(void)
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
void write_doubles(std::ostream &os, const double *data, save_type type, octave_idx_type len)
void warning(const char *fmt,...)
void error(const char *fmt,...)
#define panic_impossible()
void err_invalid_conversion(const std::string &from, const std::string &to)
void warn_logical_conversion(void)
void warn_implicit_conversion(const char *id, const char *from, const char *to)
float lo_ieee_float_nan_value(void)
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
octave_hdf5_id save_type_to_hdf5(save_type st)
octave_hdf5_id hdf5_make_complex_type(octave_hdf5_id num_type)
bool hdf5_types_compatible(octave_hdf5_id t1, octave_hdf5_id t2)
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
save_type get_save_type(double, double)
std::complex< double > erfc(std::complex< double > z, double relerr=0)
std::complex< double > erfcx(std::complex< double > z, double relerr=0)
std::complex< double > erfi(std::complex< double > z, double relerr=0)
std::complex< double > erf(std::complex< double > z, double relerr=0)
Complex atan(const Complex &x)
Complex log1p(const Complex &x)
Complex acos(const Complex &x)
Complex asin(const Complex &x)
Complex erfc(const Complex &x)
std::complex< T > ceil(const std::complex< T > &x)
Complex log2(const Complex &x)
std::complex< T > floor(const std::complex< T > &x)
Complex erf(const Complex &x)
Complex expm1(const Complex &x)
void err_nan_to_logical_conversion(void)
std::complex< double > Complex
std::complex< float > FloatComplex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
static octave_base_value * default_numeric_demotion_function(const octave_base_value &a)
octave_value::octave_value(const Array< char > &chm, char type) return retval
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)