26#if defined (HAVE_CONFIG_H)
67 "complex matrix",
"double");
81 (default_numeric_demotion_function,
108 if (! force_conversion)
110 "complex matrix",
"real scalar");
116 "complex matrix",
"real scalar");
124 if (! force_conversion)
126 "complex matrix",
"real scalar");
132 "complex matrix",
"real scalar");
142 if (! force_conversion)
144 "complex matrix",
"real matrix");
156 if (! force_conversion)
158 "complex matrix",
"real matrix");
170 if (! force_conversion)
172 "complex matrix",
"real matrix");
186 "complex matrix",
"complex scalar");
202 "complex matrix",
"complex scalar");
225 octave::err_nan_to_logical_conversion ();
240 "complex matrix",
"string");
264 if (! force_conversion)
266 "complex matrix",
"real matrix");
309 error (
"diag: expecting vector argument");
313 return mat.
diag (m, n);
324 os <<
"# ndims: " << dv.
ndims () <<
"\n";
326 for (
int i = 0; i < dv.
ndims (); i++)
335 os <<
"# rows: " <<
rows () <<
"\n"
336 <<
"# columns: " <<
columns () <<
"\n";
349 keywords[0] =
"ndims";
350 keywords[1] =
"rows";
356 error (
"load: failed to extract number of rows and columns");
361 char *prev_locale = std::setlocale (LC_ALL,
nullptr);
362 std::string old_locale (prev_locale ? prev_locale :
"");
363 std::setlocale (LC_ALL,
"C");
364 octave::unwind_action act
365 ([&old_locale] () { std::setlocale (LC_ALL, old_locale.c_str ()); });
369 int mdims =
static_cast<int> (val);
372 error (
"load: failed to extract number of dimensions");
377 for (
int i = 0; i < mdims; i++)
381 error (
"load: failed to read dimensions");
388 error (
"load: failed to load matrix constant");
392 else if (kw ==
"rows")
398 error (
"load: failed to extract number of rows and columns");
400 if (nr > 0 && nc > 0)
405 error (
"load: failed to load matrix constant");
409 else if (nr == 0 || nc == 0)
412 error (
"unexpected dimensions in octave_complex_matrix::load_ascii - please report this bug");
415 error (
"unexpected dimensions keyword (= '%s') octave_complex_matrix::load_ascii - please report this bug", kw.c_str ());
428 int32_t tmp = - dv.
ndims ();
429 os.write (
reinterpret_cast<char *
> (&tmp), 4);
430 for (
int i = 0; i < dv.
ndims (); i++)
433 os.write (
reinterpret_cast<char *
> (&tmp), 4);
442 warning (
"save: some values too large to save as floats --");
443 warning (
"save: saving as doubles instead");
448 else if (dv.
numel () > 4096)
450 double max_val, min_val;
452 st = octave::get_save_type (max_val, min_val);
456 write_doubles (os,
reinterpret_cast<const double *
> (mtmp), st,
464 octave::mach_info::float_format fmt)
468 if (! is.read (
reinterpret_cast<char *
> (&mdims), 4))
479 for (
int i = 0; i < mdims; i++)
481 if (! is.read (
reinterpret_cast<char *
> (&di), 4))
500 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
517 if (! is.read (
reinterpret_cast<char *
> (&nc), 4))
521 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
541#if defined (HAVE_HDF5)
548 int rank = dv.
ndims ();
549 hid_t space_hid, data_hid, type_hid;
550 space_hid = data_hid = type_hid = -1;
557 for (
int i = 0; i < rank; i++)
558 hdims[i] = dv(rank-i-1);
560 space_hid = H5Screate_simple (rank, hdims,
nullptr);
561 if (space_hid < 0)
return false;
563 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
569 warning (
"save: some values too large to save as floats --");
570 warning (
"save: saving as doubles instead");
573 save_type_hid = H5T_NATIVE_FLOAT;
575#if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
579 double max_val, min_val;
590 H5Sclose (space_hid);
593#if defined (HAVE_HDF5_18)
594 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
602 H5Sclose (space_hid);
608 if (complex_type_hid < 0) retval =
false;
617 H5Tclose (complex_type_hid);
622 H5Tclose (complex_type_hid);
625 H5Sclose (space_hid);
630 octave_unused_parameter (loc_id);
631 octave_unused_parameter (name);
632 octave_unused_parameter (save_as_floats);
645#if defined (HAVE_HDF5)
654#if defined (HAVE_HDF5_18)
657 hid_t data_hid = H5Dopen (loc_id, name);
659 hid_t type_hid = H5Dget_type (data_hid);
665 H5Tclose (complex_type);
670 hid_t space_id = H5Dget_space (data_hid);
672 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
676 H5Tclose (complex_type);
685 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
697 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
711 H5Tclose (complex_type);
716 octave_unused_parameter (loc_id);
717 octave_unused_parameter (name);
727 bool pr_as_read_syntax)
const
739 mwSize nel =
numel ();
746 =
static_cast<mxComplexDouble *
> (retval->
get_data ());
748 for (mwIndex i = 0; i < nel; i++)
750 pd[i].real = pdata[i].real ();
751 pd[i].imag = pdata[i].imag ();
756 mxDouble *pr =
static_cast<mxDouble *
> (retval->
get_data ());
757 mxDouble *pi =
static_cast<mxDouble *
> (retval->
get_imag_data ());
759 for (mwIndex i = 0; i < nel; i++)
761 pr[i] = pdata[i].real ();
762 pi[i] = pdata[i].imag ();
787#define ARRAY_METHOD_MAPPER(UMAP, FCN) \
788 case umap_ ## UMAP: \
789 return octave_value (m_matrix.FCN ())
796#define ARRAY_MAPPER(UMAP, TYPE, FCN) \
797 case umap_ ## UMAP: \
798 return octave_value (m_matrix.map<TYPE> (FCN))
boolMatrix mx_el_ne(const boolMatrix &m1, const boolMatrix &m2)
void swap_bytes< 4 >(void *ptr)
T & elem(octave_idx_type n)
Size of the specified dimension.
int ndims() const
Size of the specified dimension.
octave_idx_type rows() const
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type columns() const
const T * data() const
Size of the specified dimension.
T * rwdata()
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
ComplexMatrix diag(octave_idx_type k=0) const
bool any_element_is_nan() const
bool all_elements_are_real() const
bool all_integers(double &max_val, double &min_val) const
bool too_large_for_float() 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() const
Number of dimensions.
void * get_imag_data() const
octave_value diag(octave_idx_type k=0) const
octave_idx_type numel() const
octave_idx_type rows() const
octave_idx_type columns() const
int current_print_indent_level() const
virtual octave_value map(unary_mapper_t) const
void warn_load(const char *type) const
void warn_save(const char *type) const
NDArray array_value(bool=false) const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
octave_value as_double() const
octave_base_value * try_narrowing_conversion()
float float_value(bool=false) const
octave_value as_single() const
type_conv_info numeric_demotion_function() const
charNDArray char_array_value(bool frc_str_conv=false) const
octave_value map(unary_mapper_t umap) const
boolNDArray bool_array_value(bool warn=false) const
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
mxArray * as_mxArray(bool interleaved) 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)
FloatMatrix float_matrix_value(bool=false) const
static int static_type_id()
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
ColumnVector real(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,...)
void err_invalid_conversion(const std::string &from, const std::string &to)
void warn_logical_conversion()
void warn_implicit_conversion(const char *id, const char *from, const char *to)
float lo_ieee_float_nan_value()
Complex log2(const Complex &x)
Complex asin(const Complex &x)
Complex acos(const Complex &x)
std::complex< T > ceil(const std::complex< T > &x)
Complex atan(const Complex &x)
std::complex< T > floor(const std::complex< T > &x)
Complex erf(const Complex &x)
Complex expm1(const Complex &x)
Complex log1p(const Complex &x)
Complex erfc(const Complex &x)
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)
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)
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
template int8_t abs(int8_t)