# HG changeset patch # User John W. Eaton # Date 1294909031 18000 # Node ID 9a308e96194ea02192fbf6fb46a2e081a9594748 # Parent 81ff63e43f54126b999753104024c077ab400603 more data member initialization fixes diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,18 @@ +2011-01-13 John W. Eaton + + * base-lu.h (base_lu::base_lu): Initialize all data members in + initialization lists. + * base-qr.h (base_qr::base_qr): Likewise. + * DET.h (base_det::base_det): Likewise. + * sparse-base-lu.h (sparse_base_lu::sparse_base_lu): Likewise. + * sparse-base-chol.h (sparse_base_chol::sparse_base_chol): Likewise. + + * base-lu.h (base_lu::~base_lu): Explicitly define virtual destrutor. + * base-qr.h (base_qr::~base_qr): Likewise. + * base-aepbal.h (base_aepbal::~base_aepval): Likewise. + * sparse-base-lu.h (sparse_base_lu::~sparse_base_lu): Likewise. + * sparse-base-chol.h (sparse_base_chol::~sparse_base_chol): Likewise. + 2011-01-13 John W. Eaton * DAE.h (DAE::~DAE): Now virtual. diff --git a/liboctave/DET.h b/liboctave/DET.h --- a/liboctave/DET.h +++ b/liboctave/DET.h @@ -33,13 +33,15 @@ { public: - base_det (T c = 1, int e = 0) + base_det (T c = 1, int e = 0) + : c2 (), e2 () { c2 = xlog2 (c, e2); e2 += e; } base_det (T c, double e, double b) + : c2 (), e2 () { e *= xlog2 (b); e2 = e; @@ -49,7 +51,7 @@ e2 += f; } - base_det (const base_det& a) : c2(a.c2), e2(a.e2) { } + base_det (const base_det& a) : c2 (a.c2), e2 (a.e2) { } base_det& operator = (const base_det& a) { diff --git a/liboctave/base-aepbal.h b/liboctave/base-aepbal.h --- a/liboctave/base-aepbal.h +++ b/liboctave/base-aepbal.h @@ -31,6 +31,7 @@ VectorT scale; octave_idx_type ilo, ihi; char job; + base_aepbal (void) : balanced_mat (), scale (), ilo (), ihi (), job () { } public: @@ -51,6 +52,8 @@ return *this; } + virtual ~base_aepbal (void) { } + MatrixT balanced_matrix (void) const { return balanced_mat; } VectorT permuting_vector (void) const diff --git a/liboctave/base-lu.h b/liboctave/base-lu.h --- a/liboctave/base-lu.h +++ b/liboctave/base-lu.h @@ -36,10 +36,11 @@ typedef typename lu_type::element_type lu_elt_type; - base_lu (void) { } + base_lu (void) + : a_fact (), l_fact (), ipvt () { } - base_lu (const base_lu& a) : - a_fact (a.a_fact), l_fact (a.l_fact), ipvt (a.ipvt) { } + base_lu (const base_lu& a) + : a_fact (a.a_fact), l_fact (a.l_fact), ipvt (a.ipvt) { } base_lu (const lu_type& l, const lu_type& u, const PermMatrix& p); @@ -55,7 +56,7 @@ return *this; } - ~base_lu (void) { } + virtual ~base_lu (void) { } bool packed (void) const; @@ -76,7 +77,10 @@ protected: Array getp (void) const; - lu_type a_fact, l_fact; + + lu_type a_fact; + lu_type l_fact; + Array ipvt; }; diff --git a/liboctave/base-qr.cc b/liboctave/base-qr.cc --- a/liboctave/base-qr.cc +++ b/liboctave/base-qr.cc @@ -28,16 +28,18 @@ template base_qr::base_qr (const qr_type& q_arg, const qr_type& r_arg) + : q (q_arg), r (r_arg) { - octave_idx_type qr = q_arg.rows (), qc = q_arg.columns (); - octave_idx_type rr = r_arg.rows (), rc = r_arg.columns (); - if (qc == rr && (qr == qc || (qr > qc && rr == rc))) + octave_idx_type q_nr = q.rows (), q_nc = q.columns (); + octave_idx_type r_nr = r.rows (), r_nc = r.columns (); + + if (! (q_nc == r_nr && (q_nr == q_nc || (q_nr > q_nc && r_nr == r_nc)))) { - q = q_arg; - r = r_arg; + q = qr_type (); + r = qr_type (); + + (*current_liboctave_error_handler) ("QR dimensions mismatch"); } - else - (*current_liboctave_error_handler) ("QR dimensions mismatch"); } template @@ -45,12 +47,14 @@ base_qr::get_type (void) const { qr_type_t retval; + if (!q.is_empty () && q.is_square ()) retval = qr_type_std; else if (q.rows () > q.columns () && r.is_square ()) retval = qr_type_economy; else retval = qr_type_raw; + return retval; } diff --git a/liboctave/base-qr.h b/liboctave/base-qr.h --- a/liboctave/base-qr.h +++ b/liboctave/base-qr.h @@ -42,12 +42,11 @@ typedef typename qr_type::element_type qr_elt_type; - base_qr (void) { } + base_qr (void) : q (), r () { } base_qr (const qr_type& q, const qr_type& r); - base_qr (const base_qr& a) : - q (a.q), r (a.r) { } + base_qr (const base_qr& a) : q (a.q), r (a.r) { } base_qr& operator = (const base_qr& a) { @@ -59,6 +58,8 @@ return *this; } + virtual ~base_qr (void) { } + qr_type Q (void) const { return q; } qr_type R (void) const { return r; } @@ -69,7 +70,8 @@ protected: - qr_type q, r; + qr_type q; + qr_type r; }; #ifndef HAVE_QRUPDATE diff --git a/liboctave/sparse-base-chol.h b/liboctave/sparse-base-chol.h --- a/liboctave/sparse-base-chol.h +++ b/liboctave/sparse-base-chol.h @@ -36,25 +36,39 @@ class sparse_base_chol_rep { public: - sparse_base_chol_rep (void) : count (1), Lsparse (0), - is_pd (false), minor_p (0) { } + sparse_base_chol_rep (void) + : count (1), Lsparse (0), Common (), is_pd (false), minor_p (0), + perms (), cond (0) + { } - sparse_base_chol_rep (const chol_type& a, - const bool natural) : count (1) - { init (a, natural); } + sparse_base_chol_rep (const chol_type& a, const bool natural) + : count (1), Lsparse (0), Common (), is_pd (false), minor_p (0), + perms (), cond (0) + { + init (a, natural); + } sparse_base_chol_rep (const chol_type& a, octave_idx_type& info, - const bool natural) : count (1) - { info = init (a, natural); } + const bool natural) + : count (1), Lsparse (0), Common (), is_pd (false), minor_p (0), + perms (), cond (0) + { + info = init (a, natural); + } ~sparse_base_chol_rep (void) - { if (is_pd) CHOLMOD_NAME(free_sparse) (&Lsparse, &Common); } + { + if (is_pd) + CHOLMOD_NAME (free_sparse) (&Lsparse, &Common); + } cholmod_sparse * L (void) const { return Lsparse; } octave_idx_type P (void) const - { return (minor_p == static_cast(Lsparse->ncol) ? - 0 : minor_p + 1); } + { + return (minor_p == static_cast(Lsparse->ncol) ? + 0 : minor_p + 1); + } ColumnVector perm (void) const { return perms + 1; } @@ -90,14 +104,17 @@ class sparse_base_chol_rep { public: - sparse_base_chol_rep (void) : count (1), is_pd (false), minor_p (0) { } + sparse_base_chol_rep (void) + : count (1), is_pd (false), minor_p (0), perms (), cond (0) { } sparse_base_chol_rep (const chol_type& a, - const bool natural) : count (1) + const bool natural) + : count (1), is_pd (false), minor_p (0), perms (), cond (0) { init (a, natural); } sparse_base_chol_rep (const chol_type& a, octave_idx_type& info, - const bool natural) : count (1) + const bool natural) + : count (1), is_pd (false), minor_p (0), perms (), cond (0) { info = init (a, natural); } ~sparse_base_chol_rep (void) { } @@ -135,21 +152,25 @@ public: - sparse_base_chol (void) : rep (new typename - sparse_base_chol::sparse_base_chol_rep ()) { } + sparse_base_chol (void) + : rep (new typename + sparse_base_chol::sparse_base_chol_rep ()) + { } - sparse_base_chol (const chol_type& a, const bool n) : rep (new typename - sparse_base_chol:: - sparse_base_chol_rep (a, n)) { } + sparse_base_chol (const chol_type& a, const bool n) + : rep (new typename + sparse_base_chol::sparse_base_chol_rep (a, n)) + { } - sparse_base_chol (const chol_type& a, octave_idx_type& info, const bool n) : - rep (new typename sparse_base_chol:: - sparse_base_chol_rep (a, info, n)) { } + sparse_base_chol (const chol_type& a, octave_idx_type& info, const bool n) + : rep (new typename sparse_base_chol::sparse_base_chol_rep (a, info, n)) + { } - sparse_base_chol (const sparse_base_chol& a) : - rep (a.rep) { rep->count++; } + sparse_base_chol (const sparse_base_chol& a) + : rep (a.rep) + { rep->count++; } - ~sparse_base_chol (void) + virtual ~sparse_base_chol (void) { if (--rep->count <= 0) delete rep; diff --git a/liboctave/sparse-base-lu.h b/liboctave/sparse-base-lu.h --- a/liboctave/sparse-base-lu.h +++ b/liboctave/sparse-base-lu.h @@ -34,10 +34,13 @@ { public: - sparse_base_lu (void) { } + sparse_base_lu (void) + : Lfact (), Ufact (), Rfact (), cond (0), P (), Q () { } sparse_base_lu (const sparse_base_lu& a) - : Lfact (a.Lfact), Ufact (a.Ufact), cond (a.cond), P (a.P), Q (a.Q) { } + : Lfact (a.Lfact), Ufact (a.Ufact), Rfact (), cond (a.cond), + P (a.P), Q (a.Q) + { } sparse_base_lu& operator = (const sparse_base_lu& a) { @@ -52,7 +55,7 @@ return *this; } - ~sparse_base_lu (void) { } + virtual ~sparse_base_lu (void) { } lu_type L (void) const { return Lfact; }