26 #if defined (HAVE_CONFIG_H)
71 "complex matrix",
"double");
112 if (! force_conversion)
114 "complex matrix",
"real scalar");
120 "complex matrix",
"real scalar");
128 if (! force_conversion)
130 "complex matrix",
"real scalar");
136 "complex matrix",
"real scalar");
146 if (! force_conversion)
148 "complex matrix",
"real matrix");
160 if (! force_conversion)
162 "complex matrix",
"real matrix");
174 if (! force_conversion)
176 "complex matrix",
"real matrix");
190 "complex matrix",
"complex scalar");
206 "complex matrix",
"complex scalar");
244 "complex matrix",
"string");
268 if (! force_conversion)
270 "complex matrix",
"real matrix");
313 error (
"diag: expecting vector argument");
328 os <<
"# ndims: " << dv.
ndims () <<
"\n";
330 for (
int i = 0; i < dv.
ndims (); i++)
339 os <<
"# rows: " <<
rows () <<
"\n"
340 <<
"# columns: " <<
columns () <<
"\n";
353 keywords[0] =
"ndims";
354 keywords[1] =
"rows";
360 error (
"load: failed to extract number of rows and columns");
365 char *prev_locale = std::setlocale (LC_ALL,
nullptr);
366 std::string old_locale (prev_locale ? prev_locale :
"");
367 std::setlocale (LC_ALL,
"C");
368 octave::unwind_action act
369 ([&old_locale] () { std::setlocale (LC_ALL, old_locale.c_str ()); });
373 int mdims =
static_cast<int> (val);
376 error (
"load: failed to extract number of dimensions");
381 for (
int i = 0; i < mdims; i++)
385 error (
"load: failed to read dimensions");
392 error (
"load: failed to load matrix constant");
396 else if (kw ==
"rows")
402 error (
"load: failed to extract number of rows and columns");
404 if (nr > 0 && nc > 0)
409 error (
"load: failed to load matrix constant");
413 else if (nr == 0 || nc == 0)
432 int32_t tmp = - dv.
ndims ();
433 os.write (
reinterpret_cast<char *
> (&tmp), 4);
434 for (
int i = 0; i < dv.
ndims (); i++)
437 os.write (
reinterpret_cast<char *
> (&tmp), 4);
444 if (
m.too_large_for_float ())
446 warning (
"save: some values too large to save as floats --");
447 warning (
"save: saving as doubles instead");
452 else if (dv.
numel () > 4096)
454 double max_val, min_val;
455 if (
m.all_integers (max_val, min_val))
460 write_doubles (os,
reinterpret_cast<const double *
> (mtmp), st,
472 if (! is.read (
reinterpret_cast<char *
> (&mdims), 4))
483 for (
int i = 0; i < mdims; i++)
485 if (! is.read (
reinterpret_cast<char *
> (&di), 4))
504 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
521 if (! is.read (
reinterpret_cast<char *
> (&nc), 4))
525 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
545 #if defined (HAVE_HDF5)
552 int rank = dv.
ndims ();
553 hid_t space_hid, data_hid, type_hid;
554 space_hid = data_hid = type_hid = -1;
561 for (
int i = 0; i < rank; i++)
562 hdims[i] = dv(rank-i-1);
564 space_hid = H5Screate_simple (rank, hdims,
nullptr);
565 if (space_hid < 0)
return false;
567 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
571 if (
m.too_large_for_float ())
573 warning (
"save: some values too large to save as floats --");
574 warning (
"save: saving as doubles instead");
577 save_type_hid = H5T_NATIVE_FLOAT;
579 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
583 double max_val, min_val;
585 if (
m.all_integers (max_val, min_val))
594 H5Sclose (space_hid);
597 #if defined (HAVE_HDF5_18)
598 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
606 H5Sclose (space_hid);
612 if (complex_type_hid < 0) retval =
false;
621 H5Tclose (complex_type_hid);
626 H5Tclose (complex_type_hid);
629 H5Sclose (space_hid);
634 octave_unused_parameter (loc_id);
635 octave_unused_parameter (name);
636 octave_unused_parameter (save_as_floats);
649 #if defined (HAVE_HDF5)
658 #if defined (HAVE_HDF5_18)
661 hid_t data_hid = H5Dopen (loc_id, name);
663 hid_t type_hid = H5Dget_type (data_hid);
669 H5Tclose (complex_type);
674 hid_t space_id = H5Dget_space (data_hid);
676 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
680 H5Tclose (complex_type);
689 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
701 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
715 H5Tclose (complex_type);
720 octave_unused_parameter (loc_id);
721 octave_unused_parameter (name);
731 bool pr_as_read_syntax)
const
743 mwSize nel =
numel ();
750 =
static_cast<mxComplexDouble *
> (retval->
get_data ());
752 for (mwIndex i = 0; i < nel; i++)
754 pd[i].real = pdata[i].real ();
755 pd[i].imag = pdata[i].imag ();
760 mxDouble *pr =
static_cast<mxDouble *
> (retval->
get_data ());
763 for (mwIndex i = 0; i < nel; i++)
765 pr[i] = pdata[i].real ();
766 pi[i] = pdata[i].imag ();
791 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
792 case umap_ ## UMAP: \
793 return octave_value (m_matrix.FCN ())
800 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
801 case umap_ ## UMAP: \
802 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)
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type columns(void) const
OCTARRAY_OVERRIDABLE_FUNC_API const T * data(void) const
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
OCTARRAY_OVERRIDABLE_FUNC_API int ndims(void) const
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API T & elem(octave_idx_type n)
Size of the specified dimension.
OCTAVE_API ComplexMatrix diag(octave_idx_type k=0) const
OCTAVE_API bool any_element_is_nan(void) const
OCTAVE_API 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.
void * get_imag_data(void) const
void * get_data(void) const
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
OCTINTERP_API void warn_load(const char *type) const
octave_idx_type rows(void) const
OCTINTERP_API 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
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(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)
void err_nan_to_logical_conversion(void)
float lo_ieee_float_nan_value(void)
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)
class OCTAVE_API ComplexDiagMatrix
class OCTAVE_API ComplexMatrix
class OCTAVE_API charNDArray
class OCTAVE_API SparseMatrix
class OCTAVE_API FloatComplexMatrix
class OCTAVE_API SparseComplexMatrix
class OCTAVE_API FloatComplexNDArray
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)
static octave_base_value * default_numeric_demotion_function(const octave_base_value &a)
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)