changeset 722:c40cdd16121e

[project @ 1994-09-21 15:22:21 by jwe]
author jwe
date Wed, 21 Sep 1994 15:24:26 +0000
parents 54a6858bc7e7
children 1c072f20b522
files src/arith-ops.cc src/tc-rep.h src/variables.cc
diffstat 3 files changed, 104 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/arith-ops.cc	Wed Sep 21 15:19:08 1994 +0000
+++ b/src/arith-ops.cc	Wed Sep 21 15:24:26 1994 +0000
@@ -220,6 +220,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 0.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 1.0);
+    }
+
   Matrix t (ar, ac);
 
   for (int j = 0; j < ac; j++)
@@ -267,6 +275,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 0.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 1.0);
+    }
+
   Matrix t (ar, ac);
 
   for (int j = 0; j < ac; j++)
@@ -314,6 +330,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 0.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 1.0);
+    }
+
   Matrix t (ar, ac);
 
   for (int j = 0; j < ac; j++)
@@ -361,6 +385,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 0.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 1.0);
+    }
+
   Matrix t (ar, ac);
 
   for (int j = 0; j < ac; j++)
@@ -411,6 +443,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 1.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 0.0);
+    }
+
   Matrix c (ar, ac);
 
   for (int j = 0; j < ac; j++)
@@ -461,6 +501,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 1.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 0.0);
+    }
+
   Matrix c (ar, ac);
 
   for (int j = 0; j < ac; j++)
@@ -507,6 +555,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 0.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 1.0);
+    }
+
   Matrix t (ar, ac);
 
   for (int j = 0; j < ac; j++)
@@ -554,6 +610,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 0.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 1.0);
+    }
+
   Matrix t (ar, ac);
 
   for (int j = 0; j < ac; j++)
@@ -601,6 +665,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 0.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 1.0);
+    }
+
   Matrix t (ar, ac);
 
   for (int j = 0; j < ac; j++)
@@ -648,6 +720,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 0.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 1.0);
+    }
+
   Matrix t (ar, ac);
 
   for (int j = 0; j < ac; j++)
@@ -698,6 +778,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 1.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 0.0);
+    }
+
   Matrix c (ar, ac);
 
   for (int j = 0; j < ac; j++)
@@ -748,6 +836,14 @@
   int ar = a.rows ();
   int ac = a.columns ();
 
+  if (ar == 0 || ac == 0)
+    {
+      if (op == Matrix_EQ)
+	return Matrix (1, 1, 1.0);
+      else if (op == Matrix_NE)
+	return Matrix (1, 1, 0.0);
+    }
+
   Matrix c (ar, ac);
 
   for (int j = 0; j < ac; j++)
--- a/src/tc-rep.h	Wed Sep 21 15:19:08 1994 +0000
+++ b/src/tc-rep.h	Wed Sep 21 15:24:26 1994 +0000
@@ -180,7 +180,7 @@
   ComplexColumnVector complex_vector_value (int force_string_conv = 0,
 					    int force_vec_conv = 0) const;
 
-  tree_constant convert_to_str (void);
+  tree_constant convert_to_str (void) const;
 
   void convert_to_row_or_column_vector (void);
 
@@ -346,7 +346,9 @@
 // Data.
 
   int count;
+
   constant_type type_tag;
+
   union
     {
       double scalar;			// A real scalar constant.
@@ -356,6 +358,7 @@
       char *string;			// A character string constant.
       Range *range;			// A set of evenly spaced values.
     };
+
   char *orig_text;
 
 // -------------------------------------------------------------------
--- a/src/variables.cc	Wed Sep 21 15:19:08 1994 +0000
+++ b/src/variables.cc	Wed Sep 21 15:24:26 1994 +0000
@@ -172,7 +172,7 @@
   if (nargin != e_nargin)
     {
       if (warn)
-	error ("%s: expecting function to take %d argument%c", 
+	error ("%s: expecting function to take %d argument%s", 
 	       warn_for, e_nargin, (e_nargin == 1 ? "" : "s"));
       return 0;
     }
@@ -193,7 +193,7 @@
       return retval;
     }
 
-  char *name = args(1).string_value ();
+  char *name = args(0).string_value ();
 
   if (error_state)
     {
@@ -224,7 +224,7 @@
       return retval;
     }
 
-  char *name = args(1).string_value ();
+  char *name = args(0).string_value ();
 
   if (error_state)
     {
@@ -1183,7 +1183,7 @@
   mfcn.d_c_mapper = mf->d_c_mapper;
   mfcn.c_c_mapper = mf->c_c_mapper;
 
-  tree_builtin *def = new tree_builtin (2, 1, mfcn, mf->name);
+  tree_builtin *def = new tree_builtin (1, 1, mfcn, mf->name);
 
   sym_rec->define (def);