26 #if defined (HAVE_CONFIG_H)
75 "float complex matrix",
"single");
100 if (! force_conversion)
102 "complex matrix",
"real scalar");
108 "complex matrix",
"real scalar");
116 if (! force_conversion)
118 "complex matrix",
"real scalar");
124 "complex matrix",
"real scalar");
134 if (! force_conversion)
136 "complex matrix",
"real matrix");
148 if (! force_conversion)
150 "complex matrix",
"real matrix");
164 "complex matrix",
"complex scalar");
180 "complex matrix",
"complex scalar");
218 "complex matrix",
"string");
242 if (! force_conversion)
244 "complex matrix",
"real matrix");
287 error (
"diag: expecting vector argument");
303 os <<
"# ndims: " << dv.
ndims () <<
"\n";
305 for (
int i = 0; i < dv.
ndims (); i++)
314 os <<
"# rows: " <<
rows () <<
"\n"
315 <<
"# columns: " <<
columns () <<
"\n";
328 keywords[0] =
"ndims";
329 keywords[1] =
"rows";
335 error (
"load: failed to extract number of rows and columns");
340 char *prev_locale = std::setlocale (LC_ALL,
nullptr);
341 std::string old_locale (prev_locale ? prev_locale :
"");
342 std::setlocale (LC_ALL,
"C");
343 octave::unwind_action act
344 ([&old_locale] () { std::setlocale (LC_ALL, old_locale.c_str ()); });
348 int mdims =
static_cast<int> (val);
351 error (
"load: failed to extract number of dimensions");
356 for (
int i = 0; i < mdims; i++)
360 error (
"load: failed to read dimensions");
367 error (
"load: failed to load matrix constant");
371 else if (kw ==
"rows")
377 error (
"load: failed to extract number of rows and columns");
379 if (nr > 0 && nc > 0)
384 error (
"load: failed to load matrix constant");
388 else if (nr == 0 || nc == 0)
407 int32_t tmp = - dv.
ndims ();
408 os.write (
reinterpret_cast<char *
> (&tmp), 4);
409 for (
int i = 0; i < dv.
ndims (); i++)
412 os.write (
reinterpret_cast<char *
> (&tmp), 4);
417 if (dv.
numel () > 4096)
419 float max_val, min_val;
420 if (
m.all_integers (max_val, min_val))
425 write_floats (os,
reinterpret_cast<const float *
> (mtmp), st,
437 if (! is.read (
reinterpret_cast<char *
> (&mdims), 4))
448 for (
int i = 0; i < mdims; i++)
450 if (! is.read (
reinterpret_cast<char *
> (&di), 4))
469 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
486 if (! is.read (
reinterpret_cast<char *
> (&nc), 4))
490 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
512 #if defined (HAVE_HDF5)
519 int rank = dv.
ndims ();
520 hid_t space_hid, data_hid, type_hid;
521 space_hid = data_hid = type_hid = -1;
527 for (
int i = 0; i < rank; i++)
528 hdims[i] = dv(rank-i-1);
530 space_hid = H5Screate_simple (rank, hdims,
nullptr);
531 if (space_hid < 0)
return false;
533 hid_t save_type_hid = H5T_NATIVE_FLOAT;
535 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
539 float max_val, min_val;
541 if (
m.all_integers (max_val, min_val))
550 H5Sclose (space_hid);
553 #if defined (HAVE_HDF5_18)
554 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
562 H5Sclose (space_hid);
568 if (complex_type_hid < 0) retval =
false;
577 H5Tclose (complex_type_hid);
582 H5Tclose (complex_type_hid);
585 H5Sclose (space_hid);
588 octave_unused_parameter (loc_id);
589 octave_unused_parameter (name);
602 #if defined (HAVE_HDF5)
611 #if defined (HAVE_HDF5_18)
614 hid_t data_hid = H5Dopen (loc_id, name);
616 hid_t type_hid = H5Dget_type (data_hid);
622 H5Tclose (complex_type);
627 hid_t space_id = H5Dget_space (data_hid);
629 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
633 H5Tclose (complex_type);
642 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
654 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
668 H5Tclose (complex_type);
673 octave_unused_parameter (loc_id);
674 octave_unused_parameter (name);
684 bool pr_as_read_syntax)
const
705 for (
mwIndex i = 0; i < nel; i++)
707 pd[i].
real = pdata[i].real ();
708 pd[i].
imag = pdata[i].imag ();
716 for (
mwIndex i = 0; i < nel; i++)
718 pr[i] = pdata[i].real ();
719 pi[i] = pdata[i].imag ();
744 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
745 case umap_ ## UMAP: \
746 return octave_value (m_matrix.FCN ())
753 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
754 case umap_ ## UMAP: \
755 return octave_value (m_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)
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.
const T * data() const
Size of the specified dimension.
octave_idx_type columns() const
octave_idx_type numel() const
Number of elements in the array.
FloatComplexMatrix diag(octave_idx_type k=0) 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)
ColumnVector imag(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,...)
#define panic_impossible()
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)
void err_nan_to_logical_conversion()
float lo_ieee_float_nan_value()
Complex log2(const Complex &x)
Complex asin(const Complex &x)
Complex acos(const Complex &x)
Complex atan(const Complex &x)
std::complex< T > floor(const std::complex< T > &x)
std::complex< T > ceil(const std::complex< T > &x)
Complex expm1(const Complex &x)
Complex log1p(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)
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)
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)