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");
247 if (octave::math::isnan (std::real (
m_matrix.
elem (i))))
267 if (! force_conversion)
269 "complex matrix",
"real matrix");
312 error (
"diag: expecting vector argument");
316 return mat.
diag (m, n);
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");
364 char *prev_locale = std::setlocale (LC_ALL,
nullptr);
365 std::string old_locale (prev_locale ? prev_locale :
"");
366 std::setlocale (LC_ALL,
"C");
367 octave::unwind_action act
368 ([&old_locale] () { std::setlocale (LC_ALL, old_locale.c_str ()); });
372 int mdims =
static_cast<int> (val);
375 error (
"load: failed to extract number of dimensions");
380 for (
int i = 0; i < mdims; i++)
384 error (
"load: failed to read dimensions");
391 error (
"load: failed to load matrix constant");
395 else if (kw ==
"rows")
401 error (
"load: failed to extract number of rows and columns");
403 if (nr > 0 && nc > 0)
408 error (
"load: failed to load matrix constant");
412 else if (nr == 0 || nc == 0)
415 error (
"unexpected dimensions in octave_complex_matrix::load_ascii - please report this bug");
418 error (
"unexpected dimensions keyword (= '%s') octave_complex_matrix::load_ascii - please report this bug", kw.c_str ());
431 int32_t tmp = - dv.
ndims ();
432 os.write (
reinterpret_cast<char *
> (&tmp), 4);
433 for (
int i = 0; i < dv.
ndims (); i++)
436 os.write (
reinterpret_cast<char *
> (&tmp), 4);
445 warning (
"save: some values too large to save as floats --");
446 warning (
"save: saving as doubles instead");
451 else if (dv.
numel () > 4096)
453 double max_val, min_val;
455 st = octave::get_save_type (max_val, min_val);
459 write_doubles (os,
reinterpret_cast<const double *
> (mtmp), st,
467 octave::mach_info::float_format fmt)
471 if (! is.read (
reinterpret_cast<char *
> (&mdims), 4))
482 for (
int i = 0; i < mdims; i++)
484 if (! is.read (
reinterpret_cast<char *
> (&di), 4))
503 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
520 if (! is.read (
reinterpret_cast<char *
> (&nc), 4))
524 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
544#if defined (HAVE_HDF5)
551 int rank = dv.
ndims ();
552 hid_t space_hid, data_hid, type_hid;
553 space_hid = data_hid = type_hid = -1;
560 for (
int i = 0; i < rank; i++)
561 hdims[i] = dv(rank-i-1);
563 space_hid = H5Screate_simple (rank, hdims,
nullptr);
564 if (space_hid < 0)
return false;
566 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
572 warning (
"save: some values too large to save as floats --");
573 warning (
"save: saving as doubles instead");
576 save_type_hid = H5T_NATIVE_FLOAT;
578#if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
582 double max_val, min_val;
593 H5Sclose (space_hid);
596#if defined (HAVE_HDF5_18)
597 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
605 H5Sclose (space_hid);
611 if (complex_type_hid < 0) retval =
false;
620 H5Tclose (complex_type_hid);
625 H5Tclose (complex_type_hid);
628 H5Sclose (space_hid);
633 octave_unused_parameter (loc_id);
634 octave_unused_parameter (name);
635 octave_unused_parameter (save_as_floats);
648#if defined (HAVE_HDF5)
657#if defined (HAVE_HDF5_18)
660 hid_t data_hid = H5Dopen (loc_id, name);
662 hid_t type_hid = H5Dget_type (data_hid);
668 H5Tclose (complex_type);
673 hid_t space_id = H5Dget_space (data_hid);
675 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
679 H5Tclose (complex_type);
688 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
700 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
714 H5Tclose (complex_type);
719 octave_unused_parameter (loc_id);
720 octave_unused_parameter (name);
730 bool pr_as_read_syntax)
const
742 mwSize nel =
numel ();
749 =
static_cast<mxComplexDouble *
> (retval->
get_data ());
751 for (mwIndex i = 0; i < nel; i++)
753 pd[i].real = pdata[i].real ();
754 pd[i].imag = pdata[i].imag ();
759 mxDouble *pr =
static_cast<mxDouble *
> (retval->
get_data ());
760 mxDouble *pi =
static_cast<mxDouble *
> (retval->
get_imag_data ());
762 for (mwIndex i = 0; i < nel; i++)
764 pr[i] = pdata[i].real ();
765 pi[i] = pdata[i].imag ();
790#define ARRAY_METHOD_MAPPER(UMAP, FCN) \
791 case umap_ ## UMAP: \
792 return octave_value (m_matrix.FCN ())
799#define ARRAY_MAPPER(UMAP, TYPE, FCN) \
800 case umap_ ## UMAP: \
801 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)
Complex log2(const Complex &x)
Complex asin(const Complex &x)
Complex acos(const Complex &x)
float lo_ieee_float_nan_value()
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< T > ceil(const std::complex< T > &x)
Complex atan(const Complex &x)
std::complex< T > floor(const std::complex< T > &x)
std::complex< double > Complex
std::complex< float > FloatComplex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Complex erf(const Complex &x)
Complex expm1(const Complex &x)
Complex log1p(const Complex &x)
Complex erfc(const Complex &x)
#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)