24 #if defined (HAVE_CONFIG_H)
69 return matrix.index (idx, resize_ok);
95 matrix.delete_elements (idx);
132 const std::list<octave_value_list>& idx,
134 const std::list<octave_lvalue> *lvalue_list)
150 if (tcell.numel () == 1)
160 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
173 retval = (lvalue_list
182 const std::list<octave_value_list>& idx,
199 if (tcell.numel () == 1)
209 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
229 const std::list<octave_value_list>& idx,
240 if (idx.front ().empty ())
241 error (
"missing index in indexed assignment");
258 return tmp.
subsasgn (type, idx, rhs);
267 std::list<octave_value_list> next_idx (idx);
269 next_idx.erase (next_idx.begin ());
273 t_rhs = tmp.
subsasgn (type.substr (1), next_idx, rhs);
283 std::list<octave_value_list> next_idx (idx);
285 next_idx.erase (next_idx.begin ());
289 if (tmpc.
numel () != 1)
304 t_rhs = tmp.
subsasgn (next_type, next_idx, rhs);
313 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
355 if (! idxf(
k).is_magic_colon ()) didx(
k) = idxf(
k).numel ();
357 if (didx.numel () == tmp_cell.
numel ())
358 tmp_cell = tmp_cell.
reshape (didx);
380 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
390 return tmp.
subsasgn (type, idx, rhs);
456 error (
"sort: only cell arrays of character strings may be sorted");
460 tmp = tmp.
sort (dim, mode);
475 error (
"sort: only cell arrays of character strings may be sorted");
479 tmp = tmp.
sort (sidx, dim, mode);
493 error (
"issorted: A is not a cell array of strings");
508 error (
"sortrows: only cell arrays of character strings may be sorted");
523 error (
"issorted: A is not a cell array of strings");
535 error (
"invalid conversion from cell array to logical value");
555 std::queue<string_vector> strvec_queue;
563 n_elts += s_len ? s_len : 1;
567 if (s_max_len > max_len)
570 strvec_queue.push (s);
591 if (pad && max_len > t_len)
612 error (
"invalid conversion from cell array to array of strings");
644 if (nr > 0 && nc > 0)
659 std::ostringstream buf;
660 buf <<
"[" <<
i+1 <<
"," << j+1 <<
"]";
679 os <<
"(" << nr <<
"x" << nc <<
")";
687 os <<
"{" << dv.
str () <<
" Cell Array}";
698 #define CELL_ELT_TAG "<cell-element>"
706 os <<
"# ndims: " << dv.
ndims () <<
"\n";
708 for (
int i = 0;
i < dv.
ndims ();
i++)
729 os <<
"# rows: " <<
rows () <<
"\n"
730 <<
"# columns: " <<
columns () <<
"\n";
761 keywords[0] =
"ndims";
762 keywords[1] =
"rows";
768 error (
"load: failed to extract number of rows and columns");
772 int mdims =
static_cast<int> (
val);
775 error (
"load: failed to extract number of rows and columns");
780 for (
int i = 0;
i < mdims;
i++)
795 error (
"load: cell array element had unexpected name");
802 error (
"load: failed to load matrix constant");
806 else if (kw ==
"rows")
812 error (
"load: failed to extract number of rows and columns for cell array");
814 if (nr > 0 && nc > 0)
830 error (
"load: cell array element had unexpected name");
833 tmp.
elem (
i, j) = t2;
838 error (
"load: failed to load cell element");
842 else if (nr == 0 || nc == 0)
861 int32_t di = - dv.
ndims ();
862 os.write (reinterpret_cast<char *> (&di), 4);
863 for (
int i = 0;
i < dv.
ndims ();
i++)
866 os.write (reinterpret_cast<char *> (&di), 4);
893 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
905 for (
int i = 0;
i < mdims;
i++)
907 if (! is.read (reinterpret_cast<char *> (&di), 4))
940 error (
"load: cell array element had unexpected name");
947 error (
"load: failed to load matrix constant");
965 #if defined (HAVE_HDF5)
972 hsize_t rank = dv.
ndims ();
973 hid_t space_hid, data_hid, size_hid;
974 space_hid = data_hid = size_hid = -1;
976 #if defined (HAVE_HDF5_18)
980 data_hid = H5Gcreate (loc_id, name, 0);
989 space_hid = H5Screate_simple (1, &rank, 0);
1000 for (hsize_t
i = 0;
i < rank;
i++)
1001 hdims[
i] =
dv(rank-
i-1);
1003 #if defined (HAVE_HDF5_18)
1004 size_hid = H5Dcreate (data_hid,
"dims",
H5T_NATIVE_IDX, space_hid,
1007 size_hid = H5Dcreate (data_hid,
"dims",
H5T_NATIVE_IDX, space_hid,
1012 H5Sclose (space_hid);
1013 H5Gclose (data_hid);
1020 H5Dclose (size_hid);
1021 H5Sclose (space_hid);
1022 H5Gclose (data_hid);
1026 H5Dclose (size_hid);
1027 H5Sclose (space_hid);
1037 std::ostringstream buf;
1038 int digits =
static_cast<int> (
std::floor (::log10 (static_cast<double>
1040 buf <<
"_" << std::setw (digits) << std::setfill (
'0') <<
i;
1046 H5Gclose (data_hid);
1051 H5Gclose (data_hid);
1056 octave_unused_parameter (loc_id);
1057 octave_unused_parameter (name);
1058 octave_unused_parameter (save_as_floats);
1071 #if defined (HAVE_HDF5)
1082 #if defined (HAVE_HDF5_18)
1085 hid_t group_id = H5Gopen (loc_id, name);
1091 #if defined (HAVE_HDF5_18)
1094 hid_t data_hid = H5Dopen (group_id,
"dims");
1096 hid_t space_hid = H5Dget_space (data_hid);
1097 hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
1100 H5Dclose (data_hid);
1101 H5Gclose (group_id);
1108 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
1119 H5Dclose (data_hid);
1120 H5Gclose (group_id);
1124 H5Dclose (data_hid);
1125 H5Gclose (group_id);
1127 for (hsize_t
i = 0, j = hdims[0] - 1;
i < hdims[0];
i++, j--)
1132 herr_t retval2 = -1;
1136 int current_item = 0;
1138 hsize_t num_obj = 0;
1139 #if defined (HAVE_HDF5_18)
1142 group_id = H5Gopen (loc_id, name);
1144 H5Gget_num_objs (group_id, &num_obj);
1145 H5Gclose (group_id);
1150 if (current_item >= static_cast<int> (num_obj))
1170 octave_unused_parameter (loc_id);
1171 octave_unused_parameter (name);
1186 if (
args.length () != 1)
1189 return ovl (
args(0).is_cell ());
1227 ? 0 :
args(
i).xnint_value (
"cell: dimension must be a scalar integer"));
1247 if (
args.length () != 1)
1250 return ovl (
args(0).is_cellstr ());
1271 if (
args.length () != 1)
1280 string_vector s =
args(0).xstring_vector_value (
"cellstr: argument STRING must be a 2-D character array");
1322 if (
args.length () != 1)
1325 const octave_map m =
args(0).xmap_value (
"struct2cell: argument S must be a structure");
1336 if (m_dv(m_dv.
ndims () - 1) == 1)
1341 result_dv(0) = num_fields;
1343 for (
int i = 1;
i < result_dv.
ndims ();
i++)
1344 result_dv(
i) = m_dv(
i-1);
1393 #define FORWARD_MAPPER(UMAP) \
1394 case umap_ ## UMAP: \
1395 return matrix.UMAP ()
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
octave_value map(unary_mapper_t umap) const
const Cell & contents(const_iterator p) const
bool is_true(const std::string &s)
bool is_empty(void) const
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_cell())
std::string str(char sep= 'x') const
bool save_ascii(std::ostream &os)
octave_refcount< octave_idx_type > count
string_vector string_vector_value(bool pad=false) const
void err_nonbraced_cs_list_assignment(void)
bool fast_elem_insert(octave_idx_type n, const octave_value &x)
void increment_indent_level(void) const
octave_idx_type columns(void) const
Cell reshape(const dim_vector &new_dims) const
octave_idx_type max_length(void) const
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Sort by rows returns only indices.
void assign(const octave_value_list &idx, const MT &rhs)
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
identity matrix If supplied two scalar respectively For allows like xample val
const octave_hdf5_id octave_H5S_ALL
static int xtoascii(int c)
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector d)
octave_idx_type length(void) const
void delete_elements(const octave_value_list &idx)
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
void delete_elements(const octave_value_list &idx)
bool is_defined(void) const
void * mex_get_data(void) const
Give a pointer to the data in mex format.
octave_idx_type numel(void) const
void resize(int n, int fill_value=0)
#define DEFUN(name, args_name, nargout_name, doc)
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
void error(const char *fmt,...)
Cell cell_value(void) const
void indent(std::ostream &os) const
void * get_data(void) const
#define FORWARD_MAPPER(UMAP)
mxArray * as_mxArray(void) const
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
octave_value_list list_value(void) const
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
T & elem(octave_idx_type n)
octave_idx_type numel(void) const
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
void newline(std::ostream &os) const
bool is_empty(void) const
octave_idx_type rows(void) const
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Cell cell_value(void) const
void err_indexed_cs_list(void)
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
void print(std::ostream &os, bool pr_as_read_syntax=false)
size_t byte_size(void) const
void warn_load(const char *type) const
size_t byte_size(void) const
Array< std::string > cellstr_value(void) const
create a structure array and initialize its values The dimensions of each cell array of values must match Singleton cells and non cell values are repeated so that they fill the entire array If the cells are empty
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
void swap_bytes< 4 >(void *ptr)
bool is_null_value(void) const
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
bool save_text_data(std::ostream &os, const octave_value &val_arg, const std::string &name, bool mark_as_global, int precision)
Array< T > sort(int dim=0, sortmode mode=ASCENDING) const
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
octave_idx_type nfields(void) const
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
octave_idx_type numel(const octave_value_list &idx)
std::string type_name(void) const
nd deftypefn *octave_map m
Array< std::string > cellstr_value(void) const
const T * data(void) const
void resize(const dim_vector &dv, const T &rfv)
std::string read_binary_data(std::istream &is, bool swap, octave::mach_info::float_format fmt, const std::string &filename, bool &global, octave_value &tc, std::string &doc)
dim_vector dims(void) const
void clear_cellstr_cache(void) const
octave_hdf5_err hdf5_h5g_iterate(octave_hdf5_id loc_id, const char *name, int *idx, void *operator_data)
#define panic_impossible()
dim_vector redim(int n) const
bool is_cellstr(void) const
octave_idx_type length(void) const
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
void * mex_get_data(void) const
void decrement_indent_level(void) const
void warn_save(const char *type) const
OCTAVE_EXPORT octave_value_list iscellstr
friend class octave_value
OCTINTERP_API octave_value_list Fiscellstr(const octave_value_list &=octave_value_list(), int=0)
OCTINTERP_API void get_dimensions(const octave_value &a, const char *warn_for, dim_vector &dim)
std::unique_ptr< Array< std::string > > cellstr_cache
dim_vector dims(void) const
sortmode is_sorted(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
octave_idx_type length(void) const
Number of elements in the array.
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
This is a simple wrapper template that will subclass an Array type or any later type derived from ...
bool Vprint_empty_dimensions
bool print_as_scalar(void) const
bool save_binary(std::ostream &os, bool &save_as_floats)
bool save_binary_data(std::ostream &os, const octave_value &tc, const std::string &name, const std::string &doc, bool mark_as_global, bool save_as_floats)
=val(i)}if ode{val(i)}occurs in table i
const octave_base_value & get_rep(void) const
bool is_cs_list(void) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
std::string read_text_data(std::istream &is, const std::string &filename, bool &global, octave_value &tc, octave_idx_type count)
void print_with_name(std::ostream &os, const std::string &name) const
octave_idx_type ndims(void) const
Number of dimensions.
Cell index(const octave_value_list &idx, bool resize_ok=false) const
octave_value fast_elem_extract(octave_idx_type n) const
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
virtual octave_value map(unary_mapper_t) const
bool is_cellstr(void) const
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
const octave_hdf5_id octave_H5P_DEFAULT
octave_value_list list_value(void) const
void assign(const octave_value_list &idx, const Cell &rhs)
void short_disp(std::ostream &os) const
bool all_scalars(void) const
octave_idx_type cols(void) const
static const char *const keywords[]
write the output to stdout if nargout is
bool load_ascii(std::istream &is)
Vector representing the dimensions (size) of an Array.
sortmode is_sorted(sortmode mode=UNSORTED) const
bool add_hdf5_data(octave_hdf5_id loc_id, const octave_value &tc, const std::string &name, const std::string &doc, bool mark_as_global, bool save_as_floats)
octave_value storable_value(void) const
void chop_trailing_singletons(void)
OCTINTERP_API void check_dimensions(dim_vector &dim, const char *warnfor)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
bool is_zero_by_zero(void) const
octave_value next_subsref(const std::string &type, const std::list< octave_value_list > &idx, size_t skip=1)
octave_idx_type rows(void) const
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE * x
static octave_value empty_conv(const std::string &type, const octave_value &rhs=octave_value())
static int xisascii(int c)