26#if defined (HAVE_CONFIG_H)
50 (*
m_rep)[fields(i)] = i;
58 (*m_rep)[std::string (*fields++)] = n++;
70 auto p =
m_rep->find (field);
71 return (p !=
m_rep->end ()) ? p->second : -1;
77 auto p =
m_rep->find (field);
78 if (p !=
m_rep->end ())
84 return (*
m_rep)[field] = n;
91 auto p =
m_rep->find (field);
92 if (p ==
m_rep->end ())
99 for (
auto& fld_idx : *
m_rep)
101 if (fld_idx.second >= n)
117 for (
auto& fld_idx : *
m_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;
141 retval = (p ==
end () && q == other.
end ());
151 if (perm.
numel () != n)
163 for (
auto& fld_idx : *
this)
164 retval.
xelem (fld_idx.second) = fld_idx.first;
170 (
const std::map<std::string, octave_value>& m)
172 std::size_t sz = m.size ();
175 for (
const auto& k_v : m)
237 error (
"orderfields: structs must have same fields up to order");
263 : m_keys (m.m_keys), m_vals (), m_dimensions (1, 1)
288 error (
"octave_map::setfield: internal error");
335 error (
"orderfields: structs must have same fields up to order");
482 dummy = dummy.
permute (vec, inv);
501 assert (
ndims () == 2);
538 retval.
m_vals.reserve (nf);
607 retval.
m_vals.reserve (nf);
617 assert (retval.
m_vals[j].numel () == n);
628 retval.
m_vals.reserve (nf);
635 field_list[i] = map_list[i].
m_vals[j];
662template <
typename map>
668 new_map_list[idx] = map_list[idx];
680 new_map_list[i], perm);
683 catch (octave::execution_exception& ee)
685 error (ee,
"cat: field names mismatch in concatenating structs");
695 if (dim == -1 || dim == -2)
698 error (
"cat: invalid dimension");
701 retval = map_list[0];
705 for (idx = 0; idx < n; idx++)
718 bool all_same =
true;
727 do_cat (dim, n, map_list, retval);
735 do_cat (dim, n, new_map_list, retval);
759 if (dim == -1 || dim == -2)
762 error (
"cat: invalid dimension");
765 retval = map_list[0];
770 for (idx = 0; idx < n; idx++)
781 bool all_same =
true;
794 if (all_same && nf > 0)
795 do_cat (dim, n, map_list, retval);
805 do_cat (dim, n, new_map_list, retval);
814 error (
"dimension mismatch in struct concatenation");
862 dummy = dummy.
index (i, resize_ok);
873 bool resize_ok)
const
887 dummy = dummy.
index (i, j, resize_ok);
911 dummy = dummy.
index (ia, resize_ok);
940 retval =
index (i, resize_ok);
951 retval =
index (i, j, resize_ok);
959 for (k = 0; k < n_idx; k++)
960 ia(k) = idx(k).index_vector ();
962 retval =
index (ia, resize_ok);
1009 dummy.assign (i, rhs_dummy);;
1030 catch (octave::execution_exception& ee)
1032 error (ee,
"incompatible fields in struct assignment");
1057 dummy.assign (i, j, rhs_dummy);;
1078 catch (octave::execution_exception& ee)
1080 error (ee,
"incompatible fields in struct assignment");
1105 dummy.assign (ia, rhs_dummy);;
1126 catch (octave::execution_exception& ee)
1128 error (ee,
"incompatible fields in struct assignment");
1174 for (k = 0; k < n_idx; k++)
1175 ia(k) = idx(k).index_vector ();
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)
T & xelem(octave_idx_type n)
Size of the specified dimension.
OCTARRAY_API void clear(void)
OCTARRAY_API Array< T, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
octave_idx_type numel(void) const
Number of elements in the array.
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
OCTARRAY_API void delete_elements(const octave::idx_vector &i)
Deleting elements.
OCTARRAY_API Array< T, Alloc > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Size of the specified dimension.
Array< T, Alloc > reshape(octave_idx_type nr, octave_idx_type nc) const
Size of the specified dimension.
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.
OCTAVE_API 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)
OCTAVE_API 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
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
const Cell & contents(const_iterator p) const
octave_map transpose(void) const
void delete_elements(const octave::idx_vector &i)
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
dim_vector dims(void) const
bool fast_elem_insert(octave_idx_type n, const octave_scalar_map &rhs)
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
std::vector< Cell > m_vals
octave_idx_type index(const_iterator p) const
octave_map column(octave_idx_type k) const
octave_map squeeze(void) const
const octave_value & contents(const_iterator p) const
octave_scalar_map orderfields(void) const
octave_idx_type nfields(void) const
void setfield(const std::string &key, const octave_value &val)
void rmfield(const std::string &key)
std::vector< octave_value > m_vals
octave_value getfield(const std::string &key) const
octave_idx_type length(void) const
std::string & xelem(octave_idx_type i)
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()) ? '\'' :'"'))