diff liboctave/Array.cc @ 10352:a3635bc1ea19

remove Array2
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 23 Feb 2010 16:12:27 +0100
parents 12884915a8e4
children e5ae13b8b2c2
line wrap: on
line diff
--- a/liboctave/Array.cc	Tue Feb 23 14:15:34 2010 +0100
+++ b/liboctave/Array.cc	Tue Feb 23 16:12:27 2010 +0100
@@ -51,10 +51,31 @@
   : rep (a.rep), dimensions (dv), 
     slice_data (a.slice_data), slice_len (a.slice_len)
 {
-  if (dv.numel () != a.numel ())
+  if (dimensions.safe_numel () != a.numel ())
     {
-      std::string dimensions_str = dimensions.str ();
-      std::string new_dims_str = dv.str ();
+      std::string dimensions_str = a.dimensions.str ();
+      std::string new_dims_str = dimensions.str ();
+
+      (*current_liboctave_error_handler)
+        ("reshape: can't reshape %s array to %s array",
+         dimensions_str.c_str (), new_dims_str.c_str ());
+    }
+
+  // This goes here because if an exception is thrown by the above,
+  // destructor will be never called.
+  rep->count++;
+  dimensions.chop_trailing_singletons ();
+}
+
+template <class T>
+Array<T>::Array (const Array<T>& a, octave_idx_type nr, octave_idx_type nc)
+  : rep (a.rep), dimensions (nr, nc), 
+    slice_data (a.slice_data), slice_len (a.slice_len)
+{
+  if (dimensions.safe_numel () != a.numel ())
+    {
+      std::string dimensions_str = a.dimensions.str ();
+      std::string new_dims_str = dimensions.str ();
 
       (*current_liboctave_error_handler)
         ("reshape: can't reshape %s array to %s array",