changeset 19354:50922b1c74df

liboctave: confirm that matrices constructors are limited to 2 dimensions. * liboctave/array/boolMatrix.h, liboctave/array/chMatrix.h (boolMatrix::boolMatrix(dim_vector),boolMatrix::boolMatrix(dim_vector,bool), charMatrix::charMatrix(dim_vector),charMatrix::charMatrix(dim_vector,char)): call redim(2) on the dim_vector argument to the constructor, the same that happens in the other typeMatrix classes. * liboctave/array/fCMatrix.h: simplify code to reshape NDArray input into matrix form (should have no effect).
author Carnë Draug <carandraug@octave.org>
date Mon, 10 Nov 2014 23:11:20 +0000
parents 3746b92739f7
children a2595c4b8efe
files liboctave/array/boolMatrix.h liboctave/array/chMatrix.h liboctave/array/fCMatrix.h
diffstat 3 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/array/boolMatrix.h	Fri Nov 07 10:41:18 2014 +0000
+++ b/liboctave/array/boolMatrix.h	Mon Nov 10 23:11:20 2014 +0000
@@ -44,9 +44,10 @@
   boolMatrix (octave_idx_type r, octave_idx_type c, bool val)
     : boolNDArray (dim_vector (r, c), val) { }
 
-  boolMatrix (const dim_vector& dv) : boolNDArray (dv) { }
+  boolMatrix (const dim_vector& dv) : boolNDArray (dv.redim (2)) { }
 
-  boolMatrix (const dim_vector& dv, bool val) : boolNDArray (dv, val) { }
+  boolMatrix (const dim_vector& dv, bool val)
+    : boolNDArray (dv.redim (2), val) { }
 
   boolMatrix (const Array<bool>& a) : boolNDArray (a.as_matrix ()) { }
 
--- a/liboctave/array/chMatrix.h	Fri Nov 07 10:41:18 2014 +0000
+++ b/liboctave/array/chMatrix.h	Mon Nov 10 23:11:20 2014 +0000
@@ -49,9 +49,10 @@
   charMatrix (octave_idx_type r, octave_idx_type c, char val)
     : charNDArray (dim_vector (r, c), val) { }
 
-  charMatrix (const dim_vector& dv) : charNDArray (dv) { }
+  charMatrix (const dim_vector& dv) : charNDArray (dv.redim (2)) { }
 
-  charMatrix (const dim_vector& dv, char val) : charNDArray (dv, val) { }
+  charMatrix (const dim_vector& dv, char val)
+    : charNDArray (dv.redim (2), val) { }
 
   charMatrix (const Array<char>& a) : charNDArray (a.as_matrix ()) { }
 
--- a/liboctave/array/fCMatrix.h	Fri Nov 07 10:41:18 2014 +0000
+++ b/liboctave/array/fCMatrix.h	Mon Nov 10 23:11:20 2014 +0000
@@ -64,11 +64,11 @@
 
   template <class U>
   FloatComplexMatrix (const MArray<U>& a)
-    : FloatComplexNDArray (a.reshape (a.dims ().redim (2))) { }
+    : FloatComplexNDArray (a.as_matrix ()) { }
 
   template <class U>
   FloatComplexMatrix (const Array<U>& a)
-    : FloatComplexNDArray (a.reshape (a.dims ().redim (2))) { }
+    : FloatComplexNDArray (a.as_matrix ()) { }
 
   explicit FloatComplexMatrix (const FloatMatrix& a);