changeset 19349:25f535b90e52

Change boolMatrix to subclass boolNDArray rather than be another Array<bool>. * boolMatrix.h: both boolMatrix and boolNDArray are Array<bool>, the first being simply 2 dimensional. We change this so that boolMatrix inherits from boolNDArray instead. * boolNDArray.cc, boolNDArray.h (boolNDArray::matrix_value): remove method since boolMatrix can be constructed from its parent. (boolNDArray::boolNDArray): remove constructor from boolMatrix * pr-output.cc, octave-value/ov-bool-mat.cc, octave-value/ov-bool-mat.h: replace calls to boolNDArray::matrix_value () with the boolMatrix constructor.
author Carnë Draug <carandraug@octave.org>
date Mon, 20 Oct 2014 01:34:52 +0100
parents 36d1f379a4f0
children 6c9ea5be96bf
files libinterp/corefcn/pr-output.cc libinterp/octave-value/ov-bool-mat.cc libinterp/octave-value/ov-bool-mat.h liboctave/array/boolMatrix.h liboctave/array/boolNDArray.cc liboctave/array/boolNDArray.h
diffstat 6 files changed, 19 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/pr-output.cc	Mon Nov 10 16:43:39 2014 +0100
+++ b/libinterp/corefcn/pr-output.cc	Mon Oct 20 01:34:52 2014 +0100
@@ -2775,7 +2775,7 @@
     {
     case 1:
     case 2:
-      octave_print_internal (os, nda.matrix_value (),
+      octave_print_internal (os, boolMatrix (nda),
                              pr_as_read_syntax, extra_indent);
       break;
 
--- a/libinterp/octave-value/ov-bool-mat.cc	Mon Nov 10 16:43:39 2014 +0100
+++ b/libinterp/octave-value/ov-bool-mat.cc	Mon Oct 20 01:34:52 2014 +0100
@@ -79,7 +79,7 @@
 
   if (matrix.ndims () == 2)
     {
-      boolMatrix bm = matrix.matrix_value ();
+      boolMatrix bm (matrix);
 
       octave_idx_type nr = bm.rows ();
       octave_idx_type nc = bm.cols ();
--- a/libinterp/octave-value/ov-bool-mat.h	Mon Nov 10 16:43:39 2014 +0100
+++ b/libinterp/octave-value/ov-bool-mat.h	Mon Oct 20 01:34:52 2014 +0100
@@ -135,10 +135,10 @@
   { return double_value (frc_str_conv); }
 
   Matrix matrix_value (bool = false) const
-  { return Matrix (matrix.matrix_value ()); }
+  { return Matrix (boolMatrix (matrix)); }
 
   FloatMatrix float_matrix_value (bool = false) const
-  { return FloatMatrix (matrix.matrix_value ()); }
+  { return FloatMatrix (boolMatrix (matrix)); }
 
   NDArray array_value (bool = false) const
   { return NDArray (matrix); }
@@ -151,10 +151,10 @@
   FloatComplex float_complex_value (bool = false) const;
 
   ComplexMatrix complex_matrix_value (bool = false) const
-  { return ComplexMatrix (matrix.matrix_value ()); }
+  { return ComplexMatrix (boolMatrix (matrix)); }
 
   FloatComplexMatrix float_complex_matrix_value (bool = false) const
-  { return FloatComplexMatrix (matrix.matrix_value ()); }
+  { return FloatComplexMatrix (boolMatrix (matrix)); }
 
   ComplexNDArray complex_array_value (bool = false) const
   { return ComplexNDArray (matrix); }
@@ -176,19 +176,19 @@
   }
 
   boolMatrix bool_matrix_value (bool = false) const
-  { return matrix.matrix_value (); }
+  { return boolMatrix (matrix); }
 
   boolNDArray bool_array_value (bool = false) const
   { return matrix; }
 
   SparseMatrix sparse_matrix_value (bool = false) const
-  { return SparseMatrix (Matrix (matrix.matrix_value ())); }
+  { return SparseMatrix (Matrix (boolMatrix (matrix))); }
 
   SparseComplexMatrix sparse_complex_matrix_value (bool = false) const
-  { return SparseComplexMatrix (ComplexMatrix (matrix.matrix_value ())); }
+  { return SparseComplexMatrix (ComplexMatrix (boolMatrix (matrix))); }
 
   SparseBoolMatrix sparse_bool_matrix_value (bool = false) const
-  { return SparseBoolMatrix (matrix.matrix_value ()); }
+  { return SparseBoolMatrix (boolMatrix (matrix)); }
 
   octave_value convert_to_str_internal (bool pad, bool force, char type) const;
 
--- a/liboctave/array/boolMatrix.h	Mon Nov 10 16:43:39 2014 +0100
+++ b/liboctave/array/boolMatrix.h	Mon Oct 20 01:34:52 2014 +0100
@@ -25,31 +25,32 @@
 #define octave_boolMatrix_h 1
 
 #include "Array.h"
+#include "boolNDArray.h"
 
 #include "mx-defs.h"
 #include "mx-op-decl.h"
 
 class
 OCTAVE_API
-boolMatrix : public Array<bool>
+boolMatrix : public boolNDArray
 {
 public:
 
-  boolMatrix (void) : Array<bool> () { }
+  boolMatrix (void) : boolNDArray () { }
 
   boolMatrix (octave_idx_type r, octave_idx_type c)
-    : Array<bool> (dim_vector (r, c)) { }
+    : boolNDArray (dim_vector (r, c)) { }
 
   boolMatrix (octave_idx_type r, octave_idx_type c, bool val)
-    : Array<bool> (dim_vector (r, c), val) { }
+    : boolNDArray (dim_vector (r, c), val) { }
 
-  boolMatrix (const dim_vector& dv) : Array<bool> (dv) { }
+  boolMatrix (const dim_vector& dv) : boolNDArray (dv) { }
 
-  boolMatrix (const dim_vector& dv, bool val) : Array<bool> (dv, val) { }
+  boolMatrix (const dim_vector& dv, bool val) : boolNDArray (dv, val) { }
 
-  boolMatrix (const Array<bool>& a) : Array<bool> (a.as_matrix ()) { }
+  boolMatrix (const Array<bool>& a) : boolNDArray (a.as_matrix ()) { }
 
-  boolMatrix (const boolMatrix& a) : Array<bool> (a) { }
+  boolMatrix (const boolMatrix& a) : boolNDArray (a) { }
 
   boolMatrix& operator = (const boolMatrix& a)
   {
--- a/liboctave/array/boolNDArray.cc	Mon Nov 10 16:43:39 2014 +0100
+++ b/liboctave/array/boolNDArray.cc	Mon Oct 20 01:34:52 2014 +0100
@@ -107,14 +107,6 @@
   return *this;
 }
 
-
-
-boolMatrix
-boolNDArray::matrix_value (void) const
-{
-  return *this;
-}
-
 void
 boolNDArray::increment_index (Array<octave_idx_type>& ra_idx,
                               const dim_vector& dimensions,
--- a/liboctave/array/boolNDArray.h	Mon Nov 10 16:43:39 2014 +0100
+++ b/liboctave/array/boolNDArray.h	Mon Oct 20 01:34:52 2014 +0100
@@ -29,9 +29,6 @@
 #include "mx-op-decl.h"
 #include "bsxfun-decl.h"
 
-#include "boolMatrix.h"
-
-
 class
 OCTAVE_API
 boolNDArray : public Array<bool>
@@ -49,8 +46,6 @@
 
   boolNDArray (const boolNDArray& a) : Array<bool> (a) { }
 
-  boolNDArray (const boolMatrix& a) : Array<bool> (a) { }
-
   boolNDArray (const Array<bool>& a) : Array<bool> (a) { }
 
   boolNDArray& operator = (const boolNDArray& a)
@@ -83,8 +78,6 @@
   boolNDArray& insert (const boolNDArray& a,
                        const Array<octave_idx_type>& ra_idx);
 
-  boolMatrix matrix_value (void) const;
-
   boolNDArray squeeze (void) const { return Array<bool>::squeeze (); }
 
   static void increment_index (Array<octave_idx_type>& ra_idx,