26 #if defined (HAVE_CONFIG_H)
125 "real matrix",
"real scalar");
137 "real matrix",
"real scalar");
163 "real matrix",
"complex scalar");
179 "real matrix",
"complex scalar");
329 error (
"diag: expecting vector argument");
459 ::warning (
"range error for conversion to character value");
464 chm(i) =
static_cast<char> (ival);
481 os <<
"# ndims: " << dv.
ndims () <<
"\n";
483 for (
int i=0; i < dv.
ndims (); i++)
492 os <<
"# rows: " <<
rows () <<
"\n"
493 <<
"# columns: " <<
columns () <<
"\n";
506 keywords[0] =
"ndims";
507 keywords[1] =
"rows";
513 error (
"load: failed to extract number of rows and columns");
517 int mdims =
static_cast<int> (val);
520 error (
"load: failed to extract number of dimensions");
525 for (
int i = 0; i < mdims; i++)
529 error (
"load: failed to read dimensions");
536 error (
"load: failed to load matrix constant");
540 else if (kw ==
"rows")
546 error (
"load: failed to extract number of rows and columns");
548 if (nr > 0 && nc > 0)
553 error (
"load: failed to load matrix constant");
557 else if (nr == 0 || nc == 0)
577 int32_t tmp = - dv.
ndims ();
578 os.write (
reinterpret_cast<char *
> (&tmp), 4);
579 for (
int i = 0; i < dv.
ndims (); i++)
582 os.write (
reinterpret_cast<char *
> (&tmp), 4);
589 if (
m.too_large_for_float ())
591 warning (
"save: some values too large to save as floats --");
592 warning (
"save: saving as doubles instead");
597 else if (dv.
numel () > 8192)
599 double max_val, min_val;
600 if (
m.all_integers (max_val, min_val))
604 const double *mtmp =
m.data ();
616 if (! is.read (
reinterpret_cast<char *
> (&mdims), 4))
627 for (
int i = 0; i < mdims; i++)
629 if (! is.read (
reinterpret_cast<char *
> (&di), 4))
648 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
652 double *re =
m.fortran_vec ();
665 if (! is.read (
reinterpret_cast<char *
> (&nc), 4))
669 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
672 double *re =
m.fortran_vec ();
690 #if defined (HAVE_HDF5)
697 int rank = dv.
ndims ();
698 hid_t space_hid, data_hid;
699 space_hid = data_hid = -1;
705 for (
int i = 0; i < rank; i++)
706 hdims[i] = dv(rank-i-1);
708 space_hid = H5Screate_simple (rank, hdims,
nullptr);
710 if (space_hid < 0)
return false;
712 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
716 if (
m.too_large_for_float ())
718 warning (
"save: some values too large to save as floats --");
719 warning (
"save: saving as doubles instead");
722 save_type_hid = H5T_NATIVE_FLOAT;
724 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
728 double max_val, min_val;
730 if (
m.all_integers (max_val, min_val))
736 #if defined (HAVE_HDF5_18)
737 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
740 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
745 H5Sclose (space_hid);
749 double *mtmp =
m.fortran_vec ();
754 H5Sclose (space_hid);
757 octave_unused_parameter (loc_id);
758 octave_unused_parameter (
name);
759 octave_unused_parameter (save_as_floats);
772 #if defined (HAVE_HDF5)
781 #if defined (HAVE_HDF5_18)
784 hid_t data_hid = H5Dopen (loc_id,
name);
786 hid_t space_id = H5Dget_space (data_hid);
788 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
800 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
812 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
817 double *re =
m.fortran_vec ();
829 octave_unused_parameter (loc_id);
830 octave_unused_parameter (
name);
840 bool pr_as_read_syntax)
const
851 double *pr =
static_cast<double *
> (
retval->get_data ());
857 for (
mwIndex i = 0; i < nel; i++)
877 if (tmp.imag () == 0.0)
878 rr.
xelem (i) = tmp.real ();
892 rc.
xelem (j) = fcn (a(j));
915 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
916 case umap_ ## UMAP: \
917 return octave_value (matrix.FCN ())
924 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
925 case umap_ ## UMAP: \
926 return octave_value (matrix.map<TYPE> (FCN))
928 #define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
929 case umap_ ## UMAP: \
930 return do_rc_map (matrix, FCN)
991 return str_conv.
map (umap);
void swap_bytes< 4 >(void *ptr)
charNDArray max(char d, const charNDArray &m)
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
sortmode issorted(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
octave_idx_type columns(void) const
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
T & elem(octave_idx_type n)
Size of the specified dimension.
const T * data(void) const
Size of the specified dimension.
octave_idx_type rows(void) const
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
Size of the specified dimension.
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
int ndims(void) const
Size of the specified dimension.
MArray< T > reshape(const dim_vector &new_dims) const
Matrix diag(octave_idx_type k=0) const
bool any_element_is_nan(void) const
bool any_element_not_one_or_zero(void) const
NDArray squeeze(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.
Array< octave_idx_type > as_array(void) const
octave_idx_type extent(octave_idx_type n) const
octave_idx_type numel(void) const
octave_value diag(octave_idx_type k=0) const
sortmode issorted(sortmode mode=UNSORTED) const
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
octave_value squeeze(void) const
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
octave_value reshape(const dim_vector &new_dims) 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
virtual octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
void warn_load(const char *type) const
octave_idx_type rows(void) const
friend class octave_value
void warn_save(const char *type) const
static int static_type_id(void)
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
FloatComplexMatrix float_complex_matrix_value(bool=false) const
boolNDArray bool_array_value(bool warn=false) const
octave_value as_int32(void) const
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
SparseMatrix sparse_matrix_value(bool=false) const
bool load_ascii(std::istream &is)
octave_value as_uint32(void) const
mxArray * as_mxArray(void) const
FloatComplex float_complex_value(bool=false) const
float float_value(bool=false) const
octave_value as_int64(void) const
octave_value as_uint8(void) const
octave_value as_double(void) const
charNDArray char_array_value(bool=false) const
FloatMatrix float_matrix_value(bool=false) const
bool save_binary(std::ostream &os, bool save_as_floats)
bool save_ascii(std::ostream &os)
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
FloatComplexNDArray float_complex_array_value(bool=false) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
type_conv_info numeric_demotion_function(void) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
octave_base_value * try_narrowing_conversion(void)
Complex complex_value(bool=false) const
ComplexNDArray complex_array_value(bool=false) const
octave_value reshape(const dim_vector &new_dims) const
Matrix matrix_value(bool=false) const
octave_value as_int8(void) const
octave_value diag(octave_idx_type k=0) const
octave_value map(unary_mapper_t umap) const
octave_value squeeze(void) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
octave_value as_int16(void) const
sortmode issorted(sortmode mode=UNSORTED) const
ComplexMatrix complex_matrix_value(bool=false) const
FloatNDArray float_array_value(bool=false) const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
octave_value as_uint64(void) const
octave_value as_single(void) const
NDArray array_value(bool=false) const
octave_value as_uint16(void) const
double double_value(bool=false) const
octave_value map(octave_base_value::unary_mapper_t umap) const
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
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)
intNDArray< octave_int16 > int16NDArray
intNDArray< octave_int32 > int32NDArray
intNDArray< octave_int64 > int64NDArray
intNDArray< octave_int8 > int8NDArray
float lo_ieee_float_nan_value(void)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
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)
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)
Complex atan(const Complex &x)
Complex rc_acos(double x)
Complex log1p(const Complex &x)
Complex acos(const Complex &x)
Complex asin(const Complex &x)
Complex rc_log2(double x)
Complex erfc(const Complex &x)
Complex rc_sqrt(double x)
Complex rc_atanh(double x)
std::complex< T > ceil(const std::complex< T > &x)
Complex rc_acosh(double x)
Complex rc_log1p(double x)
Complex rc_log10(double x)
Complex rc_lgamma(double x)
Complex rc_asin(double x)
Complex log2(const Complex &x)
std::complex< T > floor(const std::complex< T > &x)
Complex erf(const Complex &x)
Complex expm1(const Complex &x)
void err_nan_to_logical_conversion(void)
void err_nan_to_character_conversion(void)
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)
static octave_value do_rc_map(const NDArray &a, Complex(&fcn)(double))
#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN)
#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)
octave_value::octave_value(const Array< char > &chm, char type) return retval
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
intNDArray< octave_uint16 > uint16NDArray
intNDArray< octave_uint32 > uint32NDArray
intNDArray< octave_uint64 > uint64NDArray
intNDArray< octave_uint8 > uint8NDArray