changeset 2112:320f5463c201

[project @ 1996-05-03 01:19:22 by jwe]
author jwe
date Fri, 03 May 1996 01:20:05 +0000
parents 07227f04abc5
children 0ef10ffb18eb
files liboctave/Array-idx.h liboctave/Array2-idx.h
diffstat 2 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/Array-idx.h
+++ b/liboctave/Array-idx.h
@@ -204,6 +204,19 @@
 	  retval = 0;
 	}
     }
+  else if (idx.is_colon ())
+    {
+      if (lhs_len == 0)
+	{
+	  lhs.resize (rhs_len);
+
+	  for (int i = 0; i < rhs_len; i++)
+	    lhs.elem (i) = rhs.elem (i);
+	}
+      else
+	(*current_liboctave_error_handler)
+	  ("A(:) = X: A must be the same size as X");
+    }
   else
     {
       (*current_liboctave_error_handler)
--- a/liboctave/Array2-idx.h
+++ b/liboctave/Array2-idx.h
@@ -392,8 +392,9 @@
     }
   else if (n_idx == 1)
     {
-      if (lhs_nr == 0 || lhs_nc == 0
-	  || (lhs_nr == 1 && lhs_nc == 1))
+      int lhs_is_empty = lhs_nr == 0 || lhs_nc == 0;
+
+      if (lhs_is_empty || (lhs_nr == 1 && lhs_nc == 1))
 	{
 	  idx_vector *tmp = lhs.get_idx ();
 
@@ -414,6 +415,13 @@
 		      lhs.maybe_delete_elements (idx, tmp);
 		    }
 		}
+	      else if (! liboctave_dfi_flag && lhs_is_empty
+		       && idx.is_colon ()
+		       && ! (rhs_nr == 1 || rhs_nc == 1))
+		{
+		  (*current_liboctave_error_handler)
+		    ("A(:) = X: X must be a vector");
+		}
 	      else
 		{
 		  if (assign ((Array<LT>&) lhs, (Array<RT>&) rhs))
@@ -425,6 +433,9 @@
 			  int idx_nr = idx.orig_rows ();
 			  int idx_nc = idx.orig_columns ();
 
+			  // lhs_is_empty now means that lhs was
+			  // *originally* empty.
+
 			  if (liboctave_dfi_flag
 			      || (idx_nr == 1 && idx_nc == 1))
 			    {
@@ -439,6 +450,11 @@
 				  lhs.d2 = lhs.length ();
 				}
 			    }
+			  else if (lhs_is_empty && idx.is_colon ())
+			    {
+			      lhs.d1 = rhs.d1;
+			      lhs.d2 = rhs.d2;
+			    }
 			  else if (idx_nr == 1 && rhs_nr == 1)
 			    {
 			      lhs.d1 = 1;