26 #if defined (HAVE_CONFIG_H)
50 (*
rep)[fields(i)] = i;
58 (*rep)[std::string (*fields++)] =
n++;
64 return rep->find (field) !=
rep->end ();
70 auto p =
rep->find (field);
71 return (p !=
rep->end ()) ? p->second : -1;
77 auto p =
rep->find (field);
84 return (*
rep)[field] =
n;
91 auto p =
rep->find (field);
99 for (
auto& fld_idx : *
rep)
101 if (fld_idx.second >=
n)
117 for (
auto& fld_idx : *
rep)
132 auto q = other.
begin ();
133 for (; p !=
end () && q != other.
end (); p++, q++)
135 if (p->first == q->first)
136 perm[p->second] = q->second;
163 for (
auto& fld_idx : *
this)
170 (
const std::map<std::string, octave_value>&
m)
172 size_t sz =
m.size ();
175 for (
const auto& k_v :
m)
178 xvals[i++] = k_v.second;
196 xvals.push_back (val);
218 retval.xkeys.orderfields (perm);
237 error (
"orderfields: structs must have same fields up to order");
258 xvals.resize (idx+1);
263 : xkeys (
m.xkeys), xvals (), dimensions (1, 1)
270 xvals[i].xelem (0) =
m.xvals[i];
278 return (idx >= 0) ?
xvals[idx] :
Cell ();
288 error (
"octave_map::setfield: internal error");
294 xvals.push_back (val);
316 retval.xkeys.orderfields (perm);
335 error (
"orderfields: structs must have same fields up to order");
482 dummy = dummy.
permute (vec, inv);
501 assert (
ndims () == 2);
538 retval.xvals.reserve (nf);
586 xvals[i].resize (dv);
607 retval.xvals.reserve (nf);
628 retval.xvals.reserve (nf);
635 field_list[i] = map_list[i].
xvals[j];
662 template <
typename map>
668 new_map_list[idx] = map_list[idx];
680 new_map_list[i], perm);
683 catch (octave::execution_exception& e)
685 error (e,
"cat: field names mismatch in concatenating structs");
695 if (dim == -1 || dim == -2)
698 error (
"cat: invalid dimension");
705 for (idx = 0; idx <
n; idx++)
718 bool all_same =
true;
759 if (dim == -1 || dim == -2)
762 error (
"cat: invalid dimension");
770 for (idx = 0; idx <
n; idx++)
781 bool all_same =
true;
794 if (all_same && nf > 0)
814 error (
"dimension mismatch in struct concatenation");
862 dummy = dummy.
index (i, resize_ok);
873 bool resize_ok)
const
879 retval.xvals[k] =
xvals[k].index (i, j, resize_ok);
887 dummy = dummy.
index (i, j, resize_ok);
911 dummy = dummy.
index (ia, resize_ok);
959 for (k = 0; k < n_idx; k++)
960 ia(k) = idx(k).index_vector ();
1009 dummy.assign (i, rhs_dummy);;
1030 catch (octave::execution_exception& e)
1032 error (e,
"incompatible fields in struct assignment");
1057 dummy.assign (i, j, rhs_dummy);;
1078 catch (octave::execution_exception& e)
1080 error (e,
"incompatible fields in struct assignment");
1105 dummy.assign (ia, rhs_dummy);;
1126 catch (octave::execution_exception& e)
1128 error (e,
"incompatible fields in struct assignment");
1174 for (k = 0; k < n_idx; k++)
1175 ia(k) = idx(k).index_vector ();
1210 if (&
xvals[i] != &ref)
1299 ia(i) = idx(i).index_vector ();
1324 for (
auto pa =
cbegin (); pa !=
cend (); pa++)
1328 if (pb == rb.
cend ())
1329 error (
"field name mismatch in structure concatenation");
1341 error (
"invalid structure concatenation");
1355 error (
"internal error: dimension mismatch across fields in struct");
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
Array< T > index(const idx_vector &i) const
Indexing without resizing.
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.
const T * fortran_vec(void) const
Size of the specified dimension.
Array< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Size of the specified dimension.
bool optimize_dimensions(const dim_vector &dv)
Returns true if this->dims () == dv, and if so, replaces this->dimensions by a shallow copy of dv.
void delete_elements(const idx_vector &i)
Deleting elements.
Cell & insert(const Cell &a, octave_idx_type r, octave_idx_type c)
void assign(const octave_value_list &idx, const Cell &rhs, const octave_value &fill_val=Matrix())
Vector representing the dimensions (size) of an Array.
bool concat(const dim_vector &dvb, int dim)
This corresponds to cat().
void resize(int n, int fill_value=0)
bool all_zero(void) const
void chop_trailing_singletons(void)
dim_vector squeeze(void) const
static const idx_vector colon
void set_pos_if_unset(octave_idx_type nd_arg, octave_idx_type dim_arg)
void orderfields(Array< octave_idx_type > &perm)
const_iterator begin(void) const
octave_idx_type rmfield(const std::string &name)
static fields_rep * nil_rep(void)
string_vector fieldnames(void) const
octave_idx_type nfields(void) const
bool equal_up_to_order(const octave_fields &other, octave_idx_type *perm) const
bool is_same(const octave_fields &other) const
bool isfield(const std::string &name) const
const_iterator end(void) const
octave_idx_type getfield(const std::string &name) const
void resize(const dim_vector &dv, bool fill=false)
Cell getfield(const std::string &key) const
static void do_cat(int dim, octave_idx_type n, const octave_scalar_map *map_list, octave_map &retval)
void rmfield(const std::string &key)
octave_scalar_map fast_elem_extract(octave_idx_type n) const
void delete_elements(const idx_vector &i)
octave_map reshape(const dim_vector &dv) const
octave_idx_type nfields(void) const
void optimize_dimensions(void)
const_iterator cend(void) const
octave_map permute(const Array< int > &vec, bool inv=false) const
octave_map transpose(void) const
void setfield(const std::string &key, const Cell &val)
octave_map page(octave_idx_type k) const
const_iterator seek(const std::string &k) const
octave_map concat(const octave_map &rb, const Array< octave_idx_type > &ra_idx)
void assign(const std::string &k, const Cell &val)
void extract_scalar(octave_scalar_map &dest, octave_idx_type index) const
std::string key(const_iterator p) const
octave_map orderfields(void) const
const_iterator end(void) const
string_vector keys(void) const
const_iterator cbegin(void) const
const Cell & contents(const_iterator p) const
dim_vector dims(void) const
bool fast_elem_insert(octave_idx_type n, const octave_scalar_map &rhs)
std::vector< Cell > xvals
static octave_map cat(int dim, octave_idx_type n, const octave_scalar_map *map_list)
octave_scalar_map elem(octave_idx_type n) const
octave_idx_type index(const_iterator p) const
octave_map column(octave_idx_type k) const
octave_map squeeze(void) const
octave_scalar_map orderfields(void) const
const octave_value & contents(const_iterator p) const
octave_idx_type nfields(void) const
std::vector< octave_value > xvals
void setfield(const std::string &key, const octave_value &val)
void rmfield(const std::string &key)
octave_value getfield(const std::string &key) const
octave_idx_type length(void) const
octave_idx_type numel(void) const
void error(const char *fmt,...)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
void permute_to_correct_order1(const octave_scalar_map &ref, const octave_scalar_map &src, octave_scalar_map &dest, Array< octave_idx_type > &perm)
static void permute_to_correct_order(octave_idx_type n, octave_idx_type nf, octave_idx_type idx, const map *map_list, map *new_map_list)
const octave_base_value const Array< octave_idx_type > & ra_idx
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval