changeset 3221:eba59b8c64dc

[project @ 1998-11-19 20:31:46 by jwe]
author jwe
date Thu, 19 Nov 1998 20:31:47 +0000
parents 3deb1105fbc1
children dae85431bade
files src/ChangeLog src/DLD-FUNCTIONS/balance.cc src/Makefile.in src/ov-base-mat.h src/ov-bool-mat.h src/ov-ch-mat.cc src/ov-ch-mat.h src/ov-cx-mat.cc src/ov-cx-mat.h src/ov-re-mat.cc src/ov-re-mat.h src/ov-str-mat.cc src/ov-str-mat.h
diffstat 13 files changed, 30 insertions(+), 192 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,15 +1,19 @@
+Thu Nov 19 14:30:25 1998  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* ov-re-mat.h (octave_matrix_value): Delete experimental code for
+	handling structure references for things like .rows, .cols, etc.
+
 Wed Nov 18 01:18:46 1998  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
-	* ov-base-mat.cc (octave_base_matrix::is_true): New function.
-	* ov-bool-mat.cc (octave_bool_matrix::is_true): Delete.
-	* ov-ch-mat.cc (octave_char_matrix::is_true): Delete.
-	* ov-cx-mat.cc (octave_complex_matrix::is_true): Delete.
-	* ov-re-mat.cc (octave_matrix::is_true): Delete.
-
-	* ov-base-mat.cc (octave_base_matrix::do_index_op): New function.
-	* ov-bool-mat.cc (octave_bool_matrix::do_index_op): Delete.
-	* ov-cx-mat.cc (octave_complex_matrix::do_index_op): Delete.
-	* ov-re-mat.cc (octave_matrix::do_index_op): Delete.
+	* Makefile.in (VAR_FILES): Be more careful about matching.
+	(DEF_FILES): Likewise.
+
+	* ov-base-mat.h, ov-base-mat.cc, ov-bool-mat.h, ov-bool-mat.cc,
+	ov-ch-mat.h, ov-ch-mat.cc, ov-cx-mat.h, ov-cx-mat.cc,
+	ov-re-mat.h, ov-re-mat.cc: Move default definition of all, any,
+	is_matrix_type, is_numeric_type, valid_as_zero_index, and
+	do_index_op to base class.
+	Provide definitions that override the defaults where necessary.
 
 	* mappers.cc: Don't include lo-specfun.h.
 
--- a/src/DLD-FUNCTIONS/balance.cc
+++ b/src/DLD-FUNCTIONS/balance.cc
@@ -76,7 +76,7 @@
   B: (default) permute and scale, in that order.  Rows/columns\n\
      of a (and b) that are isolated by permutation are not scaled\n\
 \n\
-[DD, AA] = balance (A, OPT) returns aa = dd*a*dd,\n\
+[DD, AA] = balance (A, OPT) returns aa = inv(dd)*a*dd,\n\
 \n\
 [CC, DD, AA, BB] = balance (A, B, OPT) returns AA (BB) = CC*A*DD (CC*B*DD)")
 {
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -153,16 +153,20 @@
 DEP_1 := $(patsubst %.c, %.d, $(DEP_2))
 MAKEDEPS := $(patsubst %.cc, %.d, $(DEP_1))
 
+DEFUN_PATTERN = "^DEFUN(|_DLD|_TEXT)[ \t]*\\("
+
 DEF_5 := $(SOURCES) $(DLD_SRC)
 DEF_4 := $(addprefix $(srcdir)/, $(DEF_5))
-DEF_3 := $(notdir $(shell grep -l "^DEFUN" $(DEF_4)))
+DEF_3 := $(notdir $(shell egrep -l $(DEFUN_PATTERN) $(DEF_4)))
 DEF_2 := $(patsubst %.y, %.df, $(DEF_3))
 DEF_1 := $(patsubst %.l, %.df, $(DEF_2))
 DEF_FILES := $(patsubst %.cc, %.df, $(DEF_1))
 
+DEFVAR_PATTERN = "^[\t ]*DEF(VAR|CONST)[ \t]*\\("
+
 VAR_5 := $(SOURCES) $(DLD_SRC)
 VAR_4 := $(addprefix $(srcdir)/, $(VAR_5))
-VAR_3 := $(notdir $(shell egrep -l "^[\t ]*DEF(VAR|CONST)" $(VAR_4)))
+VAR_3 := $(notdir $(shell egrep -l $(DEFVAR_PATTERN) $(VAR_4)))
 VAR_2 := $(patsubst %.y, %, $(VAR_3))
 VAR_1 := $(patsubst %.l, %, $(VAR_2))
 VAR_FILES := $(patsubst %.cc, %, $(VAR_1))
--- a/src/ov-base-mat.h
+++ b/src/ov-base-mat.h
@@ -78,6 +78,13 @@
     return r > c ? r : c;
   }
 
