# HG changeset patch # User Carnë Draug # Date 1415348155 0 # Node ID d0c73e23a5056f8b1e0eba8fb16c5e375738acf0 # Parent 8b4a24081e47146e2e889a13733c9857be348422 Change inheritance tree so that Matrix inherit from NDArray. * liboctave/array/CMatrix.cc, liboctave/array/CMatrix.h, liboctave/array/CNDArray.cc, liboctave/array/CNDArray.h, liboctave/array/dMatrix.cc, liboctave/array/dMatrix.h, liboctave/array/dNDArray.cc, liboctave/array/dNDArray.h, liboctave/array/fCMatrix.cc, liboctave/array/fCMatrix.h, liboctave/array/fCNDArray.cc, liboctave/array/fCNDArray.h, liboctave/array/fMatrix.cc, liboctave/array/fMatrix.h, liboctave/array/fNDArray.cc, liboctave/array/fNDArray.h: change base class of Matrix, FloatMatrix, ComplexMatrix, and FloatComplexMatrix to NDArray, FloatNDArray, ComplexNDArray, and FloatComplexNDArray respectively. This will allow to reduce duplicated code since the Matrix classes will be able to inherit many of their methods from their NDArray counterparts. Also remove the matrix_value () method since a constructor now suffices. * liboctave/array/CSparse.h: include CMatrix * libinterp/corefcn/pr-output.cc, libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-flt-cx-mat.cc, libinterp/octave-value/ov-flt-re-mat.cc, libinterp/octave-value/ov-re-mat.cc: replace calls to matrix_value () with constructor with respective Matrix subclass. diff -r 8b4a24081e47 -r d0c73e23a505 libinterp/corefcn/pr-output.cc --- a/libinterp/corefcn/pr-output.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/libinterp/corefcn/pr-output.cc Fri Nov 07 08:15:55 2014 +0000 @@ -2088,7 +2088,7 @@ { case 1: case 2: - octave_print_internal (os, nda.matrix_value (), + octave_print_internal (os, Matrix (nda), pr_as_read_syntax, extra_indent); break; @@ -2565,7 +2565,7 @@ { case 1: case 2: - octave_print_internal (os, nda.matrix_value (), + octave_print_internal (os, ComplexMatrix (nda), pr_as_read_syntax, extra_indent); break; diff -r 8b4a24081e47 -r d0c73e23a505 libinterp/octave-value/ov-cx-mat.cc --- a/libinterp/octave-value/ov-cx-mat.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/libinterp/octave-value/ov-cx-mat.cc Fri Nov 07 08:15:55 2014 +0000 @@ -152,7 +152,7 @@ gripe_implicit_conversion ("Octave:imag-to-real", "complex matrix", "real matrix"); - retval = ::real (matrix.matrix_value ()); + retval = ::real (ComplexMatrix (matrix)); return retval; } @@ -166,7 +166,7 @@ gripe_implicit_conversion ("Octave:imag-to-real", "complex matrix", "real matrix"); - retval = ::real (matrix.matrix_value ()); + retval = ::real (ComplexMatrix (matrix)); return retval; } @@ -214,13 +214,13 @@ ComplexMatrix octave_complex_matrix::complex_matrix_value (bool) const { - return matrix.matrix_value (); + return ComplexMatrix (matrix); } FloatComplexMatrix octave_complex_matrix::float_complex_matrix_value (bool) const { - return FloatComplexMatrix (matrix.matrix_value ()); + return FloatComplexMatrix (ComplexMatrix (matrix)); } boolNDArray @@ -270,7 +270,7 @@ gripe_implicit_conversion ("Octave:imag-to-real", "complex matrix", "real matrix"); - retval = SparseMatrix (::real (matrix.matrix_value ())); + retval = SparseMatrix (::real (ComplexMatrix (matrix))); return retval; } @@ -278,7 +278,7 @@ SparseComplexMatrix octave_complex_matrix::sparse_complex_matrix_value (bool) const { - return SparseComplexMatrix (matrix.matrix_value ()); + return SparseComplexMatrix (ComplexMatrix (matrix)); } octave_value @@ -302,7 +302,7 @@ if (matrix.ndims () == 2 && (matrix.rows () == 1 || matrix.columns () == 1)) { - ComplexMatrix mat = matrix.matrix_value (); + ComplexMatrix mat (matrix); retval = mat.diag (m, n); } diff -r 8b4a24081e47 -r d0c73e23a505 libinterp/octave-value/ov-flt-cx-mat.cc --- a/libinterp/octave-value/ov-flt-cx-mat.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/libinterp/octave-value/ov-flt-cx-mat.cc Fri Nov 07 08:15:55 2014 +0000 @@ -140,7 +140,7 @@ gripe_implicit_conversion ("Octave:imag-to-real", "complex matrix", "real matrix"); - retval = ::real (matrix.matrix_value ()); + retval = ::real (FloatComplexMatrix (matrix)); return retval; } @@ -154,7 +154,7 @@ gripe_implicit_conversion ("Octave:imag-to-real", "complex matrix", "real matrix"); - retval = ::real (matrix.matrix_value ()); + retval = ::real (FloatComplexMatrix (matrix)); return retval; } @@ -202,13 +202,13 @@ ComplexMatrix octave_float_complex_matrix::complex_matrix_value (bool) const { - return matrix.matrix_value (); + return FloatComplexMatrix (matrix); } FloatComplexMatrix octave_float_complex_matrix::float_complex_matrix_value (bool) const { - return FloatComplexMatrix (matrix.matrix_value ()); + return FloatComplexMatrix (matrix); } boolNDArray @@ -290,7 +290,7 @@ if (matrix.ndims () == 2 && (matrix.rows () == 1 || matrix.columns () == 1)) { - FloatComplexMatrix mat = matrix.matrix_value (); + FloatComplexMatrix mat (matrix); retval = mat.diag (m, n); } diff -r 8b4a24081e47 -r d0c73e23a505 libinterp/octave-value/ov-flt-re-mat.cc --- a/libinterp/octave-value/ov-flt-re-mat.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/libinterp/octave-value/ov-flt-re-mat.cc Fri Nov 07 08:15:55 2014 +0000 @@ -127,13 +127,13 @@ Matrix octave_float_matrix::matrix_value (bool) const { - return Matrix (matrix.matrix_value ()); + return Matrix (FloatMatrix (matrix)); } FloatMatrix octave_float_matrix::float_matrix_value (bool) const { - return matrix.matrix_value (); + return FloatMatrix (matrix); } Complex @@ -181,13 +181,13 @@ ComplexMatrix octave_float_matrix::complex_matrix_value (bool) const { - return ComplexMatrix (matrix.matrix_value ()); + return ComplexMatrix (FloatMatrix (matrix)); } FloatComplexMatrix octave_float_matrix::float_complex_matrix_value (bool) const { - return FloatComplexMatrix (matrix.matrix_value ()); + return FloatComplexMatrix (FloatMatrix (matrix)); } ComplexNDArray @@ -268,7 +268,7 @@ if (matrix.ndims () == 2 && (matrix.rows () == 1 || matrix.columns () == 1)) { - FloatMatrix mat = matrix.matrix_value (); + FloatMatrix mat (matrix); retval = mat.diag (m, n); } diff -r 8b4a24081e47 -r d0c73e23a505 libinterp/octave-value/ov-re-mat.cc --- a/libinterp/octave-value/ov-re-mat.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/libinterp/octave-value/ov-re-mat.cc Fri Nov 07 08:15:55 2014 +0000 @@ -142,13 +142,13 @@ Matrix octave_matrix::matrix_value (bool) const { - return matrix.matrix_value (); + return Matrix (matrix); } FloatMatrix octave_matrix::float_matrix_value (bool) const { - return FloatMatrix (matrix.matrix_value ()); + return FloatMatrix (Matrix (matrix)); } Complex @@ -196,13 +196,13 @@ ComplexMatrix octave_matrix::complex_matrix_value (bool) const { - return ComplexMatrix (matrix.matrix_value ()); + return ComplexMatrix (Matrix (matrix)); } FloatComplexMatrix octave_matrix::float_complex_matrix_value (bool) const { - return FloatComplexMatrix (matrix.matrix_value ()); + return FloatComplexMatrix (Matrix (matrix)); } ComplexNDArray @@ -244,7 +244,7 @@ SparseMatrix octave_matrix::sparse_matrix_value (bool) const { - return SparseMatrix (matrix.matrix_value ()); + return SparseMatrix (Matrix (matrix)); } SparseComplexMatrix @@ -277,7 +277,7 @@ if (matrix.ndims () == 2 && (matrix.rows () == 1 || matrix.columns () == 1)) { - Matrix mat = matrix.matrix_value (); + Matrix mat (matrix); retval = mat.diag (m, n); } diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/CMatrix.cc --- a/liboctave/array/CMatrix.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/CMatrix.cc Fri Nov 07 08:15:55 2014 +0000 @@ -40,6 +40,7 @@ #include "chMatrix.h" #include "dMatrix.h" #include "CMatrix.h" +#include "CNDArray.h" #include "CRowVector.h" #include "dRowVector.h" #include "CDiagMatrix.h" @@ -267,39 +268,39 @@ // Complex Matrix class ComplexMatrix::ComplexMatrix (const Matrix& a) - : MArray (a) + : ComplexNDArray (a) { } ComplexMatrix::ComplexMatrix (const RowVector& rv) - : MArray (rv) + : ComplexNDArray (rv) { } ComplexMatrix::ComplexMatrix (const ColumnVector& cv) - : MArray (cv) + : ComplexNDArray (cv) { } ComplexMatrix::ComplexMatrix (const DiagMatrix& a) - : MArray (a.dims (), 0.0) + : ComplexNDArray (a.dims (), 0.0) { for (octave_idx_type i = 0; i < a.length (); i++) elem (i, i) = a.elem (i, i); } ComplexMatrix::ComplexMatrix (const ComplexRowVector& rv) - : MArray (rv) + : ComplexNDArray (rv) { } ComplexMatrix::ComplexMatrix (const ComplexColumnVector& cv) - : MArray (cv) + : ComplexNDArray (cv) { } ComplexMatrix::ComplexMatrix (const ComplexDiagMatrix& a) - : MArray (a.dims (), 0.0) + : ComplexNDArray (a.dims (), 0.0) { for (octave_idx_type i = 0; i < a.length (); i++) elem (i, i) = a.elem (i, i); @@ -308,12 +309,12 @@ // FIXME: could we use a templated mixed-type copy function here? ComplexMatrix::ComplexMatrix (const boolMatrix& a) - : MArray (a) + : ComplexNDArray (a) { } ComplexMatrix::ComplexMatrix (const charMatrix& a) - : MArray (a.dims (), 0.0) + : ComplexNDArray (a.dims (), 0.0) { for (octave_idx_type i = 0; i < a.rows (); i++) for (octave_idx_type j = 0; j < a.cols (); j++) @@ -321,7 +322,7 @@ } ComplexMatrix::ComplexMatrix (const Matrix& re, const Matrix& im) - : MArray (re.dims ()) + : ComplexNDArray (re.dims ()) { if (im.rows () != rows () || im.cols () != cols ()) (*current_liboctave_error_handler) ("complex: internal error"); @@ -468,7 +469,7 @@ ComplexMatrix::insert (const ComplexMatrix& a, octave_idx_type r, octave_idx_type c) { - Array::insert (a, r, c); + ComplexNDArray::insert (a, r, c); return *this; } @@ -3248,7 +3249,7 @@ ComplexMatrix ComplexMatrix::diag (octave_idx_type k) const { - return MArray::diag (k); + return ComplexNDArray::diag (k); } ComplexDiagMatrix diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/CMatrix.h --- a/liboctave/array/CMatrix.h Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/CMatrix.h Fri Nov 07 08:15:55 2014 +0000 @@ -26,6 +26,7 @@ #include "MArray.h" #include "MDiagArray2.h" #include "MatrixType.h" +#include "CNDArray.h" #include "mx-defs.h" #include "mx-op-decl.h" @@ -34,7 +35,7 @@ class OCTAVE_API -ComplexMatrix : public MArray +ComplexMatrix : public ComplexNDArray { public: @@ -43,26 +44,26 @@ typedef void (*solve_singularity_handler) (double rcon); - ComplexMatrix (void) : MArray () { } + ComplexMatrix (void) : ComplexNDArray () { } ComplexMatrix (octave_idx_type r, octave_idx_type c) - : MArray (dim_vector (r, c)) { } + : ComplexNDArray (dim_vector (r, c)) { } ComplexMatrix (octave_idx_type r, octave_idx_type c, const Complex& val) - : MArray (dim_vector (r, c), val) { } + : ComplexNDArray (dim_vector (r, c), val) { } - ComplexMatrix (const dim_vector& dv) : MArray (dv.redim (2)) { } + ComplexMatrix (const dim_vector& dv) : ComplexNDArray (dv.redim (2)) { } ComplexMatrix (const dim_vector& dv, const Complex& val) - : MArray (dv.redim (2), val) { } + : ComplexNDArray (dv.redim (2), val) { } - ComplexMatrix (const ComplexMatrix& a) : MArray (a) { } + ComplexMatrix (const ComplexMatrix& a) : ComplexNDArray (a) { } template - ComplexMatrix (const MArray& a) : MArray (a.as_matrix ()) { } + ComplexMatrix (const MArray& a) : ComplexNDArray (a.as_matrix ()) { } template - ComplexMatrix (const Array& a) : MArray (a.as_matrix ()) { } + ComplexMatrix (const Array& a) : ComplexNDArray (a.as_matrix ()) { } ComplexMatrix (const Matrix& re, const Matrix& im); @@ -86,7 +87,7 @@ ComplexMatrix& operator = (const ComplexMatrix& a) { - MArray::operator = (a); + ComplexNDArray::operator = (a); return *this; } diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/CNDArray.cc --- a/liboctave/array/CNDArray.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/CNDArray.cc Fri Nov 07 08:15:55 2014 +0000 @@ -815,20 +815,6 @@ return *this; } -ComplexMatrix -ComplexNDArray::matrix_value (void) const -{ - ComplexMatrix retval; - - if (ndims () == 2) - retval = ComplexMatrix (Array (*this)); - else - (*current_liboctave_error_handler) - ("invalid conversion of ComplexNDArray to ComplexMatrix"); - - return retval; -} - void ComplexNDArray::increment_index (Array& ra_idx, const dim_vector& dimensions, diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/CNDArray.h --- a/liboctave/array/CNDArray.h Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/CNDArray.h Fri Nov 07 08:15:55 2014 +0000 @@ -24,7 +24,6 @@ #define octave_CNDArray_h 1 #include "MArray.h" -#include "CMatrix.h" #include "mx-defs.h" #include "mx-op-decl.h" @@ -36,8 +35,6 @@ { public: - typedef ComplexMatrix matrix_type; - ComplexNDArray (void) : MArray () { } ComplexNDArray (const dim_vector& dv) : MArray (dv) { } @@ -47,8 +44,6 @@ ComplexNDArray (const ComplexNDArray& a) : MArray (a) { } - ComplexNDArray (const ComplexMatrix& a) : MArray (a) { } - template ComplexNDArray (const MArray& a) : MArray (a) { } @@ -124,8 +119,6 @@ ComplexNDArray fourierNd (void) const; ComplexNDArray ifourierNd (void) const; - ComplexMatrix matrix_value (void) const; - ComplexNDArray squeeze (void) const { return MArray::squeeze (); } static void increment_index (Array& ra_idx, diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/CSparse.h --- a/liboctave/array/CSparse.h Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/CSparse.h Fri Nov 07 08:15:55 2014 +0000 @@ -26,6 +26,7 @@ #include "dMatrix.h" #include "dNDArray.h" +#include "CMatrix.h" #include "CNDArray.h" #include "dColVector.h" #include "CColVector.h" diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/dMatrix.cc --- a/liboctave/array/dMatrix.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/dMatrix.cc Fri Nov 07 08:15:55 2014 +0000 @@ -246,24 +246,24 @@ // Matrix class. Matrix::Matrix (const RowVector& rv) - : MArray (rv) + : NDArray (rv) { } Matrix::Matrix (const ColumnVector& cv) - : MArray (cv) + : NDArray (cv) { } Matrix::Matrix (const DiagMatrix& a) - : MArray (a.dims (), 0.0) + : NDArray (a.dims (), 0.0) { for (octave_idx_type i = 0; i < a.length (); i++) elem (i, i) = a.elem (i, i); } Matrix::Matrix (const PermMatrix& a) - : MArray (a.dims (), 0.0) + : NDArray (a.dims (), 0.0) { const Array ia (a.col_perm_vec ()); octave_idx_type len = a.rows (); @@ -274,12 +274,12 @@ // FIXME: could we use a templated mixed-type copy function here? Matrix::Matrix (const boolMatrix& a) - : MArray (a) + : NDArray (a) { } Matrix::Matrix (const charMatrix& a) - : MArray (a.dims ()) + : NDArray (a.dims ()) { for (octave_idx_type i = 0; i < a.rows (); i++) for (octave_idx_type j = 0; j < a.cols (); j++) @@ -2800,7 +2800,7 @@ Matrix Matrix::diag (octave_idx_type k) const { - return MArray::diag (k); + return NDArray::diag (k); } DiagMatrix diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/dMatrix.h --- a/liboctave/array/dMatrix.h Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/dMatrix.h Fri Nov 07 08:15:55 2014 +0000 @@ -23,6 +23,7 @@ #if !defined (octave_dMatrix_h) #define octave_dMatrix_h 1 +#include "dNDArray.h" #include "MArray.h" #include "MDiagArray2.h" #include "MatrixType.h" @@ -33,7 +34,7 @@ class OCTAVE_API -Matrix : public MArray +Matrix : public NDArray { public: @@ -42,26 +43,26 @@ typedef void (*solve_singularity_handler) (double rcon); - Matrix (void) : MArray () { } + Matrix (void) : NDArray () { } Matrix (octave_idx_type r, octave_idx_type c) - : MArray (dim_vector (r, c)) { } + : NDArray (dim_vector (r, c)) { } Matrix (octave_idx_type r, octave_idx_type c, double val) - : MArray (dim_vector (r, c), val) { } + : NDArray (dim_vector (r, c), val) { } - Matrix (const dim_vector& dv) : MArray (dv.redim (2)) { } + Matrix (const dim_vector& dv) : NDArray (dv.redim (2)) { } Matrix (const dim_vector& dv, double val) - : MArray (dv.redim (2), val) { } + : NDArray (dv.redim (2), val) { } - Matrix (const Matrix& a) : MArray (a) { } + Matrix (const Matrix& a) : NDArray (a) { } template - Matrix (const MArray& a) : MArray (a.as_matrix ()) { } + Matrix (const MArray& a) : NDArray (a.as_matrix ()) { } template - Matrix (const Array& a) : MArray (a.as_matrix ()) { } + Matrix (const Array& a) : NDArray (a.as_matrix ()) { } explicit Matrix (const RowVector& rv); diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/dNDArray.cc --- a/liboctave/array/dNDArray.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/dNDArray.cc Fri Nov 07 08:15:55 2014 +0000 @@ -841,20 +841,6 @@ return do_mx_unary_map (*this); } -Matrix -NDArray::matrix_value (void) const -{ - Matrix retval; - - if (ndims () == 2) - retval = Matrix (Array (*this)); - else - (*current_liboctave_error_handler) - ("invalid conversion of NDArray to Matrix"); - - return retval; -} - void NDArray::increment_index (Array& ra_idx, const dim_vector& dimensions, diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/dNDArray.h --- a/liboctave/array/dNDArray.h Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/dNDArray.h Fri Nov 07 08:15:55 2014 +0000 @@ -24,7 +24,6 @@ #define octave_dNDArray_h 1 #include "MArray.h" -#include "dMatrix.h" #include "intNDArray.h" #include "mx-defs.h" @@ -37,8 +36,6 @@ { public: - typedef Matrix matrix_type; - NDArray (void) : MArray () { } NDArray (const dim_vector& dv) : MArray (dv) { } @@ -48,8 +45,6 @@ NDArray (const NDArray& a) : MArray (a) { } - NDArray (const Matrix& a) : MArray (a) { } - NDArray (const Array& a, bool zero_based = false, bool negative_to_nan = false); @@ -141,8 +136,6 @@ friend class ComplexNDArray; - Matrix matrix_value (void) const; - NDArray squeeze (void) const { return MArray::squeeze (); } static void increment_index (Array& ra_idx, diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/fCMatrix.cc --- a/liboctave/array/fCMatrix.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/fCMatrix.cc Fri Nov 07 08:15:55 2014 +0000 @@ -41,6 +41,7 @@ #include "boolMatrix.h" #include "chMatrix.h" #include "fCMatrix.h" +#include "fCNDArray.h" #include "fCDiagMatrix.h" #include "fCColVector.h" #include "fCRowVector.h" @@ -268,39 +269,39 @@ // FloatComplex Matrix class FloatComplexMatrix::FloatComplexMatrix (const FloatMatrix& a) - : MArray (a) + : FloatComplexNDArray (a) { } FloatComplexMatrix::FloatComplexMatrix (const FloatRowVector& rv) - : MArray (rv) + : FloatComplexNDArray (rv) { } FloatComplexMatrix::FloatComplexMatrix (const FloatColumnVector& cv) - : MArray (cv) + : FloatComplexNDArray (cv) { } FloatComplexMatrix::FloatComplexMatrix (const FloatDiagMatrix& a) - : MArray (a.dims (), 0.0) + : FloatComplexNDArray (a.dims (), 0.0) { for (octave_idx_type i = 0; i < a.length (); i++) elem (i, i) = a.elem (i, i); } FloatComplexMatrix::FloatComplexMatrix (const FloatComplexRowVector& rv) - : MArray (rv) + : FloatComplexNDArray (rv) { } FloatComplexMatrix::FloatComplexMatrix (const FloatComplexColumnVector& cv) - : MArray (cv) + : FloatComplexNDArray (cv) { } FloatComplexMatrix::FloatComplexMatrix (const FloatComplexDiagMatrix& a) - : MArray (a.dims (), 0.0) + : FloatComplexNDArray (a.dims (), 0.0) { for (octave_idx_type i = 0; i < a.length (); i++) elem (i, i) = a.elem (i, i); @@ -310,12 +311,12 @@ // here? FloatComplexMatrix::FloatComplexMatrix (const boolMatrix& a) - : MArray (a) + : FloatComplexNDArray (a) { } FloatComplexMatrix::FloatComplexMatrix (const charMatrix& a) - : MArray (a.dims (), 0.0) + : FloatComplexNDArray (a.dims (), 0.0) { for (octave_idx_type i = 0; i < a.rows (); i++) for (octave_idx_type j = 0; j < a.cols (); j++) @@ -324,7 +325,7 @@ FloatComplexMatrix::FloatComplexMatrix (const FloatMatrix& re, const FloatMatrix& im) - : MArray (re.dims ()) + : FloatComplexNDArray (re.dims ()) { if (im.rows () != rows () || im.cols () != cols ()) (*current_liboctave_error_handler) ("complex: internal error"); diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/fCMatrix.h --- a/liboctave/array/fCMatrix.h Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/fCMatrix.h Fri Nov 07 08:15:55 2014 +0000 @@ -23,6 +23,7 @@ #if !defined (octave_fCMatrix_h) #define octave_fCMatrix_h 1 +#include "fCNDArray.h" #include "MArray.h" #include "MDiagArray2.h" #include "MatrixType.h" @@ -34,7 +35,7 @@ class OCTAVE_API -FloatComplexMatrix : public MArray +FloatComplexMatrix : public FloatComplexNDArray { public: @@ -43,31 +44,31 @@ typedef void (*solve_singularity_handler) (float rcon); - FloatComplexMatrix (void) : MArray () { } + FloatComplexMatrix (void) : FloatComplexNDArray () { } FloatComplexMatrix (octave_idx_type r, octave_idx_type c) - : MArray (dim_vector (r, c)) { } + : FloatComplexNDArray (dim_vector (r, c)) { } FloatComplexMatrix (octave_idx_type r, octave_idx_type c, const FloatComplex& val) - : MArray (dim_vector (r, c), val) { } + : FloatComplexNDArray (dim_vector (r, c), val) { } FloatComplexMatrix (const dim_vector& dv) - : MArray (dv.redim (2)) { } + : FloatComplexNDArray (dv.redim (2)) { } FloatComplexMatrix (const dim_vector& dv, const FloatComplex& val) - : MArray (dv.redim (2), val) { } + : FloatComplexNDArray (dv.redim (2), val) { } FloatComplexMatrix (const FloatComplexMatrix& a) - : MArray (a) { } + : FloatComplexNDArray (a) { } template FloatComplexMatrix (const MArray& a) - : MArray (a.as_matrix ()) { } + : FloatComplexNDArray (a.reshape (a.dims ().redim (2))) { } template FloatComplexMatrix (const Array& a) - : MArray (a.as_matrix ()) { } + : FloatComplexNDArray (a.reshape (a.dims ().redim (2))) { } explicit FloatComplexMatrix (const FloatMatrix& a); diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/fCNDArray.cc --- a/liboctave/array/fCNDArray.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/fCNDArray.cc Fri Nov 07 08:15:55 2014 +0000 @@ -826,20 +826,6 @@ return *this; } -FloatComplexMatrix -FloatComplexNDArray::matrix_value (void) const -{ - FloatComplexMatrix retval; - - if (ndims () == 2) - retval = FloatComplexMatrix (Array (*this)); - else - (*current_liboctave_error_handler) - ("invalid conversion of FloatComplexNDArray to FloatComplexMatrix"); - - return retval; -} - void FloatComplexNDArray::increment_index (Array& ra_idx, const dim_vector& dimensions, diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/fCNDArray.h --- a/liboctave/array/fCNDArray.h Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/fCNDArray.h Fri Nov 07 08:15:55 2014 +0000 @@ -24,7 +24,6 @@ #define octave_fCNDArray_h 1 #include "MArray.h" -#include "fCMatrix.h" #include "mx-defs.h" #include "mx-op-decl.h" @@ -36,8 +35,6 @@ { public: - typedef FloatComplexMatrix matrix_type; - FloatComplexNDArray (void) : MArray () { } FloatComplexNDArray (const dim_vector& dv) : MArray (dv) { } @@ -48,9 +45,6 @@ FloatComplexNDArray (const FloatComplexNDArray& a) : MArray (a) { } - FloatComplexNDArray (const FloatComplexMatrix& a) - : MArray (a) { } - template FloatComplexNDArray (const MArray& a) : MArray (a) { } @@ -129,8 +123,6 @@ FloatComplexNDArray fourierNd (void) const; FloatComplexNDArray ifourierNd (void) const; - FloatComplexMatrix matrix_value (void) const; - FloatComplexNDArray squeeze (void) const { return MArray::squeeze (); } diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/fMatrix.cc --- a/liboctave/array/fMatrix.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/fMatrix.cc Fri Nov 07 08:15:55 2014 +0000 @@ -32,6 +32,7 @@ #include #include +#include "fNDArray.h" #include "Array-util.h" #include "boolMatrix.h" #include "chMatrix.h" @@ -248,24 +249,24 @@ // Matrix class. FloatMatrix::FloatMatrix (const FloatRowVector& rv) - : MArray (rv) + : FloatNDArray (rv) { } FloatMatrix::FloatMatrix (const FloatColumnVector& cv) - : MArray (cv) + : FloatNDArray (cv) { } FloatMatrix::FloatMatrix (const FloatDiagMatrix& a) - : MArray (a.dims (), 0.0) + : FloatNDArray (a.dims (), 0.0) { for (octave_idx_type i = 0; i < a.length (); i++) elem (i, i) = a.elem (i, i); } FloatMatrix::FloatMatrix (const PermMatrix& a) - : MArray (a.dims (), 0.0) + : FloatNDArray (a.dims (), 0.0) { const Array ia (a.col_perm_vec ()); octave_idx_type len = a.rows (); @@ -276,12 +277,12 @@ // FIXME: could we use a templated mixed-type copy function here? FloatMatrix::FloatMatrix (const boolMatrix& a) - : MArray (a) + : FloatNDArray (a) { } FloatMatrix::FloatMatrix (const charMatrix& a) - : MArray (a.dims ()) + : FloatNDArray (a.dims ()) { for (octave_idx_type i = 0; i < a.rows (); i++) for (octave_idx_type j = 0; j < a.cols (); j++) diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/fMatrix.h --- a/liboctave/array/fMatrix.h Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/fMatrix.h Fri Nov 07 08:15:55 2014 +0000 @@ -23,6 +23,7 @@ #if !defined (octave_fMatrix_h) #define octave_fMatrix_h 1 +#include "fNDArray.h" #include "MArray.h" #include "MDiagArray2.h" #include "MatrixType.h" @@ -33,7 +34,7 @@ class OCTAVE_API -FloatMatrix : public MArray +FloatMatrix : public FloatNDArray { public: @@ -42,26 +43,26 @@ typedef void (*solve_singularity_handler) (float rcon); - FloatMatrix (void) : MArray () { } + FloatMatrix (void) : FloatNDArray () { } FloatMatrix (octave_idx_type r, octave_idx_type c) - : MArray (dim_vector (r, c)) { } + : FloatNDArray (dim_vector (r, c)) { } FloatMatrix (octave_idx_type r, octave_idx_type c, float val) - : MArray (dim_vector (r, c), val) { } + : FloatNDArray (dim_vector (r, c), val) { } - FloatMatrix (const dim_vector& dv) : MArray (dv.redim (2)) { } + FloatMatrix (const dim_vector& dv) : FloatNDArray (dv.redim (2)) { } FloatMatrix (const dim_vector& dv, float val) - : MArray (dv.redim (2), val) { } + : FloatNDArray (dv.redim (2), val) { } - FloatMatrix (const FloatMatrix& a) : MArray (a) { } + FloatMatrix (const FloatMatrix& a) : FloatNDArray (a) { } template - FloatMatrix (const MArray& a) : MArray (a.as_matrix ()) { } + FloatMatrix (const MArray& a) : FloatNDArray (a.as_matrix ()) { } template - FloatMatrix (const Array& a) : MArray (a.as_matrix ()) { } + FloatMatrix (const Array& a) : FloatNDArray (a.as_matrix ()) { } explicit FloatMatrix (const FloatRowVector& rv); @@ -75,7 +76,6 @@ explicit FloatMatrix (const charMatrix& a); - FloatMatrix& operator = (const FloatMatrix& a) { MArray::operator = (a); diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/fNDArray.cc --- a/liboctave/array/fNDArray.cc Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/fNDArray.cc Fri Nov 07 08:15:55 2014 +0000 @@ -812,20 +812,6 @@ return do_mx_unary_map (*this); } -FloatMatrix -FloatNDArray::matrix_value (void) const -{ - FloatMatrix retval; - - if (ndims () == 2) - retval = FloatMatrix (Array (*this)); - else - (*current_liboctave_error_handler) - ("invalid conversion of FloatNDArray to FloatMatrix"); - - return retval; -} - void FloatNDArray::increment_index (Array& ra_idx, const dim_vector& dimensions, diff -r 8b4a24081e47 -r d0c73e23a505 liboctave/array/fNDArray.h --- a/liboctave/array/fNDArray.h Mon Nov 03 22:18:29 2014 +0000 +++ b/liboctave/array/fNDArray.h Fri Nov 07 08:15:55 2014 +0000 @@ -24,7 +24,6 @@ #define octave_fNDArray_h 1 #include "MArray.h" -#include "fMatrix.h" #include "intNDArray.h" #include "mx-defs.h" @@ -37,8 +36,6 @@ { public: - typedef FloatMatrix matrix_type; - FloatNDArray (void) : MArray () { } FloatNDArray (const dim_vector& dv) : MArray (dv) { } @@ -48,8 +45,6 @@ FloatNDArray (const FloatNDArray& a) : MArray (a) { } - FloatNDArray (const FloatMatrix& a) : MArray (a) { } - template FloatNDArray (const MArray& a) : MArray (a) { } @@ -137,8 +132,6 @@ friend class FloatComplexNDArray; - FloatMatrix matrix_value (void) const; - FloatNDArray squeeze (void) const { return MArray::squeeze (); } static void increment_index (Array& ra_idx,