# HG changeset patch # User jwe # Date 949984547 0 # Node ID d9803711e047160d513b0ef83a4a3c154845c352 # Parent aa31644d9779128f2d3e438675483d4a136ac634 [project @ 2000-02-08 04:35:39 by jwe] diff --git a/liboctave/Array.h b/liboctave/Array.h --- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -44,7 +44,8 @@ // all the derived classes. template -class Array +class +Array { protected: @@ -64,7 +65,7 @@ ArrayRep (void) : data (0), len (0), count (1) { } - ArrayRep (int n) : data (new T [n]), len (n), count (1) { } + explicit ArrayRep (int n) : data (new T [n]), len (n), count (1) { } ArrayRep (const ArrayRep& a) : data (new T [a.len]), len (a.len), count (1) @@ -130,7 +131,7 @@ #endif } - Array (int n) + explicit Array (int n) { rep = new ArrayRep (n); diff --git a/liboctave/Array2.h b/liboctave/Array2.h --- a/liboctave/Array2.h +++ b/liboctave/Array2.h @@ -41,7 +41,8 @@ // Two dimensional array class. template -class Array2 : public Array +class +Array2 : public Array { protected: diff --git a/liboctave/Array3.h b/liboctave/Array3.h --- a/liboctave/Array3.h +++ b/liboctave/Array3.h @@ -39,7 +39,8 @@ // Three dimensional array class. template -class Array3 : public Array2 +class +Array3 : public Array2 { protected: diff --git a/liboctave/CColVector.cc b/liboctave/CColVector.cc --- a/liboctave/CColVector.cc +++ b/liboctave/CColVector.cc @@ -440,7 +440,7 @@ if (len != a_len) { gripe_nonconformant ("product", len, a_len); - return ColumnVector (); + return ComplexColumnVector (); } if (len == 0) @@ -459,7 +459,7 @@ if (len != a_len) { gripe_nonconformant ("quotient", len, a_len); - return ColumnVector (); + return ComplexColumnVector (); } if (len == 0) @@ -490,7 +490,7 @@ if (nc != a_len) { gripe_nonconformant ("operator *", nr, nc, a_len, 1); - return ColumnVector (); + return ComplexColumnVector (); } if (nc == 0 || nr == 0) diff --git a/liboctave/CColVector.h b/liboctave/CColVector.h --- a/liboctave/CColVector.h +++ b/liboctave/CColVector.h @@ -31,7 +31,8 @@ #include "mx-defs.h" -class ComplexColumnVector : public MArray +class +ComplexColumnVector : public MArray { friend class ComplexMatrix; friend class ComplexRowVector; @@ -39,11 +40,17 @@ public: ComplexColumnVector (void) : MArray () { } - ComplexColumnVector (int n) : MArray (n) { } - ComplexColumnVector (int n, const Complex& val) : MArray (n, val) { } - ComplexColumnVector (const ColumnVector& a); + + explicit ComplexColumnVector (int n) : MArray (n) { } + + ComplexColumnVector (int n, const Complex& val) + : MArray (n, val) { } + + ComplexColumnVector (const ComplexColumnVector& a) : MArray (a) { } + ComplexColumnVector (const MArray& a) : MArray (a) { } - ComplexColumnVector (const ComplexColumnVector& a) : MArray (a) { } + + explicit ComplexColumnVector (const ColumnVector& a); ComplexColumnVector& operator = (const ComplexColumnVector& a) { diff --git a/liboctave/CDiagMatrix.cc b/liboctave/CDiagMatrix.cc --- a/liboctave/CDiagMatrix.cc +++ b/liboctave/CDiagMatrix.cc @@ -287,7 +287,7 @@ if (i < 0 || i >= r) { (*current_liboctave_error_handler) ("invalid row selection"); - return RowVector (); + return ComplexRowVector (); } ComplexRowVector retval (c, 0.0); @@ -326,7 +326,7 @@ if (i < 0 || i >= c) { (*current_liboctave_error_handler) ("invalid column selection"); - return ColumnVector (); + return ComplexColumnVector (); } ComplexColumnVector retval (r, 0.0); @@ -342,7 +342,7 @@ if (! s) { (*current_liboctave_error_handler) ("invalid column selection"); - return ColumnVector (); + return ComplexColumnVector (); } char c = *s; @@ -353,7 +353,7 @@ else { (*current_liboctave_error_handler) ("invalid column selection"); - return ColumnVector (); + return ComplexColumnVector (); } } @@ -372,7 +372,7 @@ if (r != c) { (*current_liboctave_error_handler) ("inverse requires square matrix"); - return DiagMatrix (); + return ComplexDiagMatrix (); } ComplexDiagMatrix retval (r, c); diff --git a/liboctave/CDiagMatrix.h b/liboctave/CDiagMatrix.h --- a/liboctave/CDiagMatrix.h +++ b/liboctave/CDiagMatrix.h @@ -36,25 +36,37 @@ #include "mx-defs.h" -class ComplexDiagMatrix : public MDiagArray2 +class +ComplexDiagMatrix : public MDiagArray2 { public: ComplexDiagMatrix (void) : MDiagArray2 () { } + ComplexDiagMatrix (int r, int c) : MDiagArray2 (r, c) { } + ComplexDiagMatrix (int r, int c, const Complex& val) : MDiagArray2 (r, c, val) { } - ComplexDiagMatrix (const RowVector& a) + + explicit ComplexDiagMatrix (const RowVector& a) : MDiagArray2 (ComplexRowVector (a)) { } - ComplexDiagMatrix (const ComplexRowVector& a) : MDiagArray2 (a) { } - ComplexDiagMatrix (const ColumnVector& a) + + explicit ComplexDiagMatrix (const ComplexRowVector& a) + : MDiagArray2 (a) { } + + explicit ComplexDiagMatrix (const ColumnVector& a) : MDiagArray2 (ComplexColumnVector (a)) { } - ComplexDiagMatrix (const ComplexColumnVector& a) + + explicit ComplexDiagMatrix (const ComplexColumnVector& a) : MDiagArray2 (a) { } - ComplexDiagMatrix (const DiagMatrix& a); + + explicit ComplexDiagMatrix (const DiagMatrix& a); + ComplexDiagMatrix (const MDiagArray2& a) : MDiagArray2 (a) { } - ComplexDiagMatrix (const ComplexDiagMatrix& a) : MDiagArray2 (a) { } + + ComplexDiagMatrix (const ComplexDiagMatrix& a) + : MDiagArray2 (a) { } ComplexDiagMatrix& operator = (const ComplexDiagMatrix& a) { diff --git a/liboctave/CMatrix.cc b/liboctave/CMatrix.cc --- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -1350,6 +1350,34 @@ } ComplexColumnVector +ComplexMatrix::solve (const ColumnVector& b) const +{ + int info; + double rcond; + return solve (ComplexColumnVector (b), info, rcond, 0); +} + +ComplexColumnVector +ComplexMatrix::solve (const ColumnVector& b, int& info) const +{ + double rcond; + return solve (ComplexColumnVector (b), info, rcond, 0); +} + +ComplexColumnVector +ComplexMatrix::solve (const ColumnVector& b, int& info, double& rcond) const +{ + return solve (ComplexColumnVector (b), info, rcond, 0); +} + +ComplexColumnVector +ComplexMatrix::solve (const ColumnVector& b, int& info, double& rcond, + solve_singularity_handler sing_handler) const +{ + return solve (ComplexColumnVector (b), info, rcond, sing_handler); +} + +ComplexColumnVector ComplexMatrix::solve (const ComplexColumnVector& b) const { int info; @@ -1435,6 +1463,27 @@ } ComplexMatrix +ComplexMatrix::lssolve (const Matrix& b) const +{ + int info; + int rank; + return lssolve (ComplexMatrix (b), info, rank); +} + +ComplexMatrix +ComplexMatrix::lssolve (const Matrix& b, int& info) const +{ + int rank; + return lssolve (ComplexMatrix (b), info, rank); +} + +ComplexMatrix +ComplexMatrix::lssolve (const Matrix& b, int& info, int& rank) const +{ + return lssolve (ComplexMatrix (b), info, rank); +} + +ComplexMatrix ComplexMatrix::lssolve (const ComplexMatrix& b) const { int info; @@ -1517,6 +1566,27 @@ } ComplexColumnVector +ComplexMatrix::lssolve (const ColumnVector& b) const +{ + int info; + int rank; + return lssolve (ComplexColumnVector (b), info, rank); +} + +ComplexColumnVector +ComplexMatrix::lssolve (const ColumnVector& b, int& info) const +{ + int rank; + return lssolve (ComplexColumnVector (b), info, rank); +} + +ComplexColumnVector +ComplexMatrix::lssolve (const ColumnVector& b, int& info, int& rank) const +{ + return lssolve (ComplexColumnVector (b), info, rank); +} + +ComplexColumnVector ComplexMatrix::lssolve (const ComplexColumnVector& b) const { int info; diff --git a/liboctave/CMatrix.h b/liboctave/CMatrix.h --- a/liboctave/CMatrix.h +++ b/liboctave/CMatrix.h @@ -34,29 +34,41 @@ #include "mx-op-defs.h" #include "oct-cmplx.h" -class ComplexMatrix : public MArray2 +class +ComplexMatrix : public MArray2 { public: typedef void (*solve_singularity_handler) (double rcond); ComplexMatrix (void) : MArray2 () { } + ComplexMatrix (int r, int c) : MArray2 (r, c) { } + ComplexMatrix (int r, int c, const Complex& val) : MArray2 (r, c, val) { } - ComplexMatrix (const Matrix& a); - ComplexMatrix (const MArray2& a) : MArray2 (a) { } + ComplexMatrix (const ComplexMatrix& a) : MArray2 (a) { } - ComplexMatrix (const RowVector& rv); - ComplexMatrix (const ColumnVector& cv); - ComplexMatrix (const DiagMatrix& a); - // ComplexMatrix (const MDiagArray2& a) : MArray2 (a) { } - ComplexMatrix (const ComplexRowVector& rv); - ComplexMatrix (const ComplexColumnVector& cv); - ComplexMatrix (const ComplexDiagMatrix& a); + + ComplexMatrix (const MArray2& a) : MArray2 (a) { } + + explicit ComplexMatrix (const Matrix& a); + + explicit ComplexMatrix (const RowVector& rv); + + explicit ComplexMatrix (const ColumnVector& cv); - ComplexMatrix (const boolMatrix& a); - ComplexMatrix (const charMatrix& a); + explicit ComplexMatrix (const DiagMatrix& a); + + explicit ComplexMatrix (const ComplexRowVector& rv); + + explicit ComplexMatrix (const ComplexColumnVector& cv); + + explicit ComplexMatrix (const ComplexDiagMatrix& a); + + explicit ComplexMatrix (const boolMatrix& a); + + explicit ComplexMatrix (const charMatrix& a); ComplexMatrix& operator = (const ComplexMatrix& a) { @@ -152,6 +164,13 @@ ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond, solve_singularity_handler sing_handler) const; + ComplexColumnVector solve (const ColumnVector& b) const; + ComplexColumnVector solve (const ColumnVector& b, int& info) const; + ComplexColumnVector solve (const ColumnVector& b, int& info, + double& rcond) const; + ComplexColumnVector solve (const ColumnVector& b, int& info, double& rcond, + solve_singularity_handler sing_handler) const; + ComplexColumnVector solve (const ComplexColumnVector& b) const; ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const; ComplexColumnVector solve (const ComplexColumnVector& b, int& info, @@ -160,11 +179,20 @@ double& rcond, solve_singularity_handler sing_handler) const; + ComplexMatrix lssolve (const Matrix& b) const; + ComplexMatrix lssolve (const Matrix& b, int& info) const; + ComplexMatrix lssolve (const Matrix& b, int& info, int& rank) const; + ComplexMatrix lssolve (const ComplexMatrix& b) const; ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const; ComplexMatrix lssolve (const ComplexMatrix& b, int& info, int& rank) const; + ComplexColumnVector lssolve (const ColumnVector& b) const; + ComplexColumnVector lssolve (const ColumnVector& b, int& info) const; + ComplexColumnVector lssolve (const ColumnVector& b, int& info, + int& rank) const; + ComplexColumnVector lssolve (const ComplexColumnVector& b) const; ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const; ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info, diff --git a/liboctave/CRowVector.h b/liboctave/CRowVector.h --- a/liboctave/CRowVector.h +++ b/liboctave/CRowVector.h @@ -31,18 +31,24 @@ #include "mx-defs.h" -class ComplexRowVector : public MArray +class +ComplexRowVector : public MArray { friend class ComplexColumnVector; public: ComplexRowVector (void) : MArray () { } - ComplexRowVector (int n) : MArray (n) { } + + explicit ComplexRowVector (int n) : MArray (n) { } + ComplexRowVector (int n, const Complex& val) : MArray (n, val) { } - ComplexRowVector (const RowVector& a); + + ComplexRowVector (const ComplexRowVector& a) : MArray (a) { } + ComplexRowVector (const MArray& a) : MArray (a) { } - ComplexRowVector (const ComplexRowVector& a) : MArray (a) { } + + explicit ComplexRowVector (const RowVector& a); ComplexRowVector& operator = (const ComplexRowVector& a) { diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,33 @@ +2000-02-07 John W. Eaton + + * CMatrix.h, CMatrix.cc: Add lssolve methods for real-valued RHS + matrix and vector objects. + + * mx-op-defs.h (DMM_BIN_OP): Explicitly request conversion to + return type from second arg type. + (MDM_BIN_OP): Likewise, for first arg type. + + * dMatrix.cc (Matrix::fourier, Matrix::ifourier, + Matrix::fourier2d, Matrix::ifourier2d): Likewise. + + * EIG.cc (EIG::symmetric_init, EIG::hermitian_init): Explicitly + request ColumnVector to ComplexColumnVector, and Matrix to + ComplexMatrix conversions. + + * CmplxAEPBAL.cc (ComplexAEPBALANCE::init): Give balancing_mat its + initial value using ComplexMatrix constructor. + + * CColVector.cc (product, quotient, + operator * (const DiagMatrix&, const ComplexColumnVetor&)): + Fix type of returned value. + * CDiagMatrix.cc (ComplexDiagMatrix::row, + ComplexDiagMatrix::column, ComplexDiagMatrix::inverse): Likewise. + + * Array.h, CColVector.h, CDiagMatrix.h, CMatrix.h, CRowVector.h, + MArray.h, MDiagArray2.h, dColVector.h, dDiagMatrix.h, dMatrix.h, + dRowVector.h: Declare some constructors explicit, to disallow + potentially problematic automatic type conversions. + 2000-02-05 John W. Eaton * vx-rv-crv.h, vx-cv-ccv.h, vx-crv-rv.h, vx-ccv-cv.h, diff --git a/liboctave/CmplxAEPBAL.cc b/liboctave/CmplxAEPBAL.cc --- a/liboctave/CmplxAEPBAL.cc +++ b/liboctave/CmplxAEPBAL.cc @@ -77,7 +77,7 @@ (*current_liboctave_error_handler) ("unrecoverable error in zgebal"); else { - balancing_mat = Matrix (n, n, 0.0); + balancing_mat = ComplexMatrix (n, n, 0.0); for (int i = 0; i < n; i++) balancing_mat.elem (i, i) = 1.0; diff --git a/liboctave/DiagArray2.h b/liboctave/DiagArray2.h --- a/liboctave/DiagArray2.h +++ b/liboctave/DiagArray2.h @@ -50,7 +50,8 @@ // GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France template -class DiagArray2 : public Array +class +DiagArray2 : public Array { private: diff --git a/liboctave/EIG.cc b/liboctave/EIG.cc --- a/liboctave/EIG.cc +++ b/liboctave/EIG.cc @@ -160,7 +160,7 @@ Matrix atmp = a; double *tmp_data = atmp.fortran_vec (); - Array wr (n); + ColumnVector wr (n); double *pwr = wr.fortran_vec (); // XXX FIXME XXX -- it might be possible to choose a better value of @@ -175,19 +175,12 @@ if (f77_exception_encountered || info < 0) (*current_liboctave_error_handler) ("unrecoverable error in dsyev"); + else if (info > 0) + (*current_liboctave_error_handler) ("dsyev failed to converge"); else { - if (info > 0) - (*current_liboctave_error_handler) ("dsyev failed to converge"); - else - { - lambda.resize (n); - - for (int j = 0; j < n; j++) - lambda.elem (j) = Complex (wr.elem (j)); - - v = atmp; - } + lambda = ComplexColumnVector (wr); + v = ComplexMatrix (atmp); } return info; @@ -264,8 +257,8 @@ ComplexMatrix atmp = a; Complex *tmp_data = atmp.fortran_vec (); - ColumnVector w (n); - double *pw = w.fortran_vec (); + ColumnVector wr (n); + double *pwr = wr.fortran_vec (); // XXX FIXME XXX -- it might be possible to choose a better value of // lwork that would result in more efficient computations. @@ -278,7 +271,7 @@ Array rwork (lrwork); double *prwork = rwork.fortran_vec (); - F77_XFCN (zheev, ZHEEV, ("V", "U", n, tmp_data, n, pw, pwork, + F77_XFCN (zheev, ZHEEV, ("V", "U", n, tmp_data, n, pwr, pwork, lwork, prwork, info, 1L, 1L)); if (f77_exception_encountered || info < 0) @@ -287,8 +280,8 @@ (*current_liboctave_error_handler) ("zheev failed to converge"); else { - lambda = w; - v = atmp; + lambda = ComplexColumnVector (wr); + v = ComplexMatrix (atmp); } return info; diff --git a/liboctave/LP.h b/liboctave/LP.h --- a/liboctave/LP.h +++ b/liboctave/LP.h @@ -28,7 +28,8 @@ #include "LinConst.h" #include "base-min.h" -class LP : public base_minimizer +class +LP : public base_minimizer { public: diff --git a/liboctave/MArray.h b/liboctave/MArray.h --- a/liboctave/MArray.h +++ b/liboctave/MArray.h @@ -39,7 +39,8 @@ MARRAY_OPS_FORWARD_DECLS (MArray) template -class MArray : public Array +class +MArray : public Array { protected: @@ -48,10 +49,14 @@ public: MArray (void) : Array () { } - MArray (int n) : Array (n) { } + + explicit MArray (int n) : Array (n) { } + MArray (int n, const T& val) : Array (n, val) { } + + MArray (const MArray& a) : Array (a) { } + MArray (const Array& a) : Array (a) { } - MArray (const MArray& a) : Array (a) { } ~MArray (void) { } diff --git a/liboctave/MArray2.h b/liboctave/MArray2.h --- a/liboctave/MArray2.h +++ b/liboctave/MArray2.h @@ -39,7 +39,8 @@ MARRAY_OPS_FORWARD_DECLS (MArray2) template -class MArray2 : public Array2 +class +MArray2 : public Array2 { protected: @@ -48,10 +49,14 @@ public: MArray2 (void) : Array2 () { } + MArray2 (int n, int m) : Array2 (n, m) { } + MArray2 (int n, int m, const T& val) : Array2 (n, m, val) { } + + MArray2 (const MArray2& a) : Array2 (a) { } + MArray2 (const Array2& a) : Array2 (a) { } - MArray2 (const MArray2& a) : Array2 (a) { } ~MArray2 (void) { } diff --git a/liboctave/MDiagArray2.h b/liboctave/MDiagArray2.h --- a/liboctave/MDiagArray2.h +++ b/liboctave/MDiagArray2.h @@ -40,7 +40,8 @@ MDIAGARRAY2_OPS_FORWARD_DECLS (MDiagArray2) template -class MDiagArray2 : public DiagArray2 +class +MDiagArray2 : public DiagArray2 { protected: @@ -49,11 +50,16 @@ public: MDiagArray2 (void) : DiagArray2 () { } + MDiagArray2 (int r, int c) : DiagArray2 (r, c) { } + MDiagArray2 (int r, int c, const T& val) : DiagArray2 (r, c, val) { } - MDiagArray2 (const Array& a) : DiagArray2 (a) { } + + MDiagArray2 (const MDiagArray2& a) : DiagArray2 (a) { } + MDiagArray2 (const DiagArray2& a) : DiagArray2 (a) { } - MDiagArray2 (const MDiagArray2& a) : DiagArray2 (a) { } + + explicit MDiagArray2 (const Array& a) : DiagArray2 (a) { } ~MDiagArray2 (void) { } diff --git a/liboctave/base-lu.h b/liboctave/base-lu.h --- a/liboctave/base-lu.h +++ b/liboctave/base-lu.h @@ -30,7 +30,8 @@ #include "MArray.h" template -class base_lu +class +base_lu { public: diff --git a/liboctave/dColVector.h b/liboctave/dColVector.h --- a/liboctave/dColVector.h +++ b/liboctave/dColVector.h @@ -31,15 +31,20 @@ #include "mx-defs.h" -class ColumnVector : public MArray +class +ColumnVector : public MArray { public: ColumnVector (void) : MArray () { } - ColumnVector (int n) : MArray (n) { } + + explicit ColumnVector (int n) : MArray (n) { } + ColumnVector (int n, double val) : MArray (n, val) { } + + ColumnVector (const ColumnVector& a) : MArray (a) { } + ColumnVector (const MArray& a) : MArray (a) { } - ColumnVector (const ColumnVector& a) : MArray (a) { } ColumnVector& operator = (const ColumnVector& a) { diff --git a/liboctave/dDiagMatrix.h b/liboctave/dDiagMatrix.h --- a/liboctave/dDiagMatrix.h +++ b/liboctave/dDiagMatrix.h @@ -34,7 +34,8 @@ #include "mx-defs.h" -class DiagMatrix : public MDiagArray2 +class +DiagMatrix : public MDiagArray2 { friend class SVD; friend class ComplexSVD; @@ -42,12 +43,18 @@ public: DiagMatrix (void) : MDiagArray2 () { } + DiagMatrix (int r, int c) : MDiagArray2 (r, c) { } + DiagMatrix (int r, int c, double val) : MDiagArray2 (r, c, val) { } - DiagMatrix (const RowVector& a) : MDiagArray2 (a) { } - DiagMatrix (const ColumnVector& a) : MDiagArray2 (a) { } + + DiagMatrix (const DiagMatrix& a) : MDiagArray2 (a) { } + DiagMatrix (const MDiagArray2& a) : MDiagArray2 (a) { } - DiagMatrix (const DiagMatrix& a) : MDiagArray2 (a) { } + + explicit DiagMatrix (const RowVector& a) : MDiagArray2 (a) { } + + explicit DiagMatrix (const ColumnVector& a) : MDiagArray2 (a) { } DiagMatrix& operator = (const DiagMatrix& a) { diff --git a/liboctave/dMatrix.cc b/liboctave/dMatrix.cc --- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -672,7 +672,7 @@ Array wsave (nn); Complex *pwsave = wsave.fortran_vec (); - retval = *this; + retval = ComplexMatrix (*this); Complex *tmp_data = retval.fortran_vec (); F77_FCN (cffti, CFFTI) (npts, pwsave); @@ -709,7 +709,7 @@ Array wsave (nn); Complex *pwsave = wsave.fortran_vec (); - retval = *this; + retval = ComplexMatrix (*this); Complex *tmp_data = retval.fortran_vec (); F77_FCN (cffti, CFFTI) (npts, pwsave); @@ -749,7 +749,7 @@ Array wsave (nn); Complex *pwsave = wsave.fortran_vec (); - retval = *this; + retval = ComplexMatrix (*this); Complex *tmp_data = retval.fortran_vec (); F77_FCN (cffti, CFFTI) (npts, pwsave); @@ -809,7 +809,7 @@ Array wsave (nn); Complex *pwsave = wsave.fortran_vec (); - retval = *this; + retval = ComplexMatrix (*this); Complex *tmp_data = retval.fortran_vec (); F77_FCN (cffti, CFFTI) (npts, pwsave); diff --git a/liboctave/dMatrix.h b/liboctave/dMatrix.h --- a/liboctave/dMatrix.h +++ b/liboctave/dMatrix.h @@ -36,24 +36,32 @@ #include "data-conv.h" #include "mach-info.h" -class Matrix : public MArray2 +class +Matrix : public MArray2 { public: typedef void (*solve_singularity_handler) (double rcond); Matrix (void) : MArray2 () { } + Matrix (int r, int c) : MArray2 (r, c) { } + Matrix (int r, int c, double val) : MArray2 (r, c, val) { } - Matrix (const MArray2& a) : MArray2 (a) { } + Matrix (const Matrix& a) : MArray2 (a) { } - Matrix (const RowVector& rv); - Matrix (const ColumnVector& cv); - // Matrix (const MDiagArray2& a) : MArray2 (a) { } - Matrix (const DiagMatrix& a); + + Matrix (const MArray2& a) : MArray2 (a) { } + + explicit Matrix (const RowVector& rv); - Matrix (const boolMatrix& a); - Matrix (const charMatrix& a); + explicit Matrix (const ColumnVector& cv); + + explicit Matrix (const DiagMatrix& a); + + explicit Matrix (const boolMatrix& a); + + explicit Matrix (const charMatrix& a); Matrix& operator = (const Matrix& a) { diff --git a/liboctave/dRowVector.h b/liboctave/dRowVector.h --- a/liboctave/dRowVector.h +++ b/liboctave/dRowVector.h @@ -31,15 +31,20 @@ #include "mx-defs.h" -class RowVector : public MArray +class +RowVector : public MArray { public: RowVector (void) : MArray () { } - RowVector (int n) : MArray (n) { } + + explicit RowVector (int n) : MArray (n) { } + RowVector (int n, double val) : MArray (n, val) { } + + RowVector (const RowVector& a) : MArray (a) { } + RowVector (const MArray& a) : MArray (a) { } - RowVector (const RowVector& a) : MArray (a) { } RowVector& operator = (const RowVector& a) { diff --git a/liboctave/mx-op-defs.h b/liboctave/mx-op-defs.h --- a/liboctave/mx-op-defs.h +++ b/liboctave/mx-op-defs.h @@ -569,7 +569,7 @@ \ if (m_nr > 0 && m_nc > 0) \ { \ - r = m; \ + r = R (m); \ \ int len = dm.length (); \ \ @@ -630,14 +630,12 @@ // diagonal matrix by matrix operations. -// XXX FIXME XXX -- DM - M will not give the correct result. - #define DMM_BIN_OP_DECLS(R, DM, M) \ BIN_OP_DECL (R, operator +, DM, M); \ BIN_OP_DECL (R, operator -, DM, M); \ BIN_OP_DECL (R, operator *, DM, M); -#define DMM_BIN_OP(R, OP, DM, M, OPEQ) \ +#define DMM_BIN_OP(R, OP, DM, M, OPEQ, PREOP) \ R \ OP (const DM& dm, const M& m) \ { \ @@ -655,7 +653,7 @@ { \ if (m_nr > 0 && m_nc > 0) \ { \ - r = m; \ + r = R (PREOP m); \ \ int len = dm.length (); \ \ @@ -709,9 +707,9 @@ } #define DMM_BIN_OPS(R, DM, M, ZERO) \ - DMM_BIN_OP (R, operator +, DM, M, +=) \ - DMM_BIN_OP (R, operator -, DM, M, -=) \ - DMM_MULTIPLY_OP(R, DM, M, ZERO) + DMM_BIN_OP (R, operator +, DM, M, +=, ) \ + DMM_BIN_OP (R, operator -, DM, M, +=, -) \ + DMM_MULTIPLY_OP (R, DM, M, ZERO) #define DMM_OP_DECLS(R, DM, M) \ DMM_BIN_OP_DECLS(R, DM, M) diff --git a/liboctave/str-vec.h b/liboctave/str-vec.h --- a/liboctave/str-vec.h +++ b/liboctave/str-vec.h @@ -44,7 +44,7 @@ string_vector (void) : Array () { } - string_vector (int n) : Array (n) { } + explicit string_vector (int n) : Array (n) { } string_vector (const char *s) : Array (1, s) { } diff --git a/src/BaseSLList.h b/src/BaseSLList.h --- a/src/BaseSLList.h +++ b/src/BaseSLList.h @@ -36,7 +36,9 @@ void *item() {return (void*)(this+1);} // Return ((SLNode*)this)->hd }; -class BaseSLList { +class +BaseSLList +{ protected: BaseSLNode *last; virtual void delete_node(BaseSLNode*node) = 0; diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2000-02-07 John W. Eaton + * error.cc (panic): Turn off buffering of error messages. + Don't call flush_octave_stdout here, verror will do it for us. + (verror): Don't call flush_octave_stdout if buffering error messages. + * pt-except.cc (tree_try_catch_command::eval): Only restore buffer_error_message value (by running the unwind_protect element for it) if it has been saved. diff --git a/src/DLList.h b/src/DLList.h --- a/src/DLList.h +++ b/src/DLList.h @@ -35,7 +35,8 @@ }; template -class DLNode : public BaseDLNode +class +DLNode : public BaseDLNode { public: T hd; @@ -45,7 +46,9 @@ ~DLNode() { } }; -class BaseDLList { +class +BaseDLList +{ protected: BaseDLNode *h; @@ -79,7 +82,9 @@ }; template -class DLList : public BaseDLList { +class +DLList : public BaseDLList +{ //friend class DLListTrav; virtual void delete_node(BaseDLNode *node) { delete (DLNode*)node; } diff --git a/src/Map.h b/src/Map.h --- a/src/Map.h +++ b/src/Map.h @@ -45,7 +45,8 @@ #include template -class Map +class +Map { protected: int count; @@ -112,7 +113,8 @@ #endif template -class CHMap : public Map +class +CHMap : public Map { protected: CHNode **tab; diff --git a/src/SLList.h b/src/SLList.h --- a/src/SLList.h +++ b/src/SLList.h @@ -28,7 +28,8 @@ #include "BaseSLList.h" template -class SLNode : public BaseSLNode +class +SLNode : public BaseSLNode { public: T hd; // Data part of node @@ -39,7 +40,8 @@ }; template -class SLList : public BaseSLList +class +SLList : public BaseSLList { private: virtual void delete_node(BaseSLNode *node) { delete (SLNode*)node; } diff --git a/src/error.cc b/src/error.cc --- a/src/error.cc +++ b/src/error.cc @@ -82,7 +82,8 @@ static void verror (const char *name, const char *fmt, va_list args) { - flush_octave_stdout (); + if (! buffer_error_messages) + flush_octave_stdout (); bool to_beep_or_not_to_beep_p = Vbeep_on_error && ! error_state; @@ -222,10 +223,9 @@ void panic (const char *fmt, ...) { - flush_octave_stdout (); - va_list args; va_start (args, fmt); + buffer_error_messages = false; verror ("panic", fmt, args); va_end (args); abort (); diff --git a/src/lex.h b/src/lex.h --- a/src/lex.h +++ b/src/lex.h @@ -112,7 +112,8 @@ // For communication between the lexer and parser. -class lexical_feedback +class +lexical_feedback { public: diff --git a/src/pt-except.cc b/src/pt-except.cc --- a/src/pt-except.cc +++ b/src/pt-except.cc @@ -102,6 +102,9 @@ // For restoring buffer_error_messages. if (catch_code) unwind_protect::run (); + + // Also clear the frame marker. + unwind_protect::discard (); } } diff --git a/src/xpow.cc b/src/xpow.cc --- a/src/xpow.cc +++ b/src/xpow.cc @@ -33,6 +33,7 @@ #include "EIG.h" #include "dDiagMatrix.h" #include "dMatrix.h" +#include "mx-cm-cdm.h" #include "oct-cmplx.h" #include "error.h"