26#if defined (HAVE_CONFIG_H)
71 "float complex matrix",
"single");
96 if (! force_conversion)
98 "complex matrix",
"real scalar");
104 "complex matrix",
"real scalar");
112 if (! force_conversion)
114 "complex matrix",
"real scalar");
120 "complex matrix",
"real scalar");
130 if (! force_conversion)
132 "complex matrix",
"real matrix");
144 if (! force_conversion)
146 "complex matrix",
"real matrix");
160 "complex matrix",
"complex scalar");
176 "complex matrix",
"complex scalar");
199 octave::err_nan_to_logical_conversion ();
214 "complex matrix",
"string");
238 if (! force_conversion)
240 "complex matrix",
"real matrix");
283 error (
"diag: expecting vector argument");
287 return mat.
diag (m, n);
299 os <<
"# ndims: " << dv.
ndims () <<
"\n";
301 for (
int i = 0; i < dv.
ndims (); i++)
310 os <<
"# rows: " <<
rows () <<
"\n"
311 <<
"# columns: " <<
columns () <<
"\n";
324 keywords[0] =
"ndims";
325 keywords[1] =
"rows";
331 error (
"load: failed to extract number of rows and columns");
336 char *prev_locale = std::setlocale (LC_ALL,
nullptr);
337 std::string old_locale (prev_locale ? prev_locale :
"");
338 std::setlocale (LC_ALL,
"C");
339 octave::unwind_action act
340 ([&old_locale] () { std::setlocale (LC_ALL, old_locale.c_str ()); });
344 int mdims =
static_cast<int> (val);
347 error (
"load: failed to extract number of dimensions");
352 for (
int i = 0; i < mdims; i++)
356 error (
"load: failed to read dimensions");
363 error (
"load: failed to load matrix constant");
367 else if (kw ==
"rows")
373 error (
"load: failed to extract number of rows and columns");
375 if (nr > 0 && nc > 0)
380 error (
"load: failed to load matrix constant");
384 else if (nr == 0 || nc == 0)
387 error (
"unexpected dimensions in octave_float_complex_matrix::load_ascii - please report this bug");
390 error (
"unexpected dimensions keyword (= '%s') octave_float_complex_matrix::load_ascii - please report this bug", kw.c_str ());
403 int32_t tmp = - dv.
ndims ();
404 os.write (
reinterpret_cast<char *
> (&tmp), 4);
405 for (
int i = 0; i < dv.
ndims (); i++)
408 os.write (
reinterpret_cast<char *
> (&tmp), 4);
413 if (dv.
numel () > 4096)
415 float max_val, min_val;
417 st = octave::get_save_type (max_val, min_val);
421 write_floats (os,
reinterpret_cast<const float *
> (mtmp), st,
429 octave::mach_info::float_format fmt)
433 if (! is.read (
reinterpret_cast<char *
> (&mdims), 4))
444 for (
int i = 0; i < mdims; i++)
446 if (! is.read (
reinterpret_cast<char *
> (&di), 4))
465 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
482 if (! is.read (
reinterpret_cast<char *
> (&nc), 4))
486 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
508#if defined (HAVE_HDF5)
515 int rank = dv.
ndims ();
516 hid_t space_hid, data_hid, type_hid;
517 space_hid = data_hid = type_hid = -1;
523 for (
int i = 0; i < rank; i++)
524 hdims[i] = dv(rank-i-1);
526 space_hid = H5Screate_simple (rank, hdims,
nullptr);
527 if (space_hid < 0)
return false;
529 hid_t save_type_hid = H5T_NATIVE_FLOAT;
531#if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
535 float max_val, min_val;
546 H5Sclose (space_hid);
549#if defined (HAVE_HDF5_18)
550 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
558 H5Sclose (space_hid);
564 if (complex_type_hid < 0) retval =
false;
573 H5Tclose (complex_type_hid);
578 H5Tclose (complex_type_hid);
581 H5Sclose (space_hid);
584 octave_unused_parameter (loc_id);
585 octave_unused_parameter (name);
598#if defined (HAVE_HDF5)
607#if defined (HAVE_HDF5_18)
610 hid_t data_hid = H5Dopen (loc_id, name);
612 hid_t type_hid = H5Dget_type (data_hid);
618 H5Tclose (complex_type);
623 hid_t space_id = H5Dget_space (data_hid);
625 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
629 H5Tclose (complex_type);
638 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
650 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
664 H5Tclose (complex_type);
669 octave_unused_parameter (loc_id);
670 octave_unused_parameter (name);
680 bool pr_as_read_syntax)
const
692 mwSize nel =
numel ();
699 =
static_cast<mxComplexSingle *
> (retval->
get_data ());
701 for (mwIndex i = 0; i < nel; i++)
703 pd[i].real = pdata[i].real ();
704 pd[i].imag = pdata[i].imag ();
709 mxSingle *pr =
static_cast<mxSingle *
> (retval->
get_data ());
710 mxSingle *pi =
static_cast<mxSingle *
> (retval->
get_imag_data ());
712 for (mwIndex i = 0; i < nel; i++)
714 pr[i] = pdata[i].real ();
715 pi[i] = pdata[i].imag ();
740#define ARRAY_METHOD_MAPPER(UMAP, FCN) \
741 case umap_ ## UMAP: \
742 return octave_value (m_matrix.FCN ())
749#define ARRAY_MAPPER(UMAP, TYPE, FCN) \
750 case umap_ ## UMAP: \
751 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.
FloatComplexMatrix diag(octave_idx_type k=0) const
bool all_integers(float &max_val, float &min_val) const
bool any_element_is_nan() const
bool all_elements_are_real() 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
FloatComplexNDArray m_matrix
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
mxArray * as_mxArray(bool interleaved) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
ComplexMatrix complex_matrix_value(bool=false) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
SparseMatrix sparse_matrix_value(bool=false) const
FloatComplex float_complex_value(bool=false) const
FloatComplexNDArray float_complex_array_value(bool=false) const
bool save_binary(std::ostream &os, bool save_as_floats)
FloatComplexMatrix float_complex_matrix_value(bool=false) const
octave_value as_single() const
bool save_ascii(std::ostream &os)
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
octave_value diag(octave_idx_type k=0) const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
double double_value(bool=false) const
bool load_ascii(std::istream &is)
ComplexNDArray complex_array_value(bool=false) const
Matrix matrix_value(bool=false) const
boolNDArray bool_array_value(bool warn=false) const
charNDArray char_array_value(bool frc_str_conv=false) const
FloatMatrix float_matrix_value(bool=false) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
octave_value as_double() const
float float_value(bool=false) const
octave_base_value * try_narrowing_conversion()
Complex complex_value(bool=false) const
octave_value map(unary_mapper_t umap) const
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
ColumnVector real(const ComplexColumnVector &a)
void write_floats(std::ostream &os, const float *data, save_type type, octave_idx_type len)
void read_floats(std::istream &is, float *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format 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)