# HG changeset patch # User jwe # Date 814450173 0 # Node ID c02f877ca5253bf60f016fdae3a3c069b3f91da4 # Parent 0c49e5e8dd5b99822f30b0af475f281f1ed2e708 [project @ 1995-10-23 12:09:33 by jwe] diff --git a/src/pt-const.cc b/src/pt-const.cc --- a/src/pt-const.cc +++ b/src/pt-const.cc @@ -1734,7 +1734,7 @@ } void -TC_REP::convert_to_matrix_type (void) +TC_REP::convert_to_matrix_type (int make_complex) { switch (type_tag) { @@ -1749,24 +1749,50 @@ case scalar_constant: { - matrix = new Matrix (1, 1, scalar); - type_tag = matrix_constant; + if (make_complex) + { + complex_matrix = new ComplexMatrix (1, 1, scalar); + type_tag = complex_matrix_constant; + } + else + { + matrix = new Matrix (1, 1, scalar); + type_tag = matrix_constant; + } } break; case unknown_constant: { - matrix = new Matrix (0, 0); - type_tag = matrix_constant; + if (make_complex) + { + complex_matrix = new ComplexMatrix (); + type_tag = complex_matrix_constant; + } + else + { + matrix = new Matrix (); + type_tag = matrix_constant; + } } break; case range_constant: { - Matrix *tmp = new Matrix (range->matrix_value ()); - delete range; - matrix = tmp; - type_tag = matrix_constant; + if (make_complex) + { + ComplexMatrix *tmp = new ComplexMatrix (range->matrix_value ()); + delete range; + complex_matrix = tmp; + type_tag = complex_matrix_constant; + } + else + { + Matrix *tmp = new Matrix (range->matrix_value ()); + delete range; + matrix = tmp; + type_tag = matrix_constant; + } } break; @@ -2695,7 +2721,7 @@ } void -TC_REP::set_index (const Octave_object& args) +TC_REP::set_index (const Octave_object& args, int rhs_is_complex) { switch (type_tag) { @@ -2703,7 +2729,7 @@ case scalar_constant: case complex_scalar_constant: case range_constant: - convert_to_matrix_type (); + convert_to_matrix_type (rhs_is_complex); break; default: @@ -2919,7 +2945,7 @@ maybe_widen (rhs.const_type ()); - set_index (args); + set_index (args, rhs.is_complex_type ()); if (! error_state) { @@ -2970,7 +2996,7 @@ case char_matrix_constant: case char_matrix_constant_str: ::assign (*char_matrix, rhs.char_matrix_value ()); - break; + break; default: panic_impossible (); diff --git a/src/pt-const.h b/src/pt-const.h --- a/src/pt-const.h +++ b/src/pt-const.h @@ -271,7 +271,7 @@ // But not this. - void convert_to_matrix_type (void); + void convert_to_matrix_type (int make_complex); // Indexing and assignment. @@ -283,7 +283,7 @@ void set_index (const Matrix& m); void set_index (char c); - void set_index (const Octave_object& args); + void set_index (const Octave_object& args, int rhs_is_complex = 0); tree_constant do_index (const Octave_object& args); @@ -659,7 +659,8 @@ tree_constant_rep::constant_type const_type (void) const { return rep->const_type (); } - void convert_to_matrix_type (void) { rep->convert_to_matrix_type (); } + void convert_to_matrix_type (int make_complex) + { rep->convert_to_matrix_type (make_complex); } // Can we make these go away?