24 #if defined (HAVE_CONFIG_H) 62 return rep->find (field) !=
rep->end ();
68 fields_rep::iterator
p =
rep->find (field);
69 return (
p !=
rep->end ()) ?
p->second : -1;
75 fields_rep::iterator
p =
rep->find (field);
82 return (*
rep)[field] = n;
89 fields_rep::iterator
p =
rep->find (field);
97 for (
auto& fld_idx : *
rep)
99 if (fld_idx.second >= n)
115 for (
auto& fld_idx : *
rep)
131 for (;
p !=
end () && q != other.
end ();
p++, q++)
133 if (
p->first == q->first)
134 perm[
p->second] = q->second;
152 if (perm.
numel () != n)
164 for (
auto& fld_idx : *
this)
165 retval.xelem (fld_idx.second) = fld_idx.first;
171 (
const std::map<std::string, octave_value>& m)
173 size_t sz = m.size ();
176 for (
const auto& k_v : m)
178 xkeys.getfield (k_v.first);
179 xvals[
i++] = k_v.second;
194 if (idx < static_cast<octave_idx_type> (
xvals.size ()))
219 retval.xkeys.orderfields (perm);
238 error (
"orderfields: structs must have same fields up to order");
258 if (idx >= static_cast<octave_idx_type> (
xvals.size ()))
259 xvals.resize (idx+1);
264 : xkeys (m.xkeys), xvals (), dimensions (1, 1)
279 return (idx >= 0) ?
xvals[idx] :
Cell ();
289 error (
"octave_map::setfield: internal error");
292 if (idx < static_cast<octave_idx_type> (
xvals.size ()))
317 retval.xkeys.orderfields (perm);
336 error (
"orderfields: structs must have same fields up to order");
356 if (idx >= static_cast<octave_idx_type> (
xvals.size ()))
453 retval.optimize_dimensions ();
483 dummy = dummy.
permute (vec, inv);
487 retval.optimize_dimensions ();
502 assert (
ndims () == 2);
512 retval.optimize_dimensions ();
534 retval.dimensions.chop_trailing_singletons ();
539 retval.xvals.reserve (nf);
551 retval.optimize_dimensions ();
608 retval.xvals.reserve (nf);
629 retval.xvals.reserve (nf);
636 field_list[
i] = map_list[
i].
xvals[j];
663 template <
typename map>
669 new_map_list[idx] = map_list[idx];
681 new_map_list[
i], perm);
684 catch (octave::execution_exception&
e)
686 error (
e,
"cat: field names mismatch in concatenating structs");
696 if (dim == -1 || dim == -2)
699 error (
"cat: invalid dimension");
706 for (idx = 0; idx < n; idx++)
719 bool all_same =
true;
748 retval.optimize_dimensions ();
760 if (dim == -1 || dim == -2)
763 error (
"cat: invalid dimension");
771 for (idx = 0; idx < n; idx++)
782 bool all_same =
true;
795 if (all_same && nf > 0)
815 error (
"dimension mismatch in struct concatenation");
822 retval.optimize_dimensions ();
863 dummy = dummy.
index (
i, resize_ok);
867 retval.optimize_dimensions ();
874 bool resize_ok)
const 888 dummy = dummy.
index (
i, j, resize_ok);
892 retval.optimize_dimensions ();
912 dummy = dummy.
index (ia, resize_ok);
916 retval.optimize_dimensions ();
960 for (
k = 0;
k < n_idx;
k++)
961 ia(
k) = idx(
k).index_vector ();
971 e.set_pos_if_unset (n_idx,
k+1);
1010 dummy.assign (
i, rhs_dummy);;
1019 tmp.assign (
i, rhs);
1031 catch (octave::execution_exception&
e)
1033 error (
e,
"incompatible fields in struct assignment");
1058 dummy.assign (
i, j, rhs_dummy);;
1067 tmp.assign (
i, j, rhs);
1079 catch (octave::execution_exception&
e)
1081 error (
e,
"incompatible fields in struct assignment");
1106 dummy.assign (ia, rhs_dummy);;
1115 tmp.assign (ia, rhs);
1127 catch (octave::execution_exception&
e)
1129 error (
e,
"incompatible fields in struct assignment");
1175 for (
k = 0;
k < n_idx;
k++)
1176 ia(
k) = idx(
k).index_vector ();
1186 e.set_pos_if_unset (n_idx,
k+1);
1300 ia(
i) = idx(
i).index_vector ();
1305 e.set_pos_if_unset (n_idx,
i+1);
1329 if (pb == rb.
end ())
1330 error (
"field name mismatch in structure concatenation");
1342 error (
"invalid structure concatenation");
1356 error (
"internal error: dimension mismatch across fields in struct");
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
octave_map squeeze(void) const
scalar structure containing the fields
static octave_map cat(int dim, octave_idx_type n, const octave_scalar_map *map_list)
void delete_elements(const idx_vector &i)
const_iterator begin(void) const
const octave_base_value const Array< octave_idx_type > & ra_idx
string_vector keys(void) const
void assign(const std::string &k, const Cell &val)
static const idx_vector colon
identity matrix If supplied two scalar respectively For allows like xample val
void delete_elements(const idx_vector &i)
Deleting elements.
bool isfield(const std::string &name) const
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)
Array< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
void resize(int n, int fill_value=0)
const T * fortran_vec(void) const
void assign(const octave_value_list &idx, const Cell &rhs, const octave_value &fill_val=Matrix())
void error(const char *fmt,...)
octave_idx_type nfields(void) const
std::string key(const_iterator p) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
void setfield(const std::string &key, const octave_value &val)
const_iterator end(void) const
std::vector< Cell > xvals
octave_idx_type rmfield(const std::string &name)
void permute_to_correct_order1(const octave_scalar_map &ref, const octave_scalar_map &src, octave_scalar_map &dest, Array< octave_idx_type > &perm)
void orderfields(Array< octave_idx_type > &perm)
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
bool concat(const dim_vector &dvb, int dim)
This corresponds to cat().
octave_scalar_map orderfields(void) const
octave_map permute(const Array< int > &vec, bool inv=false) const
octave_idx_type index(const_iterator p) const
Cell getfield(const std::string &key) const
std::vector< octave_value > xvals
Array< T > index(const idx_vector &i) const
Indexing without resizing.
octave_idx_type numel(const octave_value_list &idx)
string_vector fieldnames(void) const
octave_map reshape(const dim_vector &dv) const
dim_vector dims(void) const
void rmfield(const std::string &key)
octave_scalar_map fast_elem_extract(octave_idx_type n) const
bool fast_elem_insert(octave_idx_type n, const octave_scalar_map &rhs)
void resize(const dim_vector &dv, const T &rfv)
Resizing (with fill).
octave_scalar_map elem(octave_idx_type n) const
void rmfield(const std::string &key)
bool equal_up_to_order(const octave_fields &other, octave_idx_type *perm) const
const Cell & contents(const_iterator p) const
Cell & insert(const Cell &a, octave_idx_type r, octave_idx_type c)
octave_value getfield(const std::string &key) const
bool all_zero(void) const
void setfield(const std::string &key, const Cell &val)
T & xelem(octave_idx_type n)
void extract_scalar(octave_scalar_map &dest, octave_idx_type index) const
octave_idx_type nfields(void) const
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
const octave_value & contents(const_iterator p) const
bool is_same(const octave_fields &other) const
octave_map transpose(void) const
octave_idx_type length(void) const
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
octave_idx_type getfield(const std::string &name) const
dim_vector squeeze(void) const
octave_idx_type nfields(void) const
octave_map column(octave_idx_type k) const
void resize(const dim_vector &dv, bool fill=false)
void optimize_dimensions(void)
octave_map concat(const octave_map &rb, const Array< octave_idx_type > &ra_idx)
dim_vector dims(void) const
octave_fields::const_iterator const_iterator
octave_idx_type numel(void) const
Number of elements in the array.
octave_map page(octave_idx_type k) const
octave_idx_type nfields(void) const
Vector representing the dimensions (size) of an Array.
const_iterator begin(void) const
const_iterator seek(const std::string &k) const
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
octave_map orderfields(void) const
static void do_cat(int dim, octave_idx_type n, const octave_scalar_map *map_list, octave_map &retval)
const_iterator end(void) const
static fields_rep * nil_rep(void)