# HG changeset patch # User jwe # Date 845671182 0 # Node ID de430cdd92346e7813ec9100fba4fc515e241930 # Parent 327f65b8ea0c8f42c8fb2661e9461a6d9d441b42 [project @ 1996-10-18 20:39:41 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ Fri Oct 18 13:44:33 1996 John W. Eaton + * 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. diff --git a/src/ov-complex.cc b/src/ov-complex.cc --- 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); } diff --git a/src/ov-scalar.cc b/src/ov-scalar.cc --- 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); } diff --git a/src/ov.cc b/src/ov.cc --- 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; } diff --git a/src/ov.h b/src/ov.h --- 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);