changeset 4707:8d4bb887f381

[project @ 2004-01-22 16:01:51 by jwe]
author jwe
date Thu, 22 Jan 2004 16:01:51 +0000
parents 2c73119a576a
children e5639a6586c4
files liboctave/Array.cc liboctave/ChangeLog
diffstat 2 files changed, 35 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/Array.cc	Thu Jan 22 04:36:54 2004 +0000
+++ b/liboctave/Array.cc	Thu Jan 22 16:01:51 2004 +0000
@@ -843,9 +843,11 @@
   int old_len = length ();
 
   int len = get_size (dv);
-
+  
   rep = new typename Array<T>::ArrayRep (len);
 
+  dim_vector dv_old = dimensions;
+  
   dimensions = dv;
 
   Array<int> ra_idx (dimensions.length (), 0);
@@ -861,10 +863,10 @@
 
   for (int i = 0; i < old_len; i++)
     {
-      if (index_in_bounds (ra_idx, dimensions))
-	xelem (ra_idx) = old_data[i];
-
-      increment_index (ra_idx, dimensions);
+      if (index_in_bounds (ra_idx, dv_old))
+	xelem (ra_idx) = old_data[get_scalar_idx (ra_idx, dv_old)];
+
+      increment_index (ra_idx, dv_old);
     }
 
   if (--old_rep->count <= 0)
@@ -2232,6 +2234,29 @@
 
   int rhs_nr = rhs.rows ();
   int rhs_nc = rhs.cols ();
+  
+  if (rhs.length () > 2)
+    {
+      dim_vector dv_tmp = rhs.squeeze().dims ();
+  
+      if (dv_tmp.length () > 2)
+	{
+	  (*current_liboctave_error_handler)
+	    ("Dimension mismatch");
+
+	  return 0;
+	}
+      
+      if (dv_tmp.length () == 1)
+	if (rhs_nr == 1)
+	  rhs_nc = dv_tmp.elem (0);
+
+      else if (dv_tmp.length () == 2)
+	{
+	  rhs_nr = dv_tmp.elem (0);
+	  rhs_nc = dv_tmp.elem (1);
+	}
+    }
 
   idx_vector *tmp = lhs.get_idx ();
 
--- a/liboctave/ChangeLog	Thu Jan 22 04:36:54 2004 +0000
+++ b/liboctave/ChangeLog	Thu Jan 22 16:01:51 2004 +0000
@@ -1,3 +1,8 @@
+2004-01-22  Petter Risholm  <risholm@stud.ntnu.no>
+
+	* Array.cc (Array<T>::assign2): Check for RHS dimensions larger
+	than 2.
+
 2004-01-21  Petter Risholm  <risholm@stud.ntnu.no>
 
 	* Array.h (Array<T>::chop_trailing_singletons): New function.