Mercurial > hg > octave-terminal
changeset 2407:4f55dc039a7e
[project @ 1996-10-14 19:48:50 by jwe]
author | jwe |
---|---|
date | Mon, 14 Oct 1996 19:48:51 +0000 |
parents | 13b3c87b192e |
children | e22aae3ccfad |
files | src/ChangeLog src/op-str-str.cc src/ov-cx-mat.cc src/ov-re-mat.cc src/ov-str-mat.cc src/ov-str-mat.h src/pt-fvc.cc |
diffstat | 7 files changed, 108 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,7 +1,7 @@ Mon Oct 14 11:05:24 1996 John W. Eaton <jwe@bevo.che.wisc.edu> - * pt-fvc.cc (tree_identifier::eval): If retval is undefined, print - error message. + * pt-fvc.cc (tree_identifier::eval): If retval is undefined and + the object to eval is a constant, print error message. * Makefile (distclean): Remove *.oct too.
--- a/src/op-str-str.cc +++ b/src/op-str-str.cc @@ -45,10 +45,32 @@ return octave_value (v1.char_matrix_value () == v2.char_matrix_value ()); } +static octave_value +ne (const octave_value& a1, const octave_value& a2) +{ + CAST_BINOP_ARGS (const octave_char_matrix_str&, + const octave_char_matrix_str&); + + return octave_value (v1.char_matrix_value () != v2.char_matrix_value ()); +} + +static octave_value +assign (octave_value& a1, const octave_value_list& idx, + const octave_value& a2) +{ + CAST_BINOP_ARGS (octave_char_matrix_str&, const octave_char_matrix_str&); + + v1.assign (idx, v2.char_matrix_value ()); + return octave_value (); +} + void install_str_str_ops (void) { INSTALL_BINOP (eq, octave_char_matrix_str, octave_char_matrix_str, eq); + INSTALL_BINOP (ne, octave_char_matrix_str, octave_char_matrix_str, ne); + + INSTALL_ASSIGNOP (octave_char_matrix_str, octave_char_matrix_str, assign); } /*
--- a/src/ov-cx-mat.cc +++ b/src/ov-cx-mat.cc @@ -67,6 +67,7 @@ { idx_vector i = idx (0).index_vector (); idx_vector j = idx (1).index_vector (); + retval = ComplexMatrix (matrix.index (i, j)); } break; @@ -74,6 +75,7 @@ case 1: { idx_vector i = idx (0).index_vector (); + retval = ComplexMatrix (matrix.index (i)); } break;
--- a/src/ov-re-mat.cc +++ b/src/ov-re-mat.cc @@ -67,6 +67,7 @@ { idx_vector i = idx (0).index_vector (); idx_vector j = idx (1).index_vector (); + retval = Matrix (matrix.index (i, j)); } break; @@ -74,6 +75,7 @@ case 1: { idx_vector i = idx (0).index_vector (); + retval = Matrix (matrix.index (i)); } break;
--- a/src/ov-str-mat.cc +++ b/src/ov-str-mat.cc @@ -31,6 +31,7 @@ #include "lo-ieee.h" #include "mx-base.h" +#include "oct-obj.h" #include "ops.h" #include "ov-re-mat.h" #include "ov-str-mat.h" @@ -56,6 +57,79 @@ } octave_value +octave_char_matrix_str::index (const octave_value_list& idx) const +{ + octave_value retval; + + int len = idx.length (); + + switch (len) + { + case 2: + { + idx_vector i = idx (0).index_vector (); + idx_vector j = idx (1).index_vector (); + + retval = octave_value (charMatrix (matrix.index (i, j)), true); + } + break; + + case 1: + { + idx_vector i = idx (0).index_vector (); + + retval = octave_value (charMatrix (matrix.index (i)), true); + } + break; + + default: + error ("invalid number of indices (%d) for matrix value", len); + break; + } + + return retval; +} + +extern void assign (Array2<char>&, const Array2<char>&); + +void +octave_char_matrix_str::assign (const octave_value_list& idx, + const charMatrix& rhs) +{ + int len = idx.length (); + + switch (len) + { + case 2: + { + idx_vector i = idx (0).index_vector (); + idx_vector j = idx (1).index_vector (); + + matrix.set_index (i); + matrix.set_index (j); + + ::assign (matrix, rhs); + } + break; + + case 1: + { + idx_vector i = idx (0).index_vector (); + + matrix.set_index (i); + + ::assign (matrix, rhs); + } + break; + + default: + error ("invalid number of indices (%d) for indexed matrix assignment", + len); + break; + } +} + +octave_value octave_char_matrix_str::all (void) const { octave_value retval; @@ -118,9 +192,7 @@ charMatrix octave_char_matrix_str::all_strings (void) const { - charMatrix retval; - error ("octave_char_matrix_str::all_strings(): not implemented"); - return retval; + return matrix; } string
--- a/src/ov-str-mat.h +++ b/src/ov-str-mat.h @@ -84,6 +84,10 @@ numeric_conv_fcn numeric_conversion_function (void) const; + octave_value index (const octave_value_list& idx) const; + + void assign (const octave_value_list& idx, const charMatrix& rhs); + octave_value all (void) const; octave_value any (void) const;