diff liboctave/Array.cc @ 1560:27a03373de41

[project @ 1995-10-12 07:22:26 by jwe]
author jwe
date Thu, 12 Oct 1995 07:24:52 +0000
parents d89532de8e72
children ffee86c37931
line wrap: on
line diff
--- a/liboctave/Array.cc
+++ b/liboctave/Array.cc
@@ -31,8 +31,17 @@
 
 #include <cassert>
 
+#include <iostream.h>
+
 #include "Array.h"
 
+#if defined (HEAVYWEIGHT_INDEXING)
+#include "idx-vector.h"
+#include "Array-idx.h"
+#endif
+
+#include "lo-error.h"
+
 // The real representation of all arrays.
 
 template <class T>
@@ -40,6 +49,12 @@
 {
   len = n;
   data = new T [len];
+
+#ifdef HEAVYWEIGHT_INDEXING
+  idx = 0;
+  max_indices = 0;
+  idx_count = 0;
+#endif
 }
 
 template <class T>
@@ -47,16 +62,30 @@
 {
   len = a.len;
   count = a.count;
+
   data = new T [len];
   for (int i = 0; i < len; i++)
     data[i] = a.data[i];
+
+#ifdef HEAVYWEIGHT_INDEXING
+  max_indices = a.max_indices;
+  idx_count = a.idx_count;
+  if (a.idx)
+    {
+      idx_vector *idx = new idx_vector [max_indices];
+      for (int i = 0; i < max_indices; i++)
+	idx[i] = a.idx[i];
+    }
+  else
+    idx = 0;
+#endif
 }
 
 template <class T>
 ArrayRep<T>::~ArrayRep (void)
 {
   delete [] data;
-  data = (T *) 0;
+  delete [] idx;
 }
 
 template <class T>
@@ -97,7 +126,6 @@
       rep = a.rep;
       rep->count++;
     }
-
   return *this;
 }
 
@@ -148,8 +176,7 @@
 {
   if (n < 0)
     {
-      (*current_liboctave_error_handler)
-	("can't resize to negative dimension");
+      (*current_liboctave_error_handler) ("can't resize to negative dimension");
       return;
     }
 
@@ -163,6 +190,8 @@
   rep = new ArrayRep<T> (n);
   rep->count = 1;
 
+  SET_MAX_INDICES (1);
+
   if (old_data && old_len > 0)
     {
       int min_len = old_len < n ? old_len : n;
@@ -181,8 +210,7 @@
 {
   if (n < 0)
     {
-      (*current_liboctave_error_handler)
-	("can't resize to negative dimension");
+      (*current_liboctave_error_handler) ("can't resize to negative dimension");
       return;
     }
 
@@ -196,6 +224,8 @@
   rep = new ArrayRep<T> (n);
   rep->count = 1;
 
+  SET_MAX_INDICES (1);
+
   int min_len = old_len < n ? old_len : n;
 
   if (old_data && old_len > 0)
@@ -280,8 +310,7 @@
 {
   if (r < 0 || c < 0)
     {
-      (*current_liboctave_error_handler)
-	("can't resize to negative dimension");
+      (*current_liboctave_error_handler) ("can't resize to negative dimension");
       return;
     }
 
@@ -290,6 +319,7 @@
 
   ArrayRep<T> *old_rep = rep;
   const T *old_data = data ();
+
   int old_d1 = dim1 ();
   int old_d2 = dim2 ();
   int old_len = length ();
@@ -297,6 +327,8 @@
   rep = new ArrayRep<T> (r*c);
   rep->count = 1;
 
+  SET_MAX_INDICES (2);
+
   d1 = r;
   d2 = c;
 
@@ -320,8 +352,7 @@
 {
   if (r < 0 || c < 0)
     {
-      (*current_liboctave_error_handler)
-	("can't resize to negative dimension");
+      (*current_liboctave_error_handler) ("can't resize to negative dimension");
       return;
     }
 
@@ -337,6 +368,8 @@
   rep = new ArrayRep<T> (r*c);
   rep->count = 1;
 
+  SET_MAX_INDICES (2);
+
   d1 = r;
   d2 = c;
 
@@ -513,8 +546,7 @@
 {
   if (r < 0 || c < 0)
     {
-      (*current_liboctave_error_handler)
-	("can't resize to negative dimensions");
+      (*current_liboctave_error_handler) ("can't resize to negative dimensions");
       return;
     }
 
@@ -530,6 +562,8 @@
   rep = new ArrayRep<T> (new_len);
   rep->count = 1;
 
+  SET_MAX_INDICES (2);
+
   nr = r;
   nc = c;
 
@@ -551,8 +585,7 @@
 {
   if (r < 0 || c < 0)
     {
-      (*current_liboctave_error_handler)
-	("can't resize to negative dimensions");
+      (*current_liboctave_error_handler) ("can't resize to negative dimensions");
       return;
     }
 
@@ -568,6 +601,8 @@
   rep = new ArrayRep<T> (new_len);
   rep->count = 1;
 
+  SET_MAX_INDICES (2);
+
   nr = r;
   nc = c;