+  octave_value all (void) const { return matrix.all (); }
+  octave_value any (void) const { return matrix.any (); }
+
+  bool is_matrix_type (void) const { return true; }
+
+  bool is_numeric_type (void) const { return true; }
+
   bool is_defined (void) const { return true; }
 
   bool is_constant (void) const { return true; }
--- a/src/ov-bool-mat.h
+++ b/src/ov-bool-mat.h
@@ -76,21 +76,12 @@
 
   bool is_bool_matrix (void) const { return true; }
 
-  octave_value all (void) const { return matrix.all (); }
-  octave_value any (void) const { return matrix.any (); }
-
   bool is_bool_type (void) const { return true; }
 
   bool is_real_type (void) const { return true; }
 
-  bool is_matrix_type (void) const { return true; }
-
-  bool is_numeric_type (void) const { return true; }
-
   bool valid_as_scalar_index (void) const;
 
-  bool valid_as_zero_index (void) const { return is_zero_by_zero (); }
-
   double double_value (bool = false) const;
 
   double scalar_value (bool frc_str_conv = false) const
--- a/src/ov-ch-mat.cc
+++ b/src/ov-ch-mat.cc
@@ -54,14 +54,6 @@
   return retval;
 }
 
-bool
-octave_char_matrix::valid_as_zero_index (void) const
-{
-  bool retval = false;
-  error ("octave_char_matrix::valid_as_zero_index(): not implemented");
-  return retval;
-}
-
 double
 octave_char_matrix::double_value (bool) const
 {
--- a/src/ov-ch-mat.h
+++ b/src/ov-ch-mat.h
@@ -82,17 +82,9 @@
   bool is_char_matrix (void) const { return true; }
   bool is_real_matrix (void) const { return true; }
 
-  octave_value all (void) const { return matrix.all (); }
-  octave_value any (void) const { return matrix.any (); }
-
   bool is_real_type (void) const { return true; }
 
-  bool is_matrix_type (void) const { return true; }
-
-  bool is_numeric_type (void) const { return true; }
-
   bool valid_as_scalar_index (void) const;
-  bool valid_as_zero_index (void) const;
 
   double double_value (bool = false) const;
 
--- a/src/ov-cx-mat.cc
+++ b/src/ov-cx-mat.cc
@@ -179,13 +179,6 @@
   return false;
 }
 
-bool
-octave_complex_matrix::valid_as_zero_index (void) const
-{
-  // XXX FIXME XXX
-  return false;
-}
-
 double
 octave_complex_matrix::double_value (bool force_conversion) const
 {
--- a/src/ov-cx-mat.h
+++ b/src/ov-cx-mat.h
@@ -82,17 +82,9 @@
 
   bool is_complex_matrix (void) const { return true; }
 
-  octave_value all (void) const { return matrix.all (); }
-  octave_value any (void) const { return matrix.any (); }
-
   bool is_complex_type (void) const { return true; }
 
-  bool is_matrix_type (void) const { return true; }
-
-  bool is_numeric_type (void) const { return true; }
-
   bool valid_as_scalar_index (void) const;
-  bool valid_as_zero_index (void) const;
 
   double double_value (bool = false) const;
 
--- a/src/ov-re-mat.cc
+++ b/src/ov-re-mat.cc
@@ -114,113 +114,6 @@
     }
 }
 
-void
-octave_matrix::assign_struct_elt (assign_op, const string& nm,
-				  const octave_value& rhs)
-{
-  octave_value retval;
-
-  Matrix m = rhs.matrix_value ();
-
-  if (! error_state)
-    {
-      int nr = -1;
-      int nc = -1;
-
-      int dim = -1;
-
-      if (m.rows () == 1 && m.cols () == 2)
-	{
-	  nr = NINT (m (0, 0));
-	  nc = NINT (m (0, 1));
-	}
-      else if (m.rows () == 2 && m.cols () == 1)
-	{
-	  nr = NINT (m (0, 0));
-	  nc = NINT (m (1, 0));
-	}
-      else if (m.rows () == 1 && m.cols () == 1)
-	{
-	  dim = NINT (m (0, 0));
-
-	  nr = matrix.rows ();
-	  nc = matrix.cols ();
-	}
-
-      if (nm == "size")
-	{
-	  if (nr >= 0 && nc >= 0)
-	    matrix.resize (nr, nc, 0.0);
-	  else
-	    error ("invalid size specification = [%d, %d] specified",
-		   nr, nc);
-	}
-      else if (nm == "rows")
-	{
-	  if (dim >= 0)
-	    matrix.resize (dim, nc, 0.0);
-	  else
-	    error ("invalid row dimension = %d specified", dim);
-	}
-      else if (nm == "cols" || nm == "columns")
-	{
-	  if (dim >= 0)
-	    matrix.resize (nr, dim, 0.0);
-	  else
-	    error ("invalid column dimension = %d specified", dim);
-	}
-    }
-}
-
-void
-octave_matrix::assign_struct_elt (assign_op, const string&,
-				  const octave_value_list&,
-				  const octave_value&)
-{
-  error ("indexed assignment for matrix properties is not implemented");
-}
-
-octave_value
-octave_matrix::do_struct_elt_index_op (const string& nm,
-				       const octave_value_list& idx,
-				       bool silent)
-{
-  // XXX DO_ME XXX
-}
-
-octave_value
-octave_matrix::do_struct_elt_index_op (const string& nm, bool silent)
-{
-  octave_value retval;
-
-  double nr = static_cast<double> (matrix.rows ());
-  double nc = static_cast<double> (matrix.cols ());
-
-  if (nm == "rows")
-    retval = nr;
-  else if (nm == "cols" || nm == "columns")
-    retval = nc;
-  else if (nm == "size")
-    {
-      Matrix tmp (1, 2);
-
-      tmp.elem (0, 0) = nr;
-      tmp.elem (0, 1) = nc;
-
-      retval = tmp;
-    }
-  else if (! silent)
-    error ("structure has no member `%s'", nm.c_str ());
-
-  return retval;
-}
-
-octave_lvalue
-octave_matrix::struct_elt_ref (octave_value *parent, const string& nm)
-{
-  return octave_lvalue (parent, nm);
-}
-
 bool
 octave_matrix::valid_as_scalar_index (void) const
 {
--- a/src/ov-re-mat.h
+++ b/src/ov-re-mat.h
@@ -78,38 +78,14 @@
 
   void assign (const octave_value_list& idx, const Matrix& rhs);
 
-  void assign_struct_elt (assign_op, const string& elt_nm,
-			  const octave_value& rhs);
-
-  void assign_struct_elt (assign_op, const string& elt_nm,
-			  const octave_value_list& idx,
-			  const octave_value& rhs);
-
   idx_vector index_vector (void) const { return idx_vector (matrix); }
 
-  octave_value
-  do_struct_elt_index_op (const string& nm, const octave_value_list& idx,
-			  bool silent);
-
-  octave_value do_struct_elt_index_op (const string& nm, bool silent);
-
-  octave_lvalue struct_elt_ref (octave_value *parent, const string& nm);
-
   bool is_real_matrix (void) const { return true; }
 
-  octave_value all (void) const { return matrix.all (); }
-  octave_value any (void) const { return matrix.any (); }
-
   bool is_real_type (void) const { return true; }
 
-  bool is_matrix_type (void) const { return true; }
-
-  bool is_numeric_type (void) const { return true; }
-
   bool valid_as_scalar_index (void) const;
 
-  bool valid_as_zero_index (void) const { return is_zero_by_zero (); }
-
   double double_value (bool = false) const;
 
   double scalar_value (bool frc_str_conv = false) const
--- a/src/ov-str-mat.cc
+++ b/src/ov-str-mat.cc
@@ -147,13 +147,6 @@
   error ("octave_char_matrix_str::valid_as_scalar_index(): not implemented");
   return retval;
 }
-bool
-octave_char_matrix_str::valid_as_zero_index (void) const
-{
-  bool retval = false;
-  error ("octave_char_matrix_str::valid_as_zero_index(): not implemented");
-  return retval;
-}
 
 Matrix
 octave_char_matrix_str::matrix_value (bool force_string_conv) const
--- a/src/ov-str-mat.h
+++ b/src/ov-str-mat.h
@@ -94,8 +94,9 @@
 
   bool is_matrix_type (void) const { return Vimplicit_str_to_num_ok; }
 
+  bool is_numeric_type (void) const { return Vimplicit_str_to_num_ok; }
+
   bool valid_as_scalar_index (void) const;
-  bool valid_as_zero_index (void) const;
 
   Matrix matrix_value (bool = false) const;