changeset 4650:623f6262a8e9

[project @ 2003-11-23 23:17:46 by jwe]
author jwe
date Sun, 23 Nov 2003 23:17:47 +0000
parents f7ce581b27fb
children b868b39534b0
files liboctave/ChangeLog liboctave/boolNDArray.h liboctave/idx-vector.cc liboctave/idx-vector.h src/ChangeLog src/ov-bool-mat.h src/ov-re-mat.h
diffstat 7 files changed, 41 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Sun Nov 23 21:46:44 2003 +0000
+++ b/liboctave/ChangeLog	Sun Nov 23 23:17:47 2003 +0000
@@ -1,5 +1,8 @@
 2003-11-23  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* idx-vector.h, idx-vector.cc: Convert boolMatrix functions to use
+	boolNDArray.  Likewise, convert Matrix functions to use	NDArray.
+
 	* Array-so.cc: New file.  Move instantiations here from so-array.h.
 	* Makefile.in (TI_SRC): Add it to the list.
 
--- a/liboctave/boolNDArray.h	Sun Nov 23 21:46:44 2003 +0000
+++ b/liboctave/boolNDArray.h	Sun Nov 23 23:17:47 2003 +0000
@@ -36,6 +36,8 @@
 #include "data-conv.h"
 #include "mach-info.h"
 
+#include "boolMatrix.h"
+
 class
 boolNDArray : public ArrayN<bool>
 {
--- a/liboctave/idx-vector.cc	Sun Nov 23 21:46:44 2003 +0000
+++ b/liboctave/idx-vector.cc	Sun Nov 23 23:17:47 2003 +0000
@@ -33,9 +33,9 @@
 #include <iostream>
 
 #include "Range.h"
-#include "boolMatrix.h"
+#include "boolNDArray.h"
 #include "dColVector.h"
-#include "dMatrix.h"
+#include "dNDArray.h"
 
 #include "idx-vector.h"
 #include "lo-error.h"
@@ -147,7 +147,7 @@
   init_state ();
 }
 
-IDX_VEC_REP::idx_vector_rep (const Matrix& m)
+IDX_VEC_REP::idx_vector_rep (const NDArray& nda)
 {
   data = 0;
   initialized = 0;
@@ -157,10 +157,7 @@
   colon = 0;
   one_zero = 0;
 
-  orig_nr = m.rows ();
-  orig_nc = m.columns ();
-
-  len = orig_nr * orig_nc;
+  len = nda.length ();
 
   if (len == 0)
     {
@@ -176,16 +173,15 @@
       int k = 0;
       data = new int [len];
 
-      for (int j = 0; j < orig_nc; j++)
-	for (int i = 0; i < orig_nr; i++)
-	  {
-	    double d = m.elem (i, j);
+      for (int i = 0; i < len; i++)
+	{
+	  double d = nda.elem (i);
 
-	    if (idx_is_inf_or_nan (d))
-	      return;
-	    else
-	      data[k++] = tree_to_mat_idx (d);
-	  }
+	  if (idx_is_inf_or_nan (d))
+	    return;
+	  else
+	    data[k++] = tree_to_mat_idx (d);
+	}
     }
 
   init_state ();
@@ -328,7 +324,7 @@
   init_state ();
 }
 
-IDX_VEC_REP::idx_vector_rep (const boolMatrix& bm)
+IDX_VEC_REP::idx_vector_rep (const boolNDArray& bnda)
 {
   data = 0;
   initialized = 0;
@@ -338,10 +334,7 @@
   colon = 0;
   one_zero = 1;
 
-  orig_nr = bm.rows ();
-  orig_nc = bm.columns ();
-
-  len = orig_nr * orig_nc;
+  len = bnda.length ();
 
   if (len == 0)
     {
@@ -358,9 +351,8 @@
       int k = 0;
       data = new int [len];
 
-      for (int j = 0; j < orig_nc; j++)
-	for (int i = 0; i < orig_nr; i++)
-	  data[k++] = tree_to_mat_idx (bm.elem (i, j));
+      for (int i = 0; i < len; i++)
+	data[k++] = tree_to_mat_idx (bnda.elem (i));
     }
 
   init_state ();
--- a/liboctave/idx-vector.h	Sun Nov 23 21:46:44 2003 +0000
+++ b/liboctave/idx-vector.h	Sun Nov 23 23:17:47 2003 +0000
@@ -32,8 +32,8 @@
 #include "Array.h"
 
 class ColumnVector;
-class boolMatrix;
-class Matrix;
+class boolNDArray;
+class NDArray;
 class Range;
 
 class
@@ -64,7 +64,7 @@
 
     idx_vector_rep (const ColumnVector& v);
 
-    idx_vector_rep (const Matrix& m);
+    idx_vector_rep (const NDArray& nda);
 
     idx_vector_rep (const Range& r);
 
@@ -76,7 +76,7 @@
 
     idx_vector_rep (bool b);
 
-    idx_vector_rep (const boolMatrix& bm);
+    idx_vector_rep (const boolNDArray& bnda);
 
     idx_vector_rep (const idx_vector_rep& a);
 
@@ -166,9 +166,9 @@
       rep->count = 1;
     }
 
-  idx_vector (const Matrix& m)
+  idx_vector (const NDArray& nda)
     {
-      rep = new idx_vector_rep (m);
+      rep = new idx_vector_rep (nda);
       rep->count = 1;
     }
 
@@ -202,9 +202,9 @@
       rep->count = 1;
     }
 
-  idx_vector (const boolMatrix& bm)
+  idx_vector (const boolNDArray& bnda)
     {
-      rep = new idx_vector_rep (bm);
+      rep = new idx_vector_rep (bnda);
       rep->count = 1;
     }
 
--- a/src/ChangeLog	Sun Nov 23 21:46:44 2003 +0000
+++ b/src/ChangeLog	Sun Nov 23 23:17:47 2003 +0000
@@ -1,5 +1,14 @@
 2003-11-23  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* ov-bool-mat.h (octave_bool_matrix::array_value): Construct return
+	value directly from matrix data member, not matrix.matrix_value ().
+
+	* ov-re-mat.h (octave_matrix::index_vector): Construct idx_vector
+	from NDArray, not Matrix.
+
+	* ov-bool-mat.h (octave_bool_matrix::index_vector): Construct
+	idx_vector from boolNDArray, not boolMatrix.
+
 	* ov.cc (install_types): Also register dld function type.
 
 	* OPERATORS/op-streamoff.cc: Install increment and decrement operators.
--- a/src/ov-bool-mat.h	Sun Nov 23 21:46:44 2003 +0000
+++ b/src/ov-bool-mat.h	Sun Nov 23 23:17:47 2003 +0000
@@ -76,9 +76,7 @@
 
   octave_value *try_narrowing_conversion (void);
 
-  // XXX FIXME XXX
-  idx_vector index_vector (void) const
-    { return idx_vector (matrix.matrix_value ()); }
+  idx_vector index_vector (void) const { return idx_vector (matrix); }
 
   bool is_bool_matrix (void) const { return true; }
 
@@ -97,7 +95,7 @@
     { return Matrix (matrix.matrix_value ()); }
 
   NDArray array_value (bool = false) const
-    { return NDArray (matrix.matrix_value ()); }
+    { return NDArray (matrix); }
 
   Complex complex_value (bool = false) const;
 
--- a/src/ov-re-mat.h	Sun Nov 23 21:46:44 2003 +0000
+++ b/src/ov-re-mat.h	Sun Nov 23 23:17:47 2003 +0000
@@ -82,8 +82,7 @@
 
   octave_value *try_narrowing_conversion (void);
 
-  // XXX FIXME XXX
-  idx_vector index_vector (void) const { return idx_vector (matrix_value ()); }
+  idx_vector index_vector (void) const { return idx_vector (matrix); }
 
   bool is_real_matrix (void) const { return true; }