Mercurial > hg > octave-terminal
changeset 10746:93422177b697
more octave_map compatibility
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 24 Jun 2010 08:02:26 +0200 |
parents | 9f4eac2fa26c |
children | 58c1b5402588 |
files | src/oct-map.cc src/oct-map.h |
diffstat | 2 files changed, 154 insertions(+), 144 deletions(-) [+] |
line wrap: on
line diff
--- a/src/oct-map.cc +++ b/src/oct-map.cc @@ -150,26 +150,26 @@ octave_value octave_scalar_map::getfield (const std::string& k) const { - octave_idx_type idx = keys.getfield (k); - return (idx >= 0) ? vals[idx] : octave_value (); + octave_idx_type idx = xkeys.getfield (k); + return (idx >= 0) ? xvals[idx] : octave_value (); } void octave_scalar_map::setfield (const std::string& k, const octave_value& val) { - octave_idx_type idx = keys.getfield (k); - if (idx < static_cast<octave_idx_type> (vals.size ())) - vals[idx] = val; + octave_idx_type idx = xkeys.getfield (k); + if (idx < static_cast<octave_idx_type> (xvals.size ())) + xvals[idx] = val; else - vals.push_back (val); + xvals.push_back (val); } void octave_scalar_map::rmfield (const std::string& k) { - octave_idx_type idx = keys.rmfield (k); + octave_idx_type idx = xkeys.rmfield (k); if (idx >= 0) - vals.erase (vals.begin () + idx); + xvals.erase (xvals.begin () + idx); } octave_scalar_map @@ -182,12 +182,12 @@ octave_scalar_map octave_scalar_map::orderfields (Array<octave_idx_type>& perm) const { - octave_scalar_map retval (keys); - retval.keys.orderfields (perm); + octave_scalar_map retval (xkeys); + retval.xkeys.orderfields (perm); octave_idx_type nf = nfields (); for (octave_idx_type i = 0; i < nf; i++) - retval.vals[i] = vals[perm.xelem(i)]; + retval.xvals[i] = xvals[perm.xelem(i)]; return retval; } @@ -196,16 +196,16 @@ octave_scalar_map::orderfields (const octave_scalar_map& other, Array<octave_idx_type>& perm) const { - if (keys.is_same (other.keys)) + if (xkeys.is_same (other.xkeys)) return *this; else { - octave_scalar_map retval (other.keys); - if (other.keys.equal_up_to_order (keys, perm)) + octave_scalar_map retval (other.xkeys); + if (other.xkeys.equal_up_to_order (xkeys, perm)) { octave_idx_type nf = nfields (); for (octave_idx_type i = 0; i < nf; i++) - retval.vals[i] = vals[perm.xelem(i)]; + retval.xvals[i] = xvals[perm.xelem(i)]; } else error ("orderfields: structs must have same fields up to order"); @@ -223,26 +223,26 @@ octave_value& octave_scalar_map::contents (const std::string& k) { - octave_idx_type idx = keys.getfield (k); - if (idx >= static_cast<octave_idx_type> (vals.size ())) - vals.resize (idx); - return vals[idx]; + octave_idx_type idx = xkeys.getfield (k); + if (idx >= static_cast<octave_idx_type> (xvals.size ())) + xvals.resize (idx); + return xvals[idx]; } octave_map::octave_map (const octave_scalar_map& m) - : keys (m.keys), vals (), dimensions (1, 1) + : xkeys (m.xkeys), xvals (), dimensions (1, 1) { octave_idx_type nf = m.nfields (); - vals.reserve (nf); + xvals.reserve (nf); for (octave_idx_type i = 0; i < nf; i++) { - vals.push_back (Cell (dimensions)); - vals[i].xelem(0) = m.vals[i]; + xvals.push_back (Cell (dimensions)); + xvals[i].xelem(0) = m.xvals[i]; } } octave_map::octave_map (const Octave_map& m) - : keys (m.keys ()), vals (m.nfields ()), dimensions (m.dims ()) + : xkeys (m.keys ()), xvals (m.nfields ()), dimensions (m.dims ()) { for (iterator p = begin (); p != end (); p++) contents(p) = m.contents (key (p)); @@ -253,8 +253,8 @@ Cell octave_map::getfield (const std::string& k) const { - octave_idx_type idx = keys.getfield (k); - return (idx >= 0) ? vals[idx] : Cell (); + octave_idx_type idx = xkeys.getfield (k); + return (idx >= 0) ? xvals[idx] : Cell (); } void @@ -265,11 +265,11 @@ if (val.dims () == dimensions) { - octave_idx_type idx = keys.getfield (k); - if (idx < static_cast<octave_idx_type> (vals.size ())) - vals[idx] = val; + octave_idx_type idx = xkeys.getfield (k); + if (idx < static_cast<octave_idx_type> (xvals.size ())) + xvals[idx] = val; else - vals.push_back (val); + xvals.push_back (val); } else error ("octave_map::setfield: internal error"); @@ -278,9 +278,9 @@ void octave_map::rmfield (const std::string& k) { - octave_idx_type idx = keys.rmfield (k); + octave_idx_type idx = xkeys.rmfield (k); if (idx >= 0) - vals.erase (vals.begin () + idx); + xvals.erase (xvals.begin () + idx); } octave_map @@ -293,12 +293,12 @@ octave_map octave_map::orderfields (Array<octave_idx_type>& perm) const { - octave_map retval (keys); - retval.keys.orderfields (perm); + octave_map retval (xkeys); + retval.xkeys.orderfields (perm); octave_idx_type nf = nfields (); for (octave_idx_type i = 0; i < nf; i++) - retval.vals[i] = vals[perm.xelem(i)]; + retval.xvals[i] = xvals[perm.xelem(i)]; return retval; } @@ -307,16 +307,16 @@ octave_map::orderfields (const octave_map& other, Array<octave_idx_type>& perm) const { - if (keys.is_same (other.keys)) + if (xkeys.is_same (other.xkeys)) return *this; else { - octave_map retval (other.keys); - if (other.keys.equal_up_to_order (keys, perm)) + octave_map retval (other.xkeys); + if (other.xkeys.equal_up_to_order (xkeys, perm)) { octave_idx_type nf = nfields (); for (octave_idx_type i = 0; i < nf; i++) - retval.vals[i] = vals[perm.xelem(i)]; + retval.xvals[i] = xvals[perm.xelem(i)]; } else error ("orderfields: structs must have same fields up to order"); @@ -334,10 +334,10 @@ Cell& octave_map::contents (const std::string& k) { - octave_idx_type idx = keys.getfield (k); - if (idx >= static_cast<octave_idx_type> (vals.size ())) - vals.push_back (Cell (dimensions)); // auto-set correct dims. - return vals[idx]; + octave_idx_type idx = xkeys.getfield (k); + if (idx >= static_cast<octave_idx_type> (xvals.size ())) + xvals.push_back (Cell (dimensions)); // auto-set correct dims. + return xvals[idx]; } void @@ -346,13 +346,13 @@ { octave_idx_type nf = nfields (); for (octave_idx_type i = 0; i < nf; i++) - dest.vals[i] = vals[i](idx); + dest.xvals[i] = xvals[i](idx); } octave_scalar_map octave_map::checkelem (octave_idx_type n) const { - octave_scalar_map retval (keys); + octave_scalar_map retval (xkeys); // Optimize this so that there is just one check. extract_scalar (retval, compute_index (n, dimensions)); @@ -363,7 +363,7 @@ octave_scalar_map octave_map::checkelem (octave_idx_type i, octave_idx_type j) const { - octave_scalar_map retval (keys); + octave_scalar_map retval (xkeys); // Optimize this so that there is just one check. extract_scalar (retval, compute_index (i, j, dimensions)); @@ -374,7 +374,7 @@ octave_scalar_map octave_map::checkelem (const Array<octave_idx_type>& ra_idx) const { - octave_scalar_map retval (keys); + octave_scalar_map retval (xkeys); // Optimize this so that there is just one check. extract_scalar (retval, compute_index (ra_idx, dimensions)); @@ -391,7 +391,7 @@ retval.dimensions = dimensions.squeeze (); for (octave_idx_type i = 0; i < nf; i++) - retval.vals[i] = vals[i].squeeze (); + retval.xvals[i] = xvals[i].squeeze (); retval.optimize_dimensions (); @@ -399,7 +399,7 @@ } /* -%!# test preservation of keys by squeeze +%!# test preservation of xkeys by squeeze %!test %! x(1,1,1,1).d = 10; x(3,5,1,7).a = "b"; x(2,4,1,7).f = 27; %! assert (fieldnames (squeeze (x)), {"d"; "a"; "f"}); @@ -408,18 +408,18 @@ octave_map octave_map::permute (const Array<int>& vec, bool inv) const { - octave_map retval (keys); + octave_map retval (xkeys); octave_idx_type nf = nfields (); for (octave_idx_type i = 0; i < nf; i++) - retval.vals[i] = vals[i].permute (vec, inv); + retval.xvals[i] = xvals[i].permute (vec, inv); // FIXME: // There is no dim_vector::permute for technical reasons. // We pick the dim vector from results if possible, otherwise use a dummy // array to get it. Need (?) a better solution to this problem. if (nf > 0) - retval.dimensions = retval.vals[0].dims (); + retval.dimensions = retval.xvals[0].dims (); else { Array<char> dummy (dimensions); @@ -444,13 +444,13 @@ { assert (ndims () == 2); - octave_map retval (keys); + octave_map retval (xkeys); retval.dimensions = dim_vector (dimensions (1), dimensions (0)); octave_idx_type nf = nfields (); for (octave_idx_type i = 0; i < nf; i++) - retval.vals[i] = vals[i].transpose (); + retval.xvals[i] = xvals[i].transpose (); retval.optimize_dimensions (); @@ -469,15 +469,15 @@ octave_map octave_map::reshape (const dim_vector& dv) const { - octave_map retval (keys); + octave_map retval (xkeys); retval.dimensions = dv; octave_idx_type nf = nfields (); if (nf > 0) { - retval.vals.reserve (nf); + retval.xvals.reserve (nf); for (octave_idx_type i = 0; i < nf; i++) - retval.vals[i] = vals[i].reshape (dv); + retval.xvals[i] = xvals[i].reshape (dv); } else { @@ -508,9 +508,9 @@ for (octave_idx_type i = 0; i < nf; i++) { if (fill) - vals[i].resize (dv, Cell::resize_fill_value ()); + xvals[i].resize (dv, Cell::resize_fill_value ()); else - vals[i].resize (dv); + xvals[i].resize (dv); } } else @@ -530,7 +530,7 @@ octave_map& retval) { octave_idx_type nf = retval.nfields (); - retval.vals.reserve (nf); + retval.xvals.reserve (nf); dim_vector& rd = retval.dimensions; rd.resize (dim+1, 1); @@ -539,10 +539,10 @@ for (octave_idx_type j = 0; j < nf; j++) { - retval.vals.push_back (Cell (rd)); - assert (retval.vals[j].numel () == n); + retval.xvals.push_back (Cell (rd)); + assert (retval.xvals[j].numel () == n); for (octave_idx_type i = 0; i < n; i++) - retval.vals[j].xelem(i) = map_list[i].vals[j]; + retval.xvals[j].xelem(i) = map_list[i].xvals[j]; } } @@ -551,16 +551,16 @@ octave_map& retval) { octave_idx_type nf = retval.nfields (); - retval.vals.reserve (nf); + retval.xvals.reserve (nf); OCTAVE_LOCAL_BUFFER (Array<octave_value>, field_list, n); for (octave_idx_type j = 0; j < nf; j++) { for (octave_idx_type i = 0; i < n; i++) - field_list[i] = map_list[i].vals[j]; + field_list[i] = map_list[i].xvals[j]; - retval.vals.push_back (Array<octave_value>::cat (dim, n, field_list)); + retval.xvals.push_back (Array<octave_value>::cat (dim, n, field_list)); } } @@ -594,7 +594,7 @@ octave_map retval; if (n > 0) { - retval.keys = map_list[0].keys; + retval.xkeys = map_list[0].xkeys; octave_idx_type nf = map_list[0].nfields (); if (nf > 0) { @@ -602,7 +602,7 @@ bool all_same = true; for (octave_idx_type i = 1; i < n; i++) { - all_same = map_list[0].keys.is_same (map_list[i].keys); + all_same = map_list[0].xkeys.is_same (map_list[i].xkeys); if (! all_same) break; } @@ -640,14 +640,14 @@ octave_map retval; if (n > 0) { - retval.keys = map_list[0].keys; + retval.xkeys = map_list[0].xkeys; octave_idx_type nf = map_list[0].nfields (); // Try the fast case. bool all_same = true; for (octave_idx_type i = 1; i < n; i++) { - all_same = map_list[0].keys.is_same (map_list[i].keys); + all_same = map_list[0].xkeys.is_same (map_list[i].xkeys); if (! all_same) break; } @@ -690,14 +690,14 @@ octave_map octave_map::index (const idx_vector& i, bool resize_ok) const { - octave_map retval (keys); + octave_map retval (xkeys); octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - retval.vals[k] = vals[k].index (i, resize_ok); + retval.xvals[k] = xvals[k].index (i, resize_ok); if (nf > 0) - retval.dimensions = retval.vals[0].dims (); + retval.dimensions = retval.xvals[0].dims (); else { // Use dummy array. FIXME: Need(?) a better solution. @@ -715,14 +715,14 @@ octave_map::index (const idx_vector& i, const idx_vector& j, bool resize_ok) const { - octave_map retval (keys); + octave_map retval (xkeys); octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - retval.vals[k] = vals[k].index (i, j, resize_ok); + retval.xvals[k] = xvals[k].index (i, j, resize_ok); if (nf > 0) - retval.dimensions = retval.vals[0].dims (); + retval.dimensions = retval.xvals[0].dims (); else { // Use dummy array. FIXME: Need(?) a better solution. @@ -739,14 +739,14 @@ octave_map octave_map::index (const Array<idx_vector>& ia, bool resize_ok) const { - octave_map retval (keys); + octave_map retval (xkeys); octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - retval.vals[k] = vals[k].index (ia, resize_ok); + retval.xvals[k] = xvals[k].index (ia, resize_ok); if (nf > 0) - retval.dimensions = retval.vals[0].dims (); + retval.dimensions = retval.xvals[0].dims (); else { // Use dummy array. FIXME: Need(?) a better solution. @@ -814,15 +814,15 @@ void octave_map::assign (const idx_vector& i, const octave_map& rhs) { - if (rhs.keys.is_same (keys)) + if (rhs.xkeys.is_same (xkeys)) { octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - vals[k].assign (i, rhs.vals[k]); + xvals[k].assign (i, rhs.xvals[k]); if (nf > 0) - dimensions = vals[0].dims (); + dimensions = xvals[0].dims (); else { // Use dummy array. FIXME: Need(?) a better solution. @@ -839,7 +839,7 @@ octave_map rhs1 = rhs.orderfields (*this, perm); if (! error_state) { - assert (rhs1.keys.is_same (rhs.keys)); + assert (rhs1.xkeys.is_same (rhs.xkeys)); assign (i, rhs1); } else @@ -851,15 +851,15 @@ octave_map::assign (const idx_vector& i, const idx_vector& j, const octave_map& rhs) { - if (rhs.keys.is_same (keys)) + if (rhs.xkeys.is_same (xkeys)) { octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - vals[k].assign (i, j, rhs.vals[k]); + xvals[k].assign (i, j, rhs.xvals[k]); if (nf > 0) - dimensions = vals[0].dims (); + dimensions = xvals[0].dims (); else { // Use dummy array. FIXME: Need(?) a better solution. @@ -876,7 +876,7 @@ octave_map rhs1 = rhs.orderfields (*this, perm); if (! error_state) { - assert (rhs1.keys.is_same (rhs.keys)); + assert (rhs1.xkeys.is_same (rhs.xkeys)); assign (i, j, rhs1); } else @@ -888,15 +888,15 @@ octave_map::assign (const Array<idx_vector>& ia, const octave_map& rhs) { - if (rhs.keys.is_same (keys)) + if (rhs.xkeys.is_same (xkeys)) { octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - vals[k].assign (ia, rhs.vals[k]); + xvals[k].assign (ia, rhs.xvals[k]); if (nf > 0) - dimensions = vals[0].dims (); + dimensions = xvals[0].dims (); else { // Use dummy array. FIXME: Need(?) a better solution. @@ -913,7 +913,7 @@ octave_map rhs1 = rhs.orderfields (*this, perm); if (! error_state) { - assert (rhs1.keys.is_same (rhs.keys)); + assert (rhs1.xkeys.is_same (rhs.xkeys)); assign (ia, rhs1); } else @@ -974,10 +974,10 @@ { octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - vals[k].delete_elements (i); + xvals[k].delete_elements (i); if (nf > 0) - dimensions = vals[0].dims (); + dimensions = xvals[0].dims (); else { // Use dummy array. FIXME: Need(?) a better solution. @@ -994,10 +994,10 @@ { octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - vals[k].delete_elements (dim, i); + xvals[k].delete_elements (dim, i); if (nf > 0) - dimensions = vals[0].dims (); + dimensions = xvals[0].dims (); else { // Use dummy array. FIXME: Need(?) a better solution. @@ -1014,10 +1014,10 @@ { octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - vals[k].delete_elements (ia); + xvals[k].delete_elements (ia); if (nf > 0) - dimensions = vals[0].dims (); + dimensions = xvals[0].dims (); else { // Use dummy array. FIXME: Need(?) a better solution. @@ -1093,7 +1093,7 @@ for (octave_idx_type i = 0; i < nf; i++) { - if (! vals[i].optimize_dimensions (dimensions)) + if (! xvals[i].optimize_dimensions (dimensions)) { error ("internal error: dimension mismatch across fields in struct"); break;
--- a/src/oct-map.h +++ b/src/oct-map.h @@ -143,22 +143,22 @@ octave_scalar_map { octave_scalar_map (const octave_fields& k) - : keys (k), vals (k.nfields ()) { } + : xkeys (k), xvals (k.nfields ()) { } public: - octave_scalar_map (void) : keys (), vals () { } + octave_scalar_map (void) : xkeys (), xvals () { } octave_scalar_map (const string_vector& k) - : keys (k), vals (k.length ()) { } + : xkeys (k), xvals (k.length ()) { } octave_scalar_map (const octave_scalar_map& m) - : keys (m.keys), vals(m.vals) { } + : xkeys (m.xkeys), xvals(m.xvals) { } octave_scalar_map& operator = (const octave_scalar_map& m) { - keys = m.keys; - vals = m.vals; + xkeys = m.xkeys; + xvals = m.xvals; return *this; } @@ -168,37 +168,43 @@ typedef octave_fields::const_iterator const_iterator; typedef const_iterator iterator; - const_iterator begin (void) const { return keys.begin (); } - const_iterator end (void) const { return keys.end (); } + const_iterator begin (void) const { return xkeys.begin (); } + const_iterator end (void) const { return xkeys.end (); } - const_iterator seek (const std::string& k) const { return keys.seek (k); } + const_iterator seek (const std::string& k) const { return xkeys.seek (k); } std::string key (const_iterator p) const - { return keys.key (p); } + { return xkeys.key (p); } octave_idx_type index (const_iterator p) const - { return keys.index (p); } + { return xkeys.index (p); } const octave_value& contents (const_iterator p) const - { return vals[keys.index (p)]; } + { return xvals[xkeys.index (p)]; } octave_value& contents (iterator p) - { return vals[keys.index (p)]; } + { return xvals[xkeys.index (p)]; } const octave_value& contents (octave_idx_type i) const - { return vals[i]; } + { return xvals[i]; } octave_value& contents (octave_idx_type i) - { return vals[i]; } + { return xvals[i]; } // number of fields. - octave_idx_type nfields (void) const { return keys.nfields (); } + octave_idx_type nfields (void) const { return xkeys.nfields (); } // check whether a field exists. bool isfield (const std::string& name) const - { return keys.isfield (name); } + { return xkeys.isfield (name); } + + bool contains (const std::string& name) const + { return isfield (name); } string_vector fieldnames (void) const - { return keys.fieldnames (); } + { return xkeys.fieldnames (); } + + string_vector keys (void) const + { return fieldnames (); } // get contents of a given field. empty value if not exist. octave_value getfield (const std::string& key) const; @@ -208,6 +214,7 @@ // remove a given field. do nothing if not exist. void rmfield (const std::string& key); + void del (const std::string& k) { rmfield (k); } // return a copy with fields ordered, optionally along with permutation. octave_scalar_map orderfields (void) const; @@ -221,16 +228,16 @@ void clear (void) { - keys.clear (); - vals.clear (); + xkeys.clear (); + xvals.clear (); } friend class octave_map; private: - octave_fields keys; - std::vector<octave_value> vals; + octave_fields xkeys; + std::vector<octave_value> xvals; }; @@ -238,22 +245,22 @@ octave_map { octave_map (const octave_fields& k) - : keys (k), vals (k.nfields ()), dimensions () { } + : xkeys (k), xvals (k.nfields ()), dimensions () { } public: - octave_map (void) : keys (), vals (), dimensions () { } + octave_map (void) : xkeys (), xvals (), dimensions () { } - octave_map (const dim_vector& dv) : keys (), vals (), dimensions (dv) { } + octave_map (const dim_vector& dv) : xkeys (), xvals (), dimensions (dv) { } octave_map (const string_vector& k) - : keys (k), vals (k.length ()), dimensions (1, 1) { } + : xkeys (k), xvals (k.length ()), dimensions (1, 1) { } octave_map (const dim_vector& dv, const string_vector& k) - : keys (k), vals (k.length ()), dimensions (dv) { } + : xkeys (k), xvals (k.length ()), dimensions (dv) { } octave_map (const octave_map& m) - : keys (m.keys), vals (m.vals), dimensions (m.dimensions) { } + : xkeys (m.xkeys), xvals (m.xvals), dimensions (m.dimensions) { } octave_map (const octave_scalar_map& m); @@ -261,8 +268,8 @@ octave_map& operator = (const octave_map& m) { - keys = m.keys; - vals = m.vals; + xkeys = m.xkeys; + xvals = m.xvals; dimensions = m.dimensions; return *this; @@ -273,40 +280,43 @@ typedef octave_fields::const_iterator const_iterator; typedef const_iterator iterator; - const_iterator begin (void) const { return keys.begin (); } - const_iterator end (void) const { return keys.end (); } + const_iterator begin (void) const { return xkeys.begin (); } + const_iterator end (void) const { return xkeys.end (); } - const_iterator seek (const std::string& k) const { return keys.seek (k); } + const_iterator seek (const std::string& k) const { return xkeys.seek (k); } std::string key (const_iterator p) const - { return keys.key (p); } + { return xkeys.key (p); } octave_idx_type index (const_iterator p) const - { return keys.index (p); } + { return xkeys.index (p); } const Cell& contents (const_iterator p) const - { return vals[keys.index (p)]; } + { return xvals[xkeys.index (p)]; } Cell& contents (iterator p) - { return vals[keys.index (p)]; } + { return xvals[xkeys.index (p)]; } const Cell& contents (octave_idx_type i) const - { return vals[i]; } + { return xvals[i]; } Cell& contents (octave_idx_type i) - { return vals[i]; } + { return xvals[i]; } // number of fields. - octave_idx_type nfields (void) const { return keys.nfields (); } + octave_idx_type nfields (void) const { return xkeys.nfields (); } // check whether a field exists. bool isfield (const std::string& name) const - { return keys.isfield (name); } + { return xkeys.isfield (name); } bool contains (const std::string& name) const { return isfield (name); } string_vector fieldnames (void) const - { return keys.fieldnames (); } + { return xkeys.fieldnames (); } + + string_vector keys (void) const + { return fieldnames (); } // get contents of a given field. empty value if not exist. Cell getfield (const std::string& key) const; @@ -331,8 +341,8 @@ void clear (void) { - keys.clear (); - vals.clear (); + xkeys.clear (); + xvals.clear (); } // The Array-like methods. @@ -400,8 +410,8 @@ private: - octave_fields keys; - std::vector<Cell> vals; + octave_fields xkeys; + std::vector<Cell> xvals; dim_vector dimensions; void optimize_dimensions (void);