Mercurial > hg > octave-terminal
changeset 2423:de430cdd9234
[project @ 1996-10-18 20:39:41 by jwe]
author | jwe |
---|---|
date | Fri, 18 Oct 1996 20:39:42 +0000 |
parents | 327f65b8ea0c |
children | b5c3b08f1bab |
files | src/ChangeLog src/ov-complex.cc src/ov-scalar.cc src/ov.cc src/ov.h |
diffstat | 5 files changed, 92 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ Fri Oct 18 13:44:33 1996 John W. Eaton <jwe@bevo.che.wisc.edu> + * ov.h (octave_value::index): Undo previous change. + * ov.cc (octave_value constructors): Call maybe_mutate() in most + cases. + + * ov-complex.cc (octave_complex::index): Avoid implicit type + conversion back to scalar type. + * ov-scalar.cc (octave_scalar::index): Likewise. + * ov.h (octave_value::index): Call maybe_mutate() on retval before returning it.
--- a/src/ov-complex.cc +++ b/src/ov-complex.cc @@ -33,6 +33,7 @@ #include "oct-obj.h" #include "ops.h" #include "ov-complex.h" +#include "ov-cx-mat.h" #include "ov-scalar.h" #include "gripes.h" #include "pr-output.h" @@ -79,7 +80,11 @@ // // and similar constructions. Hmm... - octave_value tmp (complex_matrix_value ()); + // XXX FIXME XXX -- using this constructor avoids narrowing the + // 1x1 matrix back to a scalar value. Need a better solution + // to this problem. + + octave_value tmp (new octave_complex_matrix (complex_matrix_value ())); retval = tmp.index (idx); }
--- a/src/ov-scalar.cc +++ b/src/ov-scalar.cc @@ -32,6 +32,7 @@ #include "gripes.h" #include "oct-obj.h" #include "ov-scalar.h" +#include "ov-re-mat.h" #include "ov-typeinfo.h" #include "pr-output.h" #include "xdiv.h" @@ -68,7 +69,11 @@ // // and similar constructions. Hmm... - octave_value tmp (matrix_value ()); + // XXX FIXME XXX -- using this constructor avoids narrowing the + // 1x1 matrix back to a scalar value. Need a better solution + // to this problem. + + octave_value tmp (new octave_matrix (matrix_value ())); retval = tmp.index (idx); }
--- a/src/ov.cc +++ b/src/ov.cc @@ -222,40 +222,88 @@ : rep (new octave_scalar (d)) { rep->count = 1; } octave_value::octave_value (const Matrix& m) - : rep (new octave_matrix (m)) { rep->count = 1; } + : rep (new octave_matrix (m)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const DiagMatrix& d) - : rep (new octave_matrix (d)) { rep->count = 1; } + : rep (new octave_matrix (d)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const RowVector& v, int pcv) - : rep (new octave_matrix (v, pcv)) { rep->count = 1; } + : rep (new octave_matrix (v, pcv)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const ColumnVector& v, int pcv) - : rep (new octave_matrix (v, pcv)) { rep->count = 1; } + : rep (new octave_matrix (v, pcv)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const Complex& C) - : rep (new octave_complex (C)) { rep->count = 1; } + : rep (new octave_complex (C)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const ComplexMatrix& m) - : rep (new octave_complex_matrix (m)) { rep->count = 1; } + : rep (new octave_complex_matrix (m)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const ComplexDiagMatrix& d) - : rep (new octave_complex_matrix (d)) { rep->count = 1; } + : rep (new octave_complex_matrix (d)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const ComplexRowVector& v, int pcv) - : rep (new octave_complex_matrix (v, pcv)) { rep->count = 1; } + : rep (new octave_complex_matrix (v, pcv)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const ComplexColumnVector& v, int pcv) - : rep (new octave_complex_matrix (v, pcv)) { rep->count = 1; } + : rep (new octave_complex_matrix (v, pcv)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const char *s) - : rep (new octave_char_matrix_str (s)) { rep->count = 1; } + : rep (new octave_char_matrix_str (s)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const string& s) - : rep (new octave_char_matrix_str (s)) { rep->count = 1; } + : rep (new octave_char_matrix_str (s)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const string_vector& s) - : rep (new octave_char_matrix_str (s)) { rep->count = 1; } + : rep (new octave_char_matrix_str (s)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const charMatrix& chm, bool is_string) : rep (0) @@ -266,13 +314,22 @@ rep = new octave_char_matrix (chm); rep->count = 1; + maybe_mutate (); } octave_value::octave_value (double base, double limit, double inc) - : rep (new octave_range (base, limit, inc)) { rep->count = 1; } + : rep (new octave_range (base, limit, inc)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const Range& r) - : rep (new octave_range (r)) { rep->count = 1; } + : rep (new octave_range (r)) +{ + rep->count = 1; + maybe_mutate (); +} octave_value::octave_value (const Octave_map& m) : rep (new octave_struct (m)) { rep->count = 1; }
--- a/src/ov.h +++ b/src/ov.h @@ -182,11 +182,7 @@ { return rep->try_narrowing_conversion (); } virtual octave_value index (const octave_value_list& idx) const - { - octave_value retval = rep->index (idx); - retval.maybe_mutate (); - return retval; - } + { return rep->index (idx); } octave_value& assign (const octave_value_list& idx, const octave_value& rhs);