Mercurial > hg > octave-lojdl
changeset 1528:dc527156c38c
[project @ 1995-10-05 01:44:18 by jwe]
line wrap: on
line diff
--- a/liboctave/Bounds.cc +++ b/liboctave/Bounds.cc @@ -42,20 +42,6 @@ (*current_liboctave_error_handler) ("fatal bounds error: ", msg); } -Bounds::Bounds (void) -{ - nb = 0; -} - -Bounds::Bounds (int n) -{ - nb = n; - lb.resize (nb); - ub.resize (nb); - lb.fill (0.0); - ub.fill (0.0); -} - Bounds::Bounds (const ColumnVector l, const ColumnVector u) { if (l.capacity () != u.capacity ()) @@ -69,81 +55,6 @@ ub = u; } -Bounds::Bounds (const Bounds& a) -{ - nb = a.size (); - lb = a.lower_bounds (); - ub = a.upper_bounds (); -} - -Bounds& -Bounds::operator = (const Bounds& a) -{ - nb = a.size (); - lb = a.lower_bounds (); - ub = a.upper_bounds (); - - return *this; -} - -Bounds& -Bounds::resize (int n) -{ - nb = n; - lb.resize (nb); - ub.resize (nb); - - return *this; -} - -double -Bounds::lower_bound (int index) const -{ - return lb.elem (index); -} - -double -Bounds::upper_bound (int index) const -{ - return ub.elem (index); -} - -ColumnVector -Bounds::lower_bounds (void) const -{ - return lb; -} - -ColumnVector -Bounds::upper_bounds (void) const -{ - return ub; -} - -int -Bounds::size (void) const -{ - return nb; -} - -Bounds& -Bounds::set_bound (int index, double low, double high) -{ - lb.elem (index) = low; - ub.elem (index) = high; - - return *this; -} - -Bounds& -Bounds::set_bounds (double low, double high) -{ - lb.fill (low); - ub.fill (high); - - return *this; -} - Bounds& Bounds::set_bounds (const ColumnVector l, const ColumnVector u) { @@ -161,38 +72,6 @@ } Bounds& -Bounds::set_lower_bound (int index, double low) -{ - lb.elem (index) = low; - - return *this; -} - -Bounds& -Bounds::set_upper_bound (int index, double high) -{ - ub.elem (index) = high; - - return *this; -} - -Bounds& -Bounds::set_lower_bounds (double low) -{ - lb.fill (low); - - return *this; -} - -Bounds& -Bounds::set_upper_bounds (double high) -{ - ub.fill (high); - - return *this; -} - -Bounds& Bounds::set_lower_bounds (const ColumnVector l) { if (nb != l.capacity ())
--- a/liboctave/Bounds.h +++ b/liboctave/Bounds.h @@ -32,51 +32,98 @@ #include "dColVector.h" -#ifndef Vector -#define Vector ColumnVector -#endif - class Bounds { public: - Bounds (void); - Bounds (int n); - Bounds (const Vector lb, const Vector ub); - Bounds (const Bounds& a); + Bounds (void) { nb = 0; } + + Bounds (int n) : lb (nb, 0.0), ub (nb, 0.0) { nb = n; } + + Bounds (const ColumnVector lb, const ColumnVector ub); - Bounds& operator = (const Bounds& a); + Bounds (const Bounds& a) + { + nb = a.size (); + lb = a.lower_bounds (); + ub = a.upper_bounds (); + } + + Bounds& operator = (const Bounds& a) + { + nb = a.size (); + lb = a.lower_bounds (); + ub = a.upper_bounds (); - Bounds& resize (int n); + return *this; + } + + Bounds& resize (int n) + { + nb = n; + lb.resize (nb); + ub.resize (nb); - double lower_bound (int index) const; - double upper_bound (int index) const; + return *this; + } - Vector lower_bounds (void) const; - Vector upper_bounds (void) const; + double lower_bound (int index) const { return lb.elem (index); } + double upper_bound (int index) const { return ub.elem (index); } + + ColumnVector lower_bounds (void) const { return lb; } + ColumnVector upper_bounds (void) const { return ub; } + + int size (void) const { return nb; } - int size (void) const; + Bounds& set_bound (int index, double low, double high) + { + lb.elem (index) = low; + ub.elem (index) = high; + return *this; + } - Bounds& set_bound (int index, double low, double high); + Bounds& set_bounds (double low, double high) + { + lb.fill (low); + ub.fill (high); + return *this; + } - Bounds& set_bounds (double low, double high); - Bounds& set_bounds (const Vector lb, const Vector ub); + Bounds& set_bounds (const ColumnVector lb, const ColumnVector ub); - Bounds& set_lower_bound (int index, double low); - Bounds& set_upper_bound (int index, double high); + Bounds& set_lower_bound (int index, double low) + { + lb.elem (index) = low; + return *this; + } + + Bounds& set_upper_bound (int index, double high) + { + ub.elem (index) = high; + return *this; + } - Bounds& set_lower_bounds (double low); - Bounds& set_upper_bounds (double high); + Bounds& set_lower_bounds (double low) + { + lb.fill (low); + return *this; + } - Bounds& set_lower_bounds (const Vector lb); - Bounds& set_upper_bounds (const Vector ub); + Bounds& set_upper_bounds (double high) + { + ub.fill (high); + return *this; + } + + Bounds& set_lower_bounds (const ColumnVector lb); + Bounds& set_upper_bounds (const ColumnVector ub); friend ostream& operator << (ostream& os, const Bounds& b); protected: - Vector lb; - Vector ub; + ColumnVector lb; + ColumnVector ub; int nb;
--- a/liboctave/CmplxAEPBAL.h +++ b/liboctave/CmplxAEPBAL.h @@ -38,12 +38,30 @@ public: - ComplexAEPBALANCE (void) {} - ComplexAEPBALANCE (const ComplexMatrix& a, const char *balance_job); - ComplexAEPBALANCE (const ComplexAEPBALANCE& a); - ComplexAEPBALANCE& operator = (const ComplexAEPBALANCE& a); - ComplexMatrix balanced_matrix (void) const; - ComplexMatrix balancing_matrix (void) const; + ComplexAEPBALANCE (void) { } + + ComplexAEPBALANCE (const ComplexMatrix& a, const char * balance_job) + { + init (a, balance_job); + } + + ComplexAEPBALANCE (const ComplexAEPBALANCE& a) + { + balanced_mat = a.balanced_mat; + balancing_mat = a.balancing_mat; + } + + ComplexAEPBALANCE& operator = (const ComplexAEPBALANCE& a) + { + balanced_mat = a.balanced_mat; + balancing_mat = a.balancing_mat; + + return *this; + } + + ComplexMatrix balanced_matrix (void) const { return balanced_mat; } + + ComplexMatrix balancing_matrix (void) const { return balancing_mat; } friend ostream& operator << (ostream& os, const ComplexAEPBALANCE& a); @@ -55,37 +73,6 @@ ComplexMatrix balancing_mat; }; -inline ComplexAEPBALANCE::ComplexAEPBALANCE (const ComplexMatrix& a, - const char * balance_job) -{ - init (a, balance_job); -} - -inline ComplexAEPBALANCE::ComplexAEPBALANCE (const ComplexAEPBALANCE& a) -{ - balanced_mat = a.balanced_mat; - balancing_mat = a.balancing_mat; -} - -inline ComplexAEPBALANCE& -ComplexAEPBALANCE::operator = (const ComplexAEPBALANCE& a) -{ - balanced_mat = a.balanced_mat; - balancing_mat = a.balancing_mat; - - return *this; -} - -inline ComplexMatrix ComplexAEPBALANCE::balanced_matrix (void) const -{ - return balanced_mat; -} - -inline ComplexMatrix ComplexAEPBALANCE::balancing_matrix (void) const -{ - return balancing_mat; -} - #endif /*
--- a/liboctave/CmplxCHOL.h +++ b/liboctave/CmplxCHOL.h @@ -38,12 +38,31 @@ public: - ComplexCHOL (void) {} - ComplexCHOL (const ComplexMatrix& a); - ComplexCHOL (const ComplexMatrix& a, int& info); - ComplexCHOL (const ComplexCHOL& a); - ComplexCHOL& operator = (const ComplexCHOL& a); - ComplexMatrix chol_matrix (void) const; + ComplexCHOL (void) { } + + ComplexCHOL::ComplexCHOL (const ComplexMatrix& a) { init (a); } + + ComplexCHOL::ComplexCHOL (const ComplexMatrix& a, int& info) + { + info = init (a); + } + + ComplexCHOL::ComplexCHOL (const ComplexCHOL& a) + { + chol_mat = a.chol_mat; + } + + ComplexCHOL& ComplexCHOL::operator = (const ComplexCHOL& a) + { + chol_mat = a.chol_mat; + + return *this; + } + + ComplexMatrix ComplexCHOL::chol_matrix (void) const + { + return chol_mat; + } friend ostream& operator << (ostream& os, const ComplexCHOL& a); @@ -54,34 +73,6 @@ ComplexMatrix chol_mat; }; -inline ComplexCHOL::ComplexCHOL (const ComplexMatrix& a) -{ - init (a); -} - -inline ComplexCHOL::ComplexCHOL (const ComplexMatrix& a, int& info) -{ - info = init (a); -} - -inline ComplexCHOL::ComplexCHOL (const ComplexCHOL& a) -{ - chol_mat = a.chol_mat; -} - -inline ComplexCHOL& -ComplexCHOL::operator = (const ComplexCHOL& a) -{ - chol_mat = a.chol_mat; - - return *this; -} - -inline ComplexMatrix ComplexCHOL::chol_matrix (void) const -{ - return chol_mat; -} - #endif /*
--- a/liboctave/CmplxDET.h +++ b/liboctave/CmplxDET.h @@ -38,50 +38,44 @@ public: - ComplexDET (void); + ComplexDET (void) { } + + ComplexDET (const ComplexDET& a) + { + det[0] = a.det[0]; + det[1] = a.det[1]; + } - ComplexDET (const ComplexDET& a); + ComplexDET& operator = (const ComplexDET& a) + { + det[0] = a.det[0]; + det[1] = a.det[1]; - ComplexDET& operator = (const ComplexDET& a); + return *this; + } int value_will_overflow (void) const; int value_will_underflow (void) const; + Complex coefficient (void) const; + int exponent (void) const; + Complex value (void) const; friend ostream& operator << (ostream& os, const ComplexDET& a); private: - ComplexDET (const Complex *d); + ComplexDET (const Complex *d) + { + det[0] = d[0]; + det[1] = d[1]; + } Complex det [2]; }; -inline ComplexDET::ComplexDET (void) -{ -} - -inline ComplexDET::ComplexDET (const ComplexDET& a) -{ - det[0] = a.det[0]; - det[1] = a.det[1]; -} - -inline ComplexDET& ComplexDET::operator = (const ComplexDET& a) -{ - det[0] = a.det[0]; - det[1] = a.det[1]; - return *this; -} - -inline ComplexDET::ComplexDET (const Complex *d) -{ - det[0] = d[0]; - det[1] = d[1]; -} - #endif /*
--- a/liboctave/CmplxHESS.h +++ b/liboctave/CmplxHESS.h @@ -38,13 +38,32 @@ public: - ComplexHESS (void) {} - ComplexHESS (const ComplexMatrix& a); - ComplexHESS (const ComplexMatrix& a, int& info); - ComplexHESS (const ComplexHESS& a); - ComplexHESS& operator = (const ComplexHESS& a); - ComplexMatrix hess_matrix (void) const; - ComplexMatrix unitary_hess_matrix (void) const; + ComplexHESS (void) { } + + ComplexHESS (const ComplexMatrix& a) { init (a); } + + ComplexHESS (const ComplexMatrix& a, int& info) { info = init (a); } + + ComplexHESS (const ComplexHESS& a) + { + hess_mat = a.hess_mat; + unitary_hess_mat = a.unitary_hess_mat; + } + + ComplexHESS& operator = (const ComplexHESS& a) + { + hess_mat = a.hess_mat; + unitary_hess_mat = a.unitary_hess_mat; + + return *this; + } + + ComplexMatrix hess_matrix (void) const { return hess_mat; } + + ComplexMatrix unitary_hess_matrix (void) const + { + return unitary_hess_mat; + } friend ostream& operator << (ostream& os, const ComplexHESS& a); @@ -56,41 +75,6 @@ ComplexMatrix unitary_hess_mat; }; -inline ComplexHESS::ComplexHESS (const ComplexMatrix& a) -{ - init (a); -} - -inline ComplexHESS::ComplexHESS (const ComplexMatrix& a, int& info) -{ - info = init (a); -} - -inline ComplexHESS::ComplexHESS (const ComplexHESS& a) -{ - hess_mat = a.hess_mat; - unitary_hess_mat = a.unitary_hess_mat; -} - -inline ComplexHESS& -ComplexHESS::operator = (const ComplexHESS& a) -{ - hess_mat = a.hess_mat; - unitary_hess_mat = a.unitary_hess_mat; - - return *this; -} - -inline ComplexMatrix ComplexHESS::hess_matrix (void) const -{ - return hess_mat; -} - -inline ComplexMatrix ComplexHESS::unitary_hess_matrix (void) const -{ - return unitary_hess_mat; -} - #endif /*
--- a/liboctave/CmplxLU.h +++ b/liboctave/CmplxLU.h @@ -39,17 +39,30 @@ public: - ComplexLU (void) {} + ComplexLU (void) { } ComplexLU (const ComplexMatrix& a); - ComplexLU (const ComplexLU& a); - - ComplexLU& operator = (const ComplexLU& a); + ComplexLU (const ComplexLU& a) + { + l = a.l; + u = a.u; + p = a.p; + } - ComplexMatrix L (void) const; - ComplexMatrix U (void) const; - Matrix P (void) const; + ComplexLU& operator = (const ComplexLU& a) + { + l = a.l; + u = a.u; + p = a.p; + + return *this; + } + + ComplexMatrix L (void) const { return l; } + ComplexMatrix U (void) const { return u; } + + Matrix P (void) const { return p; } friend ostream& operator << (ostream& os, const ComplexLU& a); @@ -60,36 +73,6 @@ Matrix p; }; -inline ComplexLU::ComplexLU (const ComplexLU& a) -{ - l = a.l; - u = a.u; - p = a.p; -} - -inline ComplexLU& ComplexLU::operator = (const ComplexLU& a) -{ - l = a.l; - u = a.u; - p = a.p; - return *this; -} - -inline ComplexMatrix ComplexLU::L (void) const -{ - return l; -} - -inline ComplexMatrix ComplexLU::U (void) const -{ - return u; -} - -inline Matrix ComplexLU::P (void) const -{ - return p; -} - #endif /*
--- a/liboctave/CmplxQR.h +++ b/liboctave/CmplxQR.h @@ -37,16 +37,26 @@ { public: - ComplexQR (void) {} + ComplexQR (void) { } ComplexQR (const ComplexMatrix& A, QR::type qr_type = QR::std); - ComplexQR (const ComplexQR& a); + ComplexQR (const ComplexQR& a) + { + q = a.q; + r = a.r; + } - ComplexQR& operator = (const ComplexQR& a); + ComplexQR& operator = (const ComplexQR& a) + { + q = a.q; + r = a.r; - ComplexMatrix Q (void) const; - ComplexMatrix R (void) const; + return *this; + } + + ComplexMatrix Q (void) const { return q; } + ComplexMatrix R (void) const { return r; } friend ostream& operator << (ostream& os, const ComplexQR& a); @@ -56,29 +66,6 @@ ComplexMatrix r; }; -inline ComplexQR::ComplexQR (const ComplexQR& a) -{ - q = a.q; - r = a.r; -} - -inline ComplexQR& ComplexQR::operator = (const ComplexQR& a) -{ - q = a.q; - r = a.r; - return *this; -} - -inline ComplexMatrix ComplexQR::Q (void) const -{ - return q; -} - -inline ComplexMatrix ComplexQR::R (void) const -{ - return r; -} - #endif /*
--- a/liboctave/CmplxQRP.h +++ b/liboctave/CmplxQRP.h @@ -36,15 +36,21 @@ { public: - ComplexQRP (void) {} + ComplexQRP (void) { } ComplexQRP (const ComplexMatrix& A, QR::type qr_type = QR::std); - ComplexQRP (const ComplexQRP& a); + ComplexQRP (const ComplexQRP& a) : ComplexQR (a) { p = a.p; } - ComplexQRP& operator = (const ComplexQRP& a); + ComplexQRP& operator = (const ComplexQRP& a) + { + ComplexQR::operator = (a); + p = a.p; - Matrix P (void) const; + return *this; + } + + Matrix P (void) const { return p; } friend ostream& operator << (ostream& os, const ComplexQRP& a); @@ -53,23 +59,6 @@ Matrix p; }; -inline ComplexQRP::ComplexQRP (const ComplexQRP& a) : ComplexQR (a) -{ - p = a.p; -} - -inline ComplexQRP& ComplexQRP::operator = (const ComplexQRP& a) -{ - ComplexQR::operator = (a); - p = a.p; - return *this; -} - -inline Matrix ComplexQRP::P (void) const -{ - return p; -} - #endif /*
--- a/liboctave/CmplxSCHUR.h +++ b/liboctave/CmplxSCHUR.h @@ -38,17 +38,41 @@ public: - ComplexSCHUR (void) {} + ComplexSCHUR (void) { } + + ComplexSCHUR (const ComplexMatrix& a, const char *ord) + { + init (a,ord); + } - ComplexSCHUR (const ComplexMatrix& a, const char *ord); - ComplexSCHUR (const ComplexMatrix& a, const char *ord, int& info); + ComplexSCHUR (const ComplexMatrix& a, const char *ord, int& info) + { + info = init (a,ord); + } + + ComplexSCHUR (const ComplexSCHUR& a) + { + schur_mat = a.schur_mat; + unitary_mat = a.unitary_mat; + } - ComplexSCHUR (const ComplexSCHUR& a); + ComplexSCHUR& operator = (const ComplexSCHUR& a) + { + schur_mat = a.schur_mat; + unitary_mat = a.unitary_mat; + + return *this; + } - ComplexSCHUR& operator = (const ComplexSCHUR& a); + ComplexMatrix schur_matrix (void) const + { + return schur_mat; + } - ComplexMatrix schur_matrix (void) const; - ComplexMatrix unitary_matrix (void) const; + ComplexMatrix unitary_matrix (void) const + { + return unitary_mat; + } friend ostream& operator << (ostream& os, const ComplexSCHUR& a); @@ -60,42 +84,6 @@ ComplexMatrix unitary_mat; }; -inline ComplexSCHUR::ComplexSCHUR (const ComplexMatrix& a, const char *ord) -{ - init (a,ord); -} - -inline ComplexSCHUR::ComplexSCHUR (const ComplexMatrix& a, const char *ord, - int& info) -{ - info = init (a,ord); -} - -inline ComplexSCHUR::ComplexSCHUR (const ComplexSCHUR& a) -{ - schur_mat = a.schur_mat; - unitary_mat = a.unitary_mat; -} - -inline ComplexSCHUR& -ComplexSCHUR::operator = (const ComplexSCHUR& a) -{ - schur_mat = a.schur_mat; - unitary_mat = a.unitary_mat; - - return *this; -} - -inline ComplexMatrix ComplexSCHUR::schur_matrix (void) const -{ - return schur_mat; -} - -inline ComplexMatrix ComplexSCHUR::unitary_matrix (void) const -{ - return unitary_mat; -} - #endif /*
--- a/liboctave/CmplxSVD.h +++ b/liboctave/CmplxSVD.h @@ -40,19 +40,40 @@ public: - ComplexSVD (void) {} + ComplexSVD (void) { } + - ComplexSVD (const ComplexMatrix& a, SVD::type svd_type = SVD::std); - ComplexSVD (const ComplexMatrix& a, int& info, - SVD::type svd_type = SVD::std); + ComplexSVD (const ComplexMatrix& a, SVD::type svd_type) + { + init (a, svd_type); + } + + ComplexSVD (const ComplexMatrix& a, int& info, SVD::type svd_type) + { + info = init (a, svd_type); + } - ComplexSVD (const ComplexSVD& a); - - ComplexSVD& operator = (const ComplexSVD& a); + ComplexSVD (const ComplexSVD& a) + { + sigma = a.sigma; + left_sm = a.left_sm; + right_sm = a.right_sm; + } - DiagMatrix singular_values (void) const; - ComplexMatrix left_singular_matrix (void) const; - ComplexMatrix right_singular_matrix (void) const; + ComplexSVD& operator = (const ComplexSVD& a) + { + sigma = a.sigma; + left_sm = a.left_sm; + right_sm = a.right_sm; + + return *this; + } + + DiagMatrix singular_values (void) const { return sigma; } + + ComplexMatrix left_singular_matrix (void) const { return left_sm; } + + ComplexMatrix right_singular_matrix (void) const { return right_sm; } friend ostream& operator << (ostream& os, const ComplexSVD& a); @@ -65,49 +86,6 @@ ComplexMatrix right_sm; }; -inline ComplexSVD::ComplexSVD (const ComplexMatrix& a, SVD::type svd_type) -{ - init (a, svd_type); -} - -inline ComplexSVD::ComplexSVD (const ComplexMatrix& a, int& info, - SVD::type svd_type) -{ - info = init (a, svd_type); -} - -inline ComplexSVD::ComplexSVD (const ComplexSVD& a) -{ - sigma = a.sigma; - left_sm = a.left_sm; - right_sm = a.right_sm; -} - -inline ComplexSVD& -ComplexSVD::operator = (const ComplexSVD& a) -{ - sigma = a.sigma; - left_sm = a.left_sm; - right_sm = a.right_sm; - - return *this; -} - -inline DiagMatrix ComplexSVD::singular_values (void) const -{ - return sigma; -} - -inline ComplexMatrix ComplexSVD::left_singular_matrix (void) const -{ - return left_sm; -} - -inline ComplexMatrix ComplexSVD::right_singular_matrix (void) const -{ - return right_sm; -} - #endif /*
--- a/liboctave/CollocWt.cc +++ b/liboctave/CollocWt.cc @@ -54,138 +54,6 @@ (*current_liboctave_error_handler) ("fatal CollocWt error: %s", msg); } -CollocWt::CollocWt (void) -{ - n = 0; - inc_left = 0; - inc_right = 0; - lb = 0.0; - rb = 1.0; - - Alpha = 0.0; - Beta = 0.0; - - initialized = 0; -} - -CollocWt::CollocWt (int nc, int il, int ir) -{ - n = nc; - inc_left = il; - inc_right = ir; - lb = 0.0; - rb = 1.0; - - Alpha = 0.0; - Beta = 0.0; - - initialized = 0; -} - -CollocWt::CollocWt (int nc, int ir, int il, double l, double r) -{ - n = nc; - inc_left = il; - inc_right = ir; - lb = l; - rb = r; - - Alpha = 0.0; - Beta = 0.0; - - initialized = 0; -} - -CollocWt::CollocWt (int nc, double a, double b, int il, int ir) -{ - n = nc; - inc_left = il; - inc_right = ir; - lb = 0.0; - rb = 1.0; - - Alpha = a; - Beta = b; - - initialized = 0; -} - -CollocWt::CollocWt (int nc, double a, double b, int ir, int il, - double l, double r) -{ - n = nc; - inc_left = il; - inc_right = ir; - lb = l; - rb = r; - - Alpha = a; - Beta = b; - - initialized = 0; -} - -CollocWt::CollocWt (const CollocWt& a) -{ - n = a.n; - inc_left = a.inc_left; - inc_right = a.inc_right; - lb = a.lb; - rb = a.rb; - r = a.r; - q = a.q; - A = a.A; - B = a.B; - - nt = n + inc_left + inc_right; - - initialized = a.initialized; -} - -CollocWt& -CollocWt::operator = (const CollocWt& a) -{ - n = a.n; - inc_left = a.inc_left; - inc_right = a.inc_right; - lb = a.lb; - rb = a.rb; - r = a.r; - q = a.q; - A = a.A; - B = a.B; - - nt = a.nt; - - initialized = a.initialized; - - return *this; -} - -CollocWt& -CollocWt::resize (int ncol) -{ - n = ncol; - initialized = 0; - return *this; -} - -CollocWt& -CollocWt::add_left (void) -{ - inc_left = 1; - initialized = 0; - return *this; -} - -CollocWt& -CollocWt::delete_left (void) -{ - inc_left = 0; - initialized = 0; - return *this; -} - CollocWt& CollocWt::set_left (double val) { @@ -201,22 +69,6 @@ } CollocWt& -CollocWt::add_right (void) -{ - inc_right = 1; - initialized = 0; - return *this; -} - -CollocWt& -CollocWt::delete_right (void) -{ - inc_right = 0; - initialized = 0; - return *this; -} - -CollocWt& CollocWt::set_right (double val) { if (val <= lb) @@ -230,22 +82,6 @@ return *this; } -CollocWt& -CollocWt::set_alpha (double val) -{ - Alpha = val; - initialized = 0; - return *this; -} - -CollocWt& -CollocWt::set_beta (double val) -{ - Beta = val; - initialized = 0; - return *this; -} - void CollocWt::init (void) {
--- a/liboctave/CollocWt.h +++ b/liboctave/CollocWt.h @@ -33,57 +33,192 @@ #include "dMatrix.h" #include "dColVector.h" -#ifndef Vector -#define Vector ColumnVector -#endif - class CollocWt { public: - CollocWt (void); - CollocWt (int ncol, int include_left, int include_right); - CollocWt (int ncol, int include_left, int include_right, double left, - double right); - CollocWt (int ncol, double alpha, double beta, int include_left, - int include_right); - CollocWt (int ncol, double alpha, double beta, int include_left, - int include_right, double left, double right); + CollocWt::CollocWt (void) + { + n = 0; + inc_left = 0; + inc_right = 0; + lb = 0.0; + rb = 1.0; + + Alpha = 0.0; + Beta = 0.0; + + initialized = 0; + } + + CollocWt::CollocWt (int nc, int il, int ir) + { + n = nc; + inc_left = il; + inc_right = ir; + lb = 0.0; + rb = 1.0; + + Alpha = 0.0; + Beta = 0.0; + + initialized = 0; + } + + CollocWt::CollocWt (int nc, int il, int ir, double l, double r) + { + n = nc; + inc_left = il; + inc_right = ir; + lb = l; + rb = r; + + Alpha = 0.0; + Beta = 0.0; + + initialized = 0; + } + + CollocWt::CollocWt (int nc, double a, double b, int il, int ir) + { + n = nc; + inc_left = il; + inc_right = ir; + lb = 0.0; + rb = 1.0; + + Alpha = a; + Beta = b; + + initialized = 0; + } + + CollocWt::CollocWt (int nc, double a, double b, int il, int ir, + double l, double r) + { + n = nc; + inc_left = il; + inc_right = ir; + lb = l; + rb = r; - CollocWt (const CollocWt&); + Alpha = a; + Beta = b; + + initialized = 0; + } - CollocWt& operator = (const CollocWt&); + CollocWt::CollocWt (const CollocWt& a) + { + n = a.n; + inc_left = a.inc_left; + inc_right = a.inc_right; + lb = a.lb; + rb = a.rb; + r = a.r; + q = a.q; + A = a.A; + B = a.B; + + nt = n + inc_left + inc_right; + + initialized = a.initialized; + } - CollocWt& resize (int ncol); + CollocWt& + CollocWt::operator = (const CollocWt& a) + { + n = a.n; + inc_left = a.inc_left; + inc_right = a.inc_right; + lb = a.lb; + rb = a.rb; + r = a.r; + q = a.q; + A = a.A; + B = a.B; + + nt = a.nt; + + initialized = a.initialized; + + return *this; + } - CollocWt& add_left (void); - CollocWt& delete_left (void); + CollocWt& resize (int ncol) + { + n = ncol; + initialized = 0; + return *this; + } + + CollocWt& add_left (void) + { + inc_left = 1; + initialized = 0; + return *this; + } + + CollocWt& delete_left (void) + { + inc_left = 0; + initialized = 0; + return *this; + } + CollocWt& set_left (double val); - CollocWt& add_right (void); - CollocWt& delete_right (void); + CollocWt& add_right (void) + { + inc_right = 1; + initialized = 0; + return *this; + } + + CollocWt& delete_right (void) + { + inc_right = 0; + initialized = 0; + return *this; + } + CollocWt& set_right (double val); - CollocWt& set_alpha (double val); - CollocWt& set_beta (double val); + CollocWt& set_alpha (double val) + { + Alpha = val; + initialized = 0; + return *this; + } - int ncol (void) const; - int left_included (void) const; - int right_included (void) const; + CollocWt& set_beta (double val) + { + Beta = val; + initialized = 0; + return *this; + } + + int ncol (void) const { return n; } - double left (void) const; - double right (void) const; - double width (void) const; + int left_included (void) const { return inc_left; } + int right_included (void) const { return inc_right; } - double alpha (void) const; - double beta (void) const; + double left (void) const { return lb; } + double right (void) const { return rb; } + + double width (void) const { return rb - lb; } - Vector roots (void); - Vector quad (void); - Vector quad_weights (void); + double alpha (void) const { return Alpha; } + double beta (void) const { return Beta; } + + ColumnVector roots (void) { if (!initialized) init (); return r; } + ColumnVector quad (void) { if (!initialized) init (); return q; } - Matrix first (void); - Matrix second (void); + ColumnVector quad_weights (void) { return quad (); } + + Matrix first (void) { if (!initialized) init (); return A; } + + Matrix second (void) { if (!initialized) init (); return B; } friend ostream& operator << (ostream&, const CollocWt&); @@ -101,8 +236,8 @@ double Alpha; double Beta; - Vector r; - Vector q; + ColumnVector r; + ColumnVector q; Matrix A; Matrix B; @@ -114,35 +249,6 @@ void error (const char *msg); }; -inline int -CollocWt::ncol (void) const -{ - return n; -} - -inline int CollocWt::left_included (void) const { return inc_left; } -inline int CollocWt::right_included (void) const { return inc_right; } -inline double CollocWt::left (void) const { return lb; } -inline double CollocWt::right (void) const { return rb; } -inline double CollocWt::width (void) const { return rb - lb; } -inline double CollocWt::alpha (void) const { return Alpha; } -inline double CollocWt::beta (void) const { return Beta; } - -inline Vector CollocWt::roots (void) - { if (!initialized) init (); return r; } - -inline Vector CollocWt::quad (void) - { if (!initialized) init (); return q; } - -inline Vector CollocWt::quad_weights (void) - { return quad (); } - -inline Matrix CollocWt::first (void) - { if (!initialized) init (); return A; } - -inline Matrix CollocWt::second (void) - { if (!initialized) init (); return B; } - #endif /*
--- a/liboctave/DAEFunc.h +++ b/liboctave/DAEFunc.h @@ -31,10 +31,6 @@ class Matrix; class ColumnVector; -#ifndef Vector -#define Vector ColumnVector -#endif - #if !defined (octave_DAEFunc_typedefs) #define octave_DAEFunc_typedefs 1 @@ -50,32 +46,63 @@ Matrix *dfdx; }; - typedef Vector (*DAERHSFunc) (const Vector& x, - const Vector& xdot, double); + typedef ColumnVector (*DAERHSFunc) (const ColumnVector& x, + const ColumnVector& xdot, double); + + typedef DAEJac (*DAEJacFunc) (const ColumnVector& x, + const ColumnVector& xdot, double); + + DAEFunc (void) + { + fun = 0; + jac = 0; + } - typedef DAEJac (*DAEJacFunc) (const Vector& x, - const Vector& xdot, double); + DAEFunc (DAERHSFunc f) + { + fun = f; + jac = 0; + } - DAEFunc (void); - DAEFunc (DAERHSFunc f); - DAEFunc (DAERHSFunc f, DAEJacFunc j); + DAEFunc (DAERHSFunc f, DAEJacFunc j) + { + fun = f; + jac = j; + } - DAEFunc (const DAEFunc& a); + DAEFunc (const DAEFunc& a) + { + fun = a.fun; + jac = a.jac; + } - DAEFunc& operator = (const DAEFunc& a); + DAEFunc& operator = (const DAEFunc& a) + { + fun = a.fun; + jac = a.jac; - DAERHSFunc function (void) const; + return *this; + } - DAEFunc& set_function (DAERHSFunc f); + DAERHSFunc function (void) const { return fun; } + + DAEFunc& set_function (DAERHSFunc f) + { + fun = f; + return *this; + } - DAEJacFunc jacobian_function (void) const; + DAEJacFunc jacobian_function (void) const { return jac; } - DAEFunc& set_jacobian_function (DAEJacFunc f); + DAEFunc& set_jacobian_function (DAEJacFunc j) + { + jac = j; + return *this; + } protected: DAERHSFunc fun; - DAEJacFunc jac; };
--- a/liboctave/EIG.h +++ b/liboctave/EIG.h @@ -41,20 +41,31 @@ public: - EIG (void) {} + EIG (void) { } - EIG (const Matrix& a); - EIG (const Matrix& a, int& info); + EIG (const Matrix& a) { init (a); } + EIG (const Matrix& a, int& info) { info = init (a); } + + EIG (const ComplexMatrix& a) { init (a); } + EIG (const ComplexMatrix& a, int& info) { info = init (a); } - EIG (const ComplexMatrix& a); - EIG (const ComplexMatrix& a, int& info); - - EIG (const EIG& a); + EIG (const EIG& a) + { + lambda = a.lambda; + v = a.v; + } - EIG& operator = (const EIG& a); + EIG& operator = (const EIG& a) + { + lambda = a.lambda; + v = a.v; - ComplexColumnVector eigenvalues (void) const; - ComplexMatrix eigenvectors (void) const; + return *this; + } + + ComplexColumnVector eigenvalues (void) const { return lambda; } + + ComplexMatrix eigenvectors (void) const { return v; } friend ostream& operator << (ostream& os, const EIG& a); @@ -67,49 +78,6 @@ ComplexMatrix v; }; -inline EIG::EIG (const Matrix& a) -{ - init (a); -} - -inline EIG::EIG (const Matrix& a, int& info) -{ - info = init (a); -} - -inline EIG::EIG (const ComplexMatrix& a) -{ - init (a); -} - -inline EIG::EIG (const ComplexMatrix& a, int& info) -{ - info = init (a); -} - -inline EIG::EIG (const EIG& a) -{ - lambda = a.lambda; - v = a.v; -} - -inline EIG& EIG::operator = (const EIG& a) -{ - lambda = a.lambda; - v = a.v; - return *this; -} - -inline ComplexColumnVector EIG::eigenvalues (void) const -{ - return lambda; -} - -inline ComplexMatrix EIG::eigenvectors (void) const -{ - return v; -} - #endif /*
--- a/liboctave/FEGrid.h +++ b/liboctave/FEGrid.h @@ -32,10 +32,6 @@ #include "dColVector.h" -#ifndef Vector -#define Vector ColumnVector -#endif - class FEGrid { private: @@ -47,8 +43,8 @@ public: - FEGrid (void) {} - FEGrid (const Vector& elbnds) { elem = elbnds; check_grid (); } + FEGrid (void) { } + FEGrid (const ColumnVector& elbnds) : elem (elbnds) { check_grid (); } FEGrid (int nel, double width); FEGrid (int nel, double left, double right); @@ -57,16 +53,15 @@ double left (void) const { return elem.elem (0); } double right (void) const { return elem.elem (elem.capacity () - 1); } - int in_bounds (double x) const - { return (x >= left () && x <= right ()); } + int in_bounds (double x) const { return (x >= left () && x <= right ()); } - Vector element_boundaries (void) const { return elem; } + ColumnVector element_boundaries (void) const { return elem; } friend ostream& operator << (ostream&, const FEGrid&); protected: - Vector elem; + ColumnVector elem; }; #endif
--- a/liboctave/LP.h +++ b/liboctave/LP.h @@ -31,29 +31,29 @@ #include "dColVector.h" #include "Bounds.h" #include "LinConst.h" +#include "base-min.h" -#ifndef Vector -#define Vector ColumnVector -#endif - -class LP +class LP : public base_minimizer { public: - LP (void); - LP (const Vector& c); - LP (const Vector& c, const Bounds& b); - LP (const Vector& c, const Bounds& b, const LinConst& lc); - LP (const Vector& c, const LinConst& lc); + LP (void) : base_minimizer () { } + + LP (const ColumnVector& c_arg) + : base_minimizer (), c (c_arg) { } - virtual Vector minimize (void); - virtual Vector minimize (double& objf); - virtual Vector minimize (double& objf, int& inform); - virtual Vector minimize (double& objf, int& inform, Vector& lambda) = 0; + LP (const ColumnVector& c_arg, const Bounds& b) + : base_minimizer (), c (c_arg), bnds (b) { } + + LP (const ColumnVector& c_arg, const Bounds& b, const LinConst& l) + : base_minimizer (), c (c_arg), bnds (b), lc (l) { } + + LP (const ColumnVector& c_arg, const LinConst& l) + : base_minimizer (), c (c_arg), lc (l) { } protected: - Vector c; + ColumnVector c; Bounds bnds; LinConst lc; };
--- a/liboctave/LPsolve.cc +++ b/liboctave/LPsolve.cc @@ -32,10 +32,10 @@ #include "LPsolve.h" #include "dColVector.h" -Vector -LPsolve::minimize (double&, int&, Vector&) +ColumnVector +LPsolve::do_minimize (double&, int&, ColumnVector&) { - return Vector (); + return ColumnVector (); } void
--- a/liboctave/LPsolve.h +++ b/liboctave/LPsolve.h @@ -32,10 +32,6 @@ #include "LP.h" -#ifndef Vector -#define Vector ColumnVector -#endif - class LPsolve : public LP { public: @@ -43,19 +39,19 @@ LPsolve (void) : LP () { set_default_options (); } - LPsolve (const Vector& c) : LP (c) + LPsolve (const ColumnVector& c) : LP (c) { set_default_options (); } - LPsolve (const Vector& c, const Bounds& b) : LP (c, b) + LPsolve (const ColumnVector& c, const Bounds& b) : LP (c, b) { set_default_options (); } - LPsolve (const Vector& c, const Bounds& b, const LinConst& lc) + LPsolve (const ColumnVector& c, const Bounds& b, const LinConst& lc) : LP (c, b, lc) { set_default_options (); } - LPsolve (const Vector& c, const LinConst& lc) : LP (c, lc) + LPsolve (const ColumnVector& c, const LinConst& lc) : LP (c, lc) { set_default_options (); } - virtual Vector minimize (double& objf, int& inform, Vector& lambda); + ColumnVector do_minimize (double& objf, int& inform, ColumnVector& lambda); private:
--- a/liboctave/LinConst.h +++ b/liboctave/LinConst.h @@ -45,7 +45,7 @@ { public: - LinConst (void) : Bounds () {} + LinConst (void) : Bounds () { } LinConst (int nc, int n) : Bounds (nc), A (nb, n) {} LinConst (int eq, int ineq, int n)
--- a/liboctave/NLConst.h +++ b/liboctave/NLConst.h @@ -33,20 +33,29 @@ #include "Bounds.h" #include "NLFunc.h" -#ifndef Vector -#define Vector ColumnVector -#endif - class NLConst : public Bounds, public NLFunc { public: - NLConst (void); - NLConst (int n); - NLConst (const Vector& lb, const NLFunc f, const Vector& ub); - NLConst (const NLConst& a); + NLConst (void) : Bounds (), NLFunc () { } + + NLConst (int n) : Bounds (n), NLFunc () { } + + NLConst (const ColumnVector& lb, const NLFunc f, const ColumnVector& ub) + : Bounds (lb, ub), NLFunc (f) { } + + NLConst (const NLConst& a) : Bounds (a.lb, a.ub), NLFunc (a.fun, a.jac) { } - NLConst& operator = (const NLConst& a); + NLConst& operator = (const NLConst& a) + { + nb = a.nb; + lb = a.lb; + fun = a.fun; + jac = a.jac; + ub = a.ub; + + return *this; + } private:
--- a/liboctave/NLP.h +++ b/liboctave/NLP.h @@ -29,105 +29,68 @@ #include "Bounds.h" #include "LinConst.h" #include "NLConst.h" +#include "base-min.h" -#ifndef Vector -#define Vector ColumnVector -#endif - -class NLP +class NLP : public base_minimizer { public: - NLP (void); + NLP (void) : base_minimizer () { } - NLP (const Vector& x, const Objective& phi); + NLP (const ColumnVector& x, const Objective& obj) + : base_minimizer (x), phi (obj) { } - NLP (const Vector& x, const Objective& phi, const Bounds& b); + NLP (const ColumnVector& x, const Objective& obj, const Bounds& b) + : base_minimizer (x), phi (obj), bnds (b) { } - NLP (const Vector& x, const Objective& phi, const Bounds& b, const - LinConst& lc); + NLP (const ColumnVector& x, const Objective& obj, const Bounds& b, + const LinConst& l) + : base_minimizer (x), phi (obj), bnds (b), lc (l) { } - NLP (const Vector& x, const Objective& phi, const Bounds& b, const - LinConst& lc, const NLConst& nlc); + NLP (const ColumnVector& x, const Objective& obj, const Bounds& b, + const LinConst& l, const NLConst& nl) + : base_minimizer (x), phi (obj), bnds (b), lc (l), nlc (nl) { } - NLP (const Vector& x, const Objective& phi, const LinConst& lc); + NLP (const ColumnVector& x, const Objective& obj, const LinConst& l) + : base_minimizer (x), phi (obj), lc (l) { } + + NLP (const ColumnVector& x, const Objective& obj, const LinConst& l, + const NLConst& nl) + : base_minimizer (x), phi (obj), lc (l), nlc (nl) { } - NLP (const Vector& x, const Objective& phi, const LinConst& lc, - const NLConst& nlc); + NLP (const ColumnVector& x, const Objective& obj, const NLConst& nl) + : base_minimizer (x), phi (obj), nlc (nl) { } - NLP (const Vector& x, const Objective& phi, const NLConst& nlc); + NLP (const ColumnVector& x, const Objective& obj, const Bounds& b, + const NLConst& nl) + : base_minimizer (x), phi (obj), bnds (b), nlc (nl) { } - NLP (const Vector& x, const Objective& phi, const Bounds& b, const - NLConst& nlc); + NLP& operator = (const NLP& a) + { + if (this != &a) + { + x = a.x; + phi = a.phi; + bnds = a.bnds; + lc = a.lc; + nlc = a.nlc; + } - ~NLP (void); + return *this; + } - NLP& operator = (const NLP& a); + virtual ~NLP (void) { } - int size (void) const; + int size (void) const { return x.capacity (); } protected: - Vector x; Objective phi; Bounds bnds; LinConst lc; NLConst nlc; }; -inline NLP::NLP (void) {} - -inline NLP::NLP (const Vector& xx, const Objective& obj) - : x (xx), phi (obj) {} - -inline NLP::NLP (const Vector& xx, const Objective& obj, const Bounds& b) - : x (xx), phi (obj), bnds (b) {} - -inline NLP::NLP (const Vector& xx, const Objective& obj, const Bounds& b, - const LinConst& l) - : x (xx), phi (obj), bnds (b), lc (l) {} - -inline NLP::NLP (const Vector& xx, const Objective& obj, const Bounds& b, - const LinConst& l, const NLConst& nl) - : x (xx), phi (obj), bnds (b), lc (l), nlc (nl) {} - -inline NLP::NLP (const Vector& xx, const Objective& obj, const LinConst& l) - : x (xx), phi (obj), lc (l) {} - -inline NLP::NLP (const Vector& xx, const Objective& obj, const LinConst& l, - const NLConst& nl) - : x (xx), phi (obj), lc (l), nlc (nl) {} - -inline NLP::NLP (const Vector& xx, const Objective& obj, const NLConst& nl) - : x (xx), phi (obj), nlc (nl) {} - -inline NLP::NLP (const Vector& xx, const Objective& obj, const Bounds& b, - const NLConst& nl) - : x (xx), phi (obj), bnds (b), nlc (nl) {} - -inline NLP::~NLP (void) { } - -inline NLP& -NLP::operator = (const NLP& a) -{ - if (this != &a) - { - x = a.x; - phi = a.phi; - bnds = a.bnds; - lc = a.lc; - nlc = a.nlc; - } - - return *this; -} - -inline int -NLP::size (void) const -{ - return x.capacity (); -} - #endif /*
--- a/liboctave/NPSOL.cc +++ b/liboctave/NPSOL.cc @@ -73,7 +73,7 @@ npsol_objfun (int& mode, const int& n, double *xx, double *objf, double *objgrd, int *) { - Vector tmp_x (n); + ColumnVector tmp_x (n); npsol_objective_error = 0; @@ -99,7 +99,7 @@ if ((mode == 1 || mode == 2) && user_grad) { - Vector tmp_grad (n); + ColumnVector tmp_grad (n); tmp_grad = (*user_grad) (tmp_x); @@ -120,8 +120,8 @@ const int& nrowj, int *, double *xx, double *cons, double *cjac, int *) { - Vector tmp_x (n); - Vector tmp_c (ncnln); + ColumnVector tmp_x (n); + ColumnVector tmp_c (ncnln); for (int i = 0; i < n; i++) tmp_x.elem (i) = xx[i]; @@ -159,32 +159,8 @@ return 0; } -Vector -NPSOL::minimize (void) -{ - double objf; - int inform; - Vector lambda; - return minimize (objf, inform, lambda); -} - -Vector -NPSOL::minimize (double& objf) -{ - int inform; - Vector lambda; - return minimize (objf, inform, lambda); -} - -Vector -NPSOL::minimize (double& objf, int& inform) -{ - Vector lambda; - return minimize (objf, inform, lambda); -} - -Vector -NPSOL::minimize (double& objf, int& inform, Vector& lambda) +ColumnVector +NPSOL::do_minimize (double& objf, int& inform, ColumnVector& lambda) { // Dimensions of various things. @@ -332,34 +308,6 @@ return x; } -Vector -NPSOL::minimize (const Vector& xnew) -{ - x = xnew; - return minimize (); -} - -Vector -NPSOL::minimize (const Vector& xnew, double& objf) -{ - x = xnew; - return minimize (objf); -} - -Vector -NPSOL::minimize (const Vector& xnew, double& objf, int& inform) -{ - x = xnew; - return minimize (objf, inform); -} - -Vector -NPSOL::minimize (const Vector& xnew, double& objf, int& inform, Vector& lambda) -{ - x = xnew; - return minimize (objf, inform, lambda); -} - NPSOL& NPSOL::option (char *) {
--- a/liboctave/NPSOL.h +++ b/liboctave/NPSOL.h @@ -33,10 +33,6 @@ #include "dColVector.h" #include "NLP.h" -#ifndef Vector -#define Vector ColumnVector -#endif - class NPSOL_options { public: @@ -134,47 +130,33 @@ NPSOL (void) : NLP () { } - NPSOL (const Vector& x, const Objective& phi) : NLP (x, phi) { } + NPSOL (const ColumnVector& x, const Objective& phi) : NLP (x, phi) { } - NPSOL (const Vector& x, const Objective& phi, - const Bounds& b) : NLP (x, phi, b) - { } + NPSOL (const ColumnVector& x, const Objective& phi, + const Bounds& b) : NLP (x, phi, b) { } - NPSOL (const Vector& x, const Objective& phi, const Bounds& b, - const LinConst& lc) : NLP (x, phi, b, lc) - { } + NPSOL (const ColumnVector& x, const Objective& phi, const Bounds& b, + const LinConst& lc) : NLP (x, phi, b, lc) { } - NPSOL (const Vector& x, const Objective& phi, const Bounds& b, - const LinConst& lc, const NLConst& nlc) : NLP (x, phi, b, lc, nlc) - { } - - NPSOL (const Vector& x, const Objective& phi, - const LinConst& lc) : NLP (x, phi, lc) - { } + NPSOL (const ColumnVector& x, const Objective& phi, const Bounds& b, + const LinConst& lc, const NLConst& nlc) + : NLP (x, phi, b, lc, nlc) { } - NPSOL (const Vector& x, const Objective& phi, const LinConst& lc, - const NLConst& nlc) : NLP (x, phi, lc, nlc) - { } + NPSOL (const ColumnVector& x, const Objective& phi, + const LinConst& lc) : NLP (x, phi, lc) { } - NPSOL (const Vector& x, const Objective& phi, - const NLConst& nlc) : NLP (x, phi, nlc) - { } - - NPSOL (const Vector& x, const Objective& phi, const Bounds& b, - const NLConst& nlc) : NLP (x, phi, b, nlc) - { } + NPSOL (const ColumnVector& x, const Objective& phi, const LinConst& lc, + const NLConst& nlc) : NLP (x, phi, lc, nlc) { } - NPSOL (const NPSOL& a); + NPSOL (const ColumnVector& x, const Objective& phi, + const NLConst& nlc) : NLP (x, phi, nlc) { } - Vector minimize (void); - Vector minimize (double& objf); - Vector minimize (double& objf, int& inform); - Vector minimize (double& objf, int& inform, Vector& lambda); + NPSOL (const ColumnVector& x, const Objective& phi, const Bounds& b, + const NLConst& nlc) : NLP (x, phi, b, nlc) { } - Vector minimize (const Vector& x); - Vector minimize (const Vector& x, double& objf); - Vector minimize (const Vector& x, double& objf, int& inform); - Vector minimize (const Vector& x, double& objf, int& inform, Vector& lambda); + NPSOL (const NPSOL& a) : NLP (a.x, a.phi, a.bnds, a.lc, a.nlc) { } + + ColumnVector do_minimize (double& objf, int& inform, ColumnVector& lambda); NPSOL& option (char *s); @@ -187,9 +169,6 @@ // function, and the user wants us to quit. extern int npsol_objective_error; -inline NPSOL::NPSOL (const NPSOL& a) : NLP (a.x, a.phi, a.bnds, a.lc, a.nlc) - { } - #endif #endif
--- a/liboctave/QLD.h +++ b/liboctave/QLD.h @@ -44,57 +44,54 @@ QLD (void) : QP () { set_default_options (); } - QLD (const Vector& x, const Matrix& H) : QP (x, H) + QLD (const ColumnVector& x, const Matrix& H) : QP (x, H) { set_default_options (); } - QLD (const Vector& x, const Matrix& H, const Vector& c) : QP (x, H, c) - { set_default_options (); } + QLD (const ColumnVector& x, const Matrix& H, const ColumnVector& c) + : QP (x, H, c) { set_default_options (); } - QLD (const Vector& x, const Matrix& H, const Bounds& b) : QP (x, H, b) - { set_default_options (); } - - QLD (const Vector& x, const Matrix& H, const LinConst& lc) : QP (x, H, lc) + QLD (const ColumnVector& x, const Matrix& H, const Bounds& b) : QP (x, H, b) { set_default_options (); } - QLD (const Vector& x, const Matrix& H, const Vector& c, const Bounds& b) - : QP (x, H, c, b) { set_default_options (); } + QLD (const ColumnVector& x, const Matrix& H, const LinConst& lc) + : QP (x, H, lc) + { set_default_options (); } + + QLD (const ColumnVector& x, const Matrix& H, const ColumnVector& c, + const Bounds& b) : QP (x, H, c, b) { set_default_options (); } - QLD (const Vector& x, const Matrix& H, const Vector& c, const LinConst& lc) - : QP (x, H, c, lc) { set_default_options (); } + QLD (const ColumnVector& x, const Matrix& H, const ColumnVector& c, + const LinConst& lc) : QP (x, H, c, lc) { set_default_options (); } - QLD (const Vector& x, const Matrix& H, const Bounds& b, const LinConst& lc) - : QP (x, H, b, lc) { set_default_options (); } + QLD (const ColumnVector& x, const Matrix& H, const Bounds& b, + const LinConst& lc) : QP (x, H, b, lc) { set_default_options (); } + + QLD (const ColumnVector& x, const Matrix& H, const ColumnVector& c, + const Bounds& b, const LinConst& lc) : QP (x, H, c, b, lc) + { set_default_options (); } - QLD (const Vector& x, const Matrix& H, const Vector& c, const Bounds& b, - const LinConst& lc) - : QP (x, H, c, b, lc) { set_default_options (); } + QLD (const QLD& a) : QP (a.x, a.H, a.c, a.bnds, a.lc) + { set_default_options (); } - QLD (const QLD& a); + QLD& operator = (const QLD& a) + { + x = a.x; + H = a.H; + c = a.c; + bnds = a.bnds; + lc = a.lc; + iprint = a.iprint; - QLD& operator = (const QLD& a); + return *this; + } - Vector minimize (double& objf, int& inform); + ColumnVector minimize (double& objf, int& inform); private: void set_default_options (void); int iprint; }; -inline QLD::QLD (const QLD& a) : QP (a.x, a.H, a.c, a.bnds, a.lc) - { set_default_options (); } - -inline QLD& -QLD::operator = (const QLD& a) -{ - x = a.x; - H = a.H; - c = a.c; - bnds = a.bnds; - lc = a.lc; - iprint = a.iprint; - return *this; -} - #endif /*
--- a/liboctave/QP.h +++ b/liboctave/QP.h @@ -32,48 +32,63 @@ #include "dColVector.h" #include "Bounds.h" #include "LinConst.h" +#include "base-min.h" -#ifndef Vector -#define Vector ColumnVector -#endif - -class QP +class QP : public base_minimizer { public: - QP (void); - QP (const Vector& x, const Matrix& H); - QP (const Vector& x, const Matrix& H, const Vector& c); - QP (const Vector& x, const Matrix& H, const Bounds& b); - QP (const Vector& x, const Matrix& H, const LinConst& lc); - QP (const Vector& x, const Matrix& H, const Vector& c, const Bounds& b); - QP (const Vector& x, const Matrix& H, const Vector& c, const LinConst& lc); - QP (const Vector& x, const Matrix& H, const Bounds& b, const LinConst& lc); - QP (const Vector& x, const Matrix& H, const Vector& c, const Bounds& b, - const LinConst& lc); + QP (void) : base_minimizer () { } + + QP (const ColumnVector& x, const Matrix& H_arg) + : base_minimizer (x), H (H_arg) + { make_h_symmetric (); } + + QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg) + : base_minimizer (x), H (H_arg), c (c_arg) + { make_h_symmetric (); } + + QP (const ColumnVector& x, const Matrix& H_arg, const Bounds& b) + : base_minimizer (x), H (H_arg), bnds (b) + { make_h_symmetric (); } + + QP (const ColumnVector& x, const Matrix& H_arg, const LinConst& l) + : base_minimizer (x), H (H_arg), lc (l) + { make_h_symmetric (); } - virtual Vector minimize (void); - virtual Vector minimize (double& objf); - virtual Vector minimize (double& objf, int& inform); - virtual Vector minimize (double& objf, int& inform, Vector& lambda) = 0; + QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg, + const Bounds& b) + : base_minimizer (x), H (H_arg), c (c_arg), bnds (b) + { make_h_symmetric (); } + + QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg, + const LinConst& l) + : base_minimizer (x), H (H_arg), c (c_arg), lc (l) + { make_h_symmetric (); } - virtual Vector minimize (const Vector& x); - virtual Vector minimize (const Vector& x, double& objf); - virtual Vector minimize (const Vector& x, double& objf, int& inform); - virtual Vector minimize (const Vector& x, double& objf, int& inform, - Vector& lambda); + QP (const ColumnVector& x, const Matrix& H_arg, const Bounds& b, + const LinConst& l) + : base_minimizer (x), H (H_arg), bnds (b), lc (l) + { make_h_symmetric (); } + + QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg, + const Bounds& b, const LinConst& l) + : base_minimizer (x), H (H_arg), c (c_arg), bnds (b), lc (l) + { make_h_symmetric (); } + + virtual ~QP (void) { } protected: - Vector x; + ColumnVector x; Matrix H; - Vector c; + ColumnVector c; Bounds bnds; LinConst lc; private: - Matrix make_h_symmetric (void); + Matrix make_h_symmetric (void) { return 0.5 * (H + H.transpose ()); } }; #endif
--- a/liboctave/QPSOL.cc +++ b/liboctave/QPSOL.cc @@ -75,8 +75,8 @@ return 0; } -Vector -QPSOL::minimize (double& objf, int& inform, Vector& lambda) +ColumnVector +QPSOL::do_minimize (double& objf, int& inform, ColumnVector& lambda) { int n = x.capacity ();
--- a/liboctave/QPSOL.h +++ b/liboctave/QPSOL.h @@ -76,54 +76,47 @@ { public: - QPSOL (void) : QP () - { } + QPSOL (void) : QP () { } + + QPSOL (const ColumnVector& x, const Matrix& H) : QP (x, H) { } - QPSOL (const Vector& x, const Matrix& H) : QP (x, H) - { } + QPSOL (const ColumnVector& x, const Matrix& H, const ColumnVector& c) + : QP (x, H, c) { } - QPSOL (const Vector& x, const Matrix& H, const Vector& c) : QP (x, H, c) - { } + QPSOL (const ColumnVector& x, const Matrix& H, const Bounds& b) + : QP (x, H, b) { } - QPSOL (const Vector& x, const Matrix& H, const Bounds& b) : QP (x, H, b) - { } + QPSOL (const ColumnVector& x, const Matrix& H, const LinConst& lc) + : QP (x, H, lc) { } - QPSOL (const Vector& x, const Matrix& H, const LinConst& lc) : QP (x, H, lc) - { } + QPSOL (const ColumnVector& x, const Matrix& H, const ColumnVector& c, + const Bounds& b) : QP (x, H, c, b) { } - QPSOL (const Vector& x, const Matrix& H, const Vector& c, const Bounds& b) - : QP (x, H, c, b) { } + QPSOL (const ColumnVector& x, const Matrix& H, const ColumnVector& c, + const LinConst& lc) : QP (x, H, c, lc) { } - QPSOL (const Vector& x, const Matrix& H, const Vector& c, const LinConst& lc) - : QP (x, H, c, lc) { } - - QPSOL (const Vector& x, const Matrix& H, const Bounds& b, const LinConst& lc) + QPSOL (const ColumnVector& x, const Matrix& H, const Bounds& b, + const LinConst& lc) : QP (x, H, b, lc) { } - QPSOL (const Vector& x, const Matrix& H, const Vector& c, const Bounds& b, - const LinConst& lc) - : QP (x, H, c, b, lc) { } + QPSOL (const ColumnVector& x, const Matrix& H, const ColumnVector& c, + const Bounds& b, const LinConst& lc) : QP (x, H, c, b, lc) { } - QPSOL (const QPSOL& a); - - QPSOL& operator = (const QPSOL& a); - - Vector minimize (double& objf, int& inform, Vector& lambda); -}; + QPSOL (const QPSOL& a) : QP (a.x, a.H, a.c, a.bnds, a.lc) { } -inline QPSOL::QPSOL (const QPSOL& a) : QP (a.x, a.H, a.c, a.bnds, a.lc) - { } + QPSOL& operator = (const QPSOL& a) + { + x = a.x; + H = a.H; + c = a.c; + bnds = a.bnds; + lc = a.lc; -inline QPSOL& -QPSOL::operator = (const QPSOL& a) -{ - x = a.x; - H = a.H; - c = a.c; - bnds = a.bnds; - lc = a.lc; - return *this; -} + return *this; + } + + ColumnVector do_minimize (double& objf, int& inform, ColumnVector& lambda); +}; #endif #endif
--- a/liboctave/Quad.cc +++ b/liboctave/Quad.cc @@ -60,40 +60,6 @@ const int&, int&, int*, double*); } -Quad::Quad (integrand_fcn fcn) -{ - f = fcn; -} - -Quad::Quad (integrand_fcn fcn, double abs, double rel) - : Quad_options (abs, rel) -{ - f = fcn; -} - -double -Quad::integrate (void) -{ - int ier, neval; - double abserr; - return integrate (ier, neval, abserr); -} - -double -Quad::integrate (int& ier) -{ - int neval; - double abserr; - return integrate (ier, neval, abserr); -} - -double -Quad::integrate (int& ier, int& neval) -{ - double abserr; - return integrate (ier, neval, abserr); -} - static double user_function (double *x, int& ierr) { @@ -113,59 +79,6 @@ return retval; } -DefQuad::DefQuad (integrand_fcn fcn) : Quad (fcn) -{ - lower_limit = 0.0; - upper_limit = 1.0; -} - -DefQuad::DefQuad (integrand_fcn fcn, double ll, double ul) - : Quad (fcn) -{ - lower_limit = ll; - upper_limit = ul; -} - -DefQuad::DefQuad (integrand_fcn fcn, double ll, double ul, - double abs, double rel) : Quad (fcn, abs, rel) -{ - lower_limit = ll; - upper_limit = ul; -} - -DefQuad::DefQuad (integrand_fcn fcn, double ll, double ul, - const Vector& sing) : Quad (fcn) -{ - lower_limit = ll; - upper_limit = ul; - singularities = sing; -} - -DefQuad::DefQuad (integrand_fcn fcn, const Vector& sing, - double abs, double rel) : Quad (fcn, abs, rel) -{ - lower_limit = 0.0; - upper_limit = 1.0; - singularities = sing; -} - -DefQuad::DefQuad (integrand_fcn fcn, const Vector& sing) - : Quad (fcn) -{ - lower_limit = 0.0; - upper_limit = 1.0; - singularities = sing; -} - -DefQuad::DefQuad (integrand_fcn fcn, double ll, double ul, - const Vector& sing, double abs, double rel) - : Quad (fcn, abs, rel) -{ - lower_limit = ll; - upper_limit = ul; - singularities = sing; -} - double DefQuad::integrate (int& ier, int& neval, double& abserr) { @@ -193,33 +106,6 @@ return result; } -IndefQuad::IndefQuad (integrand_fcn fcn) : Quad (fcn) -{ - bound = 0.0; - type = bound_to_inf; -} - -IndefQuad::IndefQuad (integrand_fcn fcn, double b, IntegralType t) - : Quad (fcn) -{ - bound = b; - type = t; -} - -IndefQuad::IndefQuad (integrand_fcn fcn, double b, IntegralType t, - double abs, double rel) : Quad (fcn, abs, rel) -{ - bound = b; - type = t; -} - -IndefQuad::IndefQuad (integrand_fcn fcn, double abs, double rel) - : Quad (fcn, abs, rel) -{ - bound = 0.0; - type = bound_to_inf; -} - double IndefQuad::integrate (int& ier, int& neval, double& abserr) { @@ -264,80 +150,6 @@ return result; } -Quad_options::Quad_options (void) -{ - init (); -} - -Quad_options::Quad_options (double abs, double rel) -{ - x_absolute_tolerance = abs; - x_relative_tolerance = rel; -} - -Quad_options::Quad_options (const Quad_options& opt) -{ - copy (opt); -} - -Quad_options& -Quad_options::operator = (const Quad_options& opt) -{ - if (this != &opt) - copy (opt); - - return *this; -} - -Quad_options::~Quad_options (void) -{ -} - -void -Quad_options::init (void) -{ - double sqrt_eps = sqrt (DBL_EPSILON); - x_absolute_tolerance = sqrt_eps; - x_relative_tolerance = sqrt_eps; -} - -void -Quad_options::copy (const Quad_options& opt) -{ - x_absolute_tolerance = opt.x_absolute_tolerance; - x_relative_tolerance = opt.x_relative_tolerance; -} - -void -Quad_options::set_default_options (void) -{ - init (); -} - -void -Quad_options::set_absolute_tolerance (double val) -{ - x_absolute_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON); -} - -void -Quad_options::set_relative_tolerance (double val) -{ - x_relative_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON); -} - -double -Quad_options::absolute_tolerance (void) -{ - return x_absolute_tolerance; -} - -double -Quad_options::relative_tolerance (void) -{ - return x_relative_tolerance; -} - /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/liboctave/Quad.h +++ b/liboctave/Quad.h @@ -30,10 +30,6 @@ #include "dColVector.h" -#ifndef Vector -#define Vector ColumnVector -#endif - #if !defined (octave_Quad_typedefs) #define octave_Quad_typedefs 1 @@ -51,24 +47,53 @@ { public: - Quad_options (void); - Quad_options (double abs, double rel); - Quad_options (const Quad_options& opt); + Quad_options (void) { init (); } + + Quad_options (double abs, double rel) + { + x_absolute_tolerance = abs; + x_relative_tolerance = rel; + } + + Quad_options (const Quad_options& opt) { copy (opt); } - Quad_options& operator = (const Quad_options& opt); + Quad_options& operator = (const Quad_options& opt) + { + if (this != &opt) + copy (opt); - ~Quad_options (void); + return *this; + } + + ~Quad_options (void) { } - void init (void); - void copy (const Quad_options& opt); + void init (void) + { + double sqrt_eps = sqrt (DBL_EPSILON); + x_absolute_tolerance = sqrt_eps; + x_relative_tolerance = sqrt_eps; + } - void set_default_options (void); + void copy (const Quad_options& opt) + { + x_absolute_tolerance = opt.x_absolute_tolerance; + x_relative_tolerance = opt.x_relative_tolerance; + } - void set_absolute_tolerance (double); - void set_relative_tolerance (double); + void set_default_options (void) { init (); } + + void set_absolute_tolerance (double val) + { + x_absolute_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON); + } - double absolute_tolerance (void); - double relative_tolerance (void); + void set_relative_tolerance (double val) + { + x_relative_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON); + } + + double absolute_tolerance (void) { return x_absolute_tolerance; } + double relative_tolerance (void) { return x_relative_tolerance; } private: @@ -80,12 +105,30 @@ { public: - Quad (integrand_fcn fcn); - Quad (integrand_fcn fcn, double abs, double rel); + Quad (integrand_fcn fcn) { f = fcn; } + Quad (integrand_fcn fcn, double abs, double rel) + : Quad_options (abs, rel) { f = fcn; } + + virtual double integrate (void) + { + int ier, neval; + double abserr; + return integrate (ier, neval, abserr); + } - virtual double integrate (void); - virtual double integrate (int& ier); - virtual double integrate (int& ier, int& neval); + virtual double integrate (int& ier) + { + int neval; + double abserr; + return integrate (ier, neval, abserr); + } + + virtual double integrate (int& ier, int& neval) + { + double abserr; + return integrate (ier, neval, abserr); + } + virtual double integrate (int& ier, int& neval, double& abserr) = 0; protected: @@ -97,14 +140,55 @@ { public: - DefQuad (integrand_fcn fcn); - DefQuad (integrand_fcn fcn, double ll, double ul); - DefQuad (integrand_fcn fcn, double ll, double ul, double abs, double rel); - DefQuad (integrand_fcn fcn, double ll, double ul, const Vector& sing); - DefQuad (integrand_fcn fcn, const Vector& sing, double abs, double rel); - DefQuad (integrand_fcn fcn, const Vector& sing); - DefQuad (integrand_fcn fcn, double ll, double ul, const Vector& sing, - double abs, double rel); + DefQuad (integrand_fcn fcn) : Quad (fcn) + { + lower_limit = 0.0; + upper_limit = 1.0; + } + + DefQuad (integrand_fcn fcn, double ll, double ul) : Quad (fcn) + { + lower_limit = ll; + upper_limit = ul; + } + + DefQuad (integrand_fcn fcn, double ll, double ul, double abs, + double rel) : Quad (fcn, abs, rel) + { + lower_limit = ll; + upper_limit = ul; + } + + DefQuad (integrand_fcn fcn, double ll, double ul, + const ColumnVector& sing) : Quad (fcn) + { + lower_limit = ll; + upper_limit = ul; + singularities = sing; + } + + DefQuad (integrand_fcn fcn, const ColumnVector& sing, double abs, + double rel) : Quad (fcn, abs, rel) + { + lower_limit = 0.0; + upper_limit = 1.0; + singularities = sing; + } + + DefQuad (integrand_fcn fcn, const ColumnVector& sing) : Quad (fcn) + { + lower_limit = 0.0; + upper_limit = 1.0; + singularities = sing; + } + + DefQuad (integrand_fcn fcn, double ll, double ul, const ColumnVector& sing, + double abs, double rel) : Quad (fcn, abs, rel) + { + lower_limit = ll; + upper_limit = ul; + singularities = sing; + } double integrate (int& ier, int& neval, double& abserr); @@ -113,7 +197,7 @@ double lower_limit; double upper_limit; - Vector singularities; + ColumnVector singularities; }; class IndefQuad : public Quad @@ -122,11 +206,30 @@ enum IntegralType { bound_to_inf, neg_inf_to_bound, doubly_infinite }; - IndefQuad (integrand_fcn fcn); - IndefQuad (integrand_fcn fcn, double b, IntegralType t); + IndefQuad (integrand_fcn fcn) : Quad (fcn) + { + bound = 0.0; + type = bound_to_inf; + } + + IndefQuad (integrand_fcn fcn, double b, IntegralType t) : Quad (fcn) + { + bound = b; + type = t; + } + IndefQuad (integrand_fcn fcn, double b, IntegralType t, double abs, - double rel); - IndefQuad (integrand_fcn fcn, double abs, double rel); + double rel) : Quad (fcn, abs, rel) + { + bound = b; + type = t; + } + + IndefQuad (integrand_fcn fcn, double abs, double rel) : Quad (fcn, abs, rel) + { + bound = 0.0; + type = bound_to_inf; + } double integrate (int& ier, int& neval, double& abserr);
--- a/liboctave/Range.h +++ b/liboctave/Range.h @@ -35,15 +35,42 @@ class Range { public: - Range (void); - Range (const Range& r); - Range (double b, double l); - Range (double b, double l, double i); + Range (void) + { + rng_base = -1; + rng_limit = -1; + rng_inc = -1; + rng_nelem = -1; + } + + Range (const Range& r) + { + rng_base = r.rng_base; + rng_limit = r.rng_limit; + rng_inc = r.rng_inc; + rng_nelem = r.rng_nelem; + } - double base (void) const; - double limit (void) const; - double inc (void) const; - int nelem (void) const; + Range (double b, double l) + { + rng_base = b; + rng_limit = l; + rng_inc = 1; + rng_nelem = nelem_internal (); + } + + Range (double b, double l, double i) + { + rng_base = b; + rng_limit = l; + rng_inc = i; + rng_nelem = nelem_internal (); + } + + double base (void) const { return rng_base; } + double limit (void) const { return rng_limit; } + double inc (void) const { return rng_inc; } + int nelem (void) const { return rng_nelem; } Matrix matrix_value (void) const; @@ -52,9 +79,10 @@ void sort (void); - void set_base (double b); - void set_limit (double l); - void set_inc (double i); + void set_base (double b) { rng_base = b; } + void set_limit (double l) { rng_limit = l; } + void set_inc (double i) { rng_inc = i; } + friend ostream& operator << (ostream& os, const Range& r); friend istream& operator >> (istream& is, Range& r); @@ -70,51 +98,6 @@ int nelem_internal (void) const; }; -inline -Range::Range (void) -{ - rng_base = -1; - rng_limit = -1; - rng_inc = -1; - rng_nelem = -1; -} - -inline -Range::Range (const Range& r) -{ - rng_base = r.rng_base; - rng_limit = r.rng_limit; - rng_inc = r.rng_inc; - rng_nelem = r.rng_nelem; -} - -inline -Range::Range (double b, double l) -{ - rng_base = b; - rng_limit = l; - rng_inc = 1; - rng_nelem = nelem_internal (); -} - -inline -Range::Range (double b, double l, double i) -{ - rng_base = b; - rng_limit = l; - rng_inc = i; - rng_nelem = nelem_internal (); -} - -inline double Range::base (void) const { return rng_base; } -inline double Range::limit (void) const { return rng_limit; } -inline double Range::inc (void) const { return rng_inc; } -inline int Range::nelem (void) const { return rng_nelem; } - -inline void Range::set_base (double b) { rng_base = b; } -inline void Range::set_limit (double l) { rng_limit = l; } -inline void Range::set_inc (double i) { rng_inc = i; } - #endif /*
--- a/liboctave/dbleAEPBAL.h +++ b/liboctave/dbleAEPBAL.h @@ -38,15 +38,31 @@ public: - AEPBALANCE (void) {} + AEPBALANCE (void) { } - AEPBALANCE (const Matrix& a, const char *balance_job); + AEPBALANCE (const Matrix& a,const char * balance_job) + { + init (a, balance_job); + } + + AEPBALANCE (const AEPBALANCE& a) + { + balanced_mat = a.balanced_mat; + balancing_mat = a.balancing_mat; + } - AEPBALANCE (const AEPBALANCE& a); + AEPBALANCE& operator = (const AEPBALANCE& a) + { + balanced_mat = a.balanced_mat; + balancing_mat = a.balancing_mat; - AEPBALANCE& operator = (const AEPBALANCE& a); - Matrix balanced_matrix (void) const; - Matrix balancing_matrix (void) const; + return *this; + } + + Matrix balanced_matrix (void) const { return balanced_mat; } + + Matrix balancing_matrix (void) const { return balancing_mat; } + friend ostream& operator << (ostream& os, const AEPBALANCE& a); private: @@ -57,36 +73,6 @@ Matrix balancing_mat; }; -inline AEPBALANCE::AEPBALANCE (const Matrix& a,const char * balance_job) -{ - init (a, balance_job); -} - -inline AEPBALANCE::AEPBALANCE (const AEPBALANCE& a) -{ - balanced_mat = a.balanced_mat; - balancing_mat = a.balancing_mat; -} - -inline AEPBALANCE& -AEPBALANCE::operator = (const AEPBALANCE& a) -{ - balanced_mat = a.balanced_mat; - balancing_mat = a.balancing_mat; - - return *this; -} - -inline Matrix AEPBALANCE::balanced_matrix (void) const -{ - return balanced_mat; -} - -inline Matrix AEPBALANCE::balancing_matrix (void) const -{ - return balancing_mat; -} - #endif /*
--- a/liboctave/dbleCHOL.h +++ b/liboctave/dbleCHOL.h @@ -38,15 +38,23 @@ public: - CHOL (void) {} + CHOL (void) { } + + CHOL (const Matrix& a) { init (a); } - CHOL (const Matrix& a); - CHOL (const Matrix& a, int& info); + CHOL (const Matrix& a, int& info) { info = init (a); } + + CHOL (const CHOL& a) { chol_mat = a.chol_mat; } - CHOL (const CHOL& a); + CHOL& operator = (const CHOL& a) + { + chol_mat = a.chol_mat; - CHOL& operator = (const CHOL& a); - Matrix chol_matrix (void) const; + return *this; + } + + Matrix chol_matrix (void) const { return chol_mat; } + friend ostream& operator << (ostream& os, const CHOL& a); private: @@ -56,34 +64,6 @@ Matrix chol_mat; }; -inline CHOL::CHOL (const Matrix& a) -{ - init (a); -} - -inline CHOL::CHOL (const Matrix& a, int& info) -{ - info = init (a); -} - -inline CHOL::CHOL (const CHOL& a) -{ - chol_mat = a.chol_mat; -} - -inline CHOL& -CHOL::operator = (const CHOL& a) -{ - chol_mat = a.chol_mat; - - return *this; -} - -inline Matrix CHOL::chol_matrix (void) const -{ - return chol_mat; -} - #endif /*
--- a/liboctave/dbleDET.h +++ b/liboctave/dbleDET.h @@ -36,50 +36,44 @@ public: - DET (void); + DET (void) { } + + DET (const DET& a) + { + det[0] = a.det[0]; + det[1] = a.det[1]; + } - DET (const DET& a); + DET& operator = (const DET& a) + { + det[0] = a.det[0]; + det[1] = a.det[1]; - DET& operator = (const DET& a); + return *this; + } int value_will_overflow (void) const; int value_will_underflow (void) const; + double coefficient (void) const; + int exponent (void) const; + double value (void) const; friend ostream& operator << (ostream& os, const DET& a); private: - DET (const double *d); + DET (const double *d) + { + det[0] = d[0]; + det[1] = d[1]; + } double det [2]; }; -inline DET::DET (void) -{ -} - -inline DET::DET (const DET& a) -{ - det[0] = a.det[0]; - det[1] = a.det[1]; -} - -inline DET& DET::operator = (const DET& a) -{ - det[0] = a.det[0]; - det[1] = a.det[1]; - return *this; -} - -inline DET::DET (const double *d) -{ - det[0] = d[0]; - det[1] = d[1]; -} - #endif /*
--- a/liboctave/dbleGEPBAL.h +++ b/liboctave/dbleGEPBAL.h @@ -38,17 +38,40 @@ public: - GEPBALANCE (void) {} + GEPBALANCE (void) { } GEPBALANCE (const Matrix& a, const Matrix &, const char *balance_job); - GEPBALANCE (const GEPBALANCE& a); + + GEPBALANCE (const Matrix& a, const Matrix& b, const char * balance_job) + { + init (a, b, balance_job); + } + + GEPBALANCE (const GEPBALANCE& a) + { + balanced_a_mat = a.balanced_a_mat; + balanced_b_mat = a.balanced_b_mat; + left_balancing_mat = a.left_balancing_mat; + right_balancing_mat = a.right_balancing_mat; + } - GEPBALANCE& operator = (const GEPBALANCE& a); - Matrix balanced_a_matrix (void) const; - Matrix balanced_b_matrix (void) const; - Matrix left_balancing_matrix (void) const; - Matrix right_balancing_matrix (void) const; + GEPBALANCE& operator = (const GEPBALANCE& a) + { + balanced_a_mat = a.balanced_a_mat; + balanced_b_mat = a.balanced_b_mat; + left_balancing_mat = a.left_balancing_mat; + right_balancing_mat = a.right_balancing_mat; + + return *this; + } + + Matrix balanced_a_matrix (void) const { return balanced_a_mat; } + Matrix balanced_b_matrix (void) const { return balanced_b_mat; } + + Matrix left_balancing_matrix (void) const { return left_balancing_mat; } + Matrix right_balancing_matrix (void) const { return right_balancing_mat; } + friend ostream& operator << (ostream& os, const GEPBALANCE& a); private: @@ -61,51 +84,6 @@ Matrix right_balancing_mat; }; -inline GEPBALANCE::GEPBALANCE (const Matrix& a, const Matrix& b, - const char * balance_job) -{ - init (a, b, balance_job); -} - -inline GEPBALANCE::GEPBALANCE (const GEPBALANCE& a) -{ - balanced_a_mat = a.balanced_a_mat; - balanced_b_mat = a.balanced_b_mat; - left_balancing_mat = a.left_balancing_mat; - right_balancing_mat = a.right_balancing_mat; -} - -inline GEPBALANCE& -GEPBALANCE::operator = (const GEPBALANCE& a) -{ - balanced_a_mat = a.balanced_a_mat; - balanced_b_mat = a.balanced_b_mat; - left_balancing_mat = a.left_balancing_mat; - right_balancing_mat = a.right_balancing_mat; - - return *this; -} - -inline Matrix GEPBALANCE::balanced_a_matrix (void) const -{ - return balanced_a_mat; -} - -inline Matrix GEPBALANCE::balanced_b_matrix (void) const -{ - return balanced_b_mat; -} - -inline Matrix GEPBALANCE::left_balancing_matrix (void) const -{ - return left_balancing_mat; -} - -inline Matrix GEPBALANCE::right_balancing_matrix (void) const -{ - return right_balancing_mat; -} - #endif /*
--- a/liboctave/dbleHESS.h +++ b/liboctave/dbleHESS.h @@ -38,16 +38,33 @@ public: - HESS (void) {} + HESS (void) { } HESS (const Matrix& a); HESS (const Matrix&a, int& info); - HESS (const HESS& a); + HESS (const Matrix& a) { init (a); } + + HESS (const Matrix& a, int& info) { info = init (a); } + + HESS (const HESS& a) + { + hess_mat = a.hess_mat; + unitary_hess_mat = a.unitary_hess_mat; + } - HESS& operator = (const HESS& a); - Matrix hess_matrix (void) const; - Matrix unitary_hess_matrix (void) const; + HESS& operator = (const HESS& a) + { + hess_mat = a.hess_mat; + unitary_hess_mat = a.unitary_hess_mat; + + return *this; + } + + Matrix hess_matrix (void) const { return hess_mat; } + + Matrix unitary_hess_matrix (void) const { return unitary_hess_mat; } + friend ostream& operator << (ostream& os, const HESS& a); private: @@ -58,41 +75,6 @@ Matrix unitary_hess_mat; }; -inline HESS::HESS (const Matrix& a) -{ - init (a); -} - -inline HESS::HESS (const Matrix& a, int& info) -{ - info = init (a); -} - -inline HESS::HESS (const HESS& a) -{ - hess_mat = a.hess_mat; - unitary_hess_mat = a.unitary_hess_mat; -} - -inline HESS& -HESS::operator = (const HESS& a) -{ - hess_mat = a.hess_mat; - unitary_hess_mat = a.unitary_hess_mat; - - return *this; -} - -inline Matrix HESS::hess_matrix (void) const -{ - return hess_mat; -} - -inline Matrix HESS::unitary_hess_matrix (void) const -{ - return unitary_hess_mat; -} - #endif /*
--- a/liboctave/dbleLU.h +++ b/liboctave/dbleLU.h @@ -38,17 +38,31 @@ public: - LU (void) {} + LU (void) { } LU (const Matrix& a); - LU (const LU& a); - - LU& operator = (const LU& a); + LU (const LU& a) + { + l = a.l; + u = a.u; + p = a.p; + } - Matrix L (void) const; - Matrix U (void) const; - Matrix P (void) const; + LU& operator = (const LU& a) + { + l = a.l; + u = a.u; + p = a.p; + + return *this; + } + + Matrix L (void) const { return l; } + + Matrix U (void) const { return u; } + + Matrix P (void) const { return p; } friend ostream& operator << (ostream& os, const LU& a); @@ -59,36 +73,6 @@ Matrix p; }; -inline LU::LU (const LU& a) -{ - l = a.l; - u = a.u; - p = a.p; -} - -inline LU& LU::operator = (const LU& a) -{ - l = a.l; - u = a.u; - p = a.p; - return *this; -} - -inline Matrix LU::L (void) const -{ - return l; -} - -inline Matrix LU::U (void) const -{ - return u; -} - -inline Matrix LU::P (void) const -{ - return p; -} - #endif /*
--- a/liboctave/dbleQR.h +++ b/liboctave/dbleQR.h @@ -43,16 +43,27 @@ economy, }; - QR (void) {} + QR (void) { } QR (const Matrix& A, type qr_type = QR::std); - QR (const QR& a); + QR (const QR& a) + { + q = a.q; + r = a.r; + } - QR& operator = (const QR& a); + QR& operator = (const QR& a) + { + q = a.q; + r = a.r; - Matrix Q (void) const; - Matrix R (void) const; + return *this; + } + + Matrix Q (void) const { return q; } + + Matrix R (void) const { return r; } friend ostream& operator << (ostream& os, const QR& a); @@ -62,29 +73,6 @@ Matrix r; }; -inline QR::QR (const QR& a) -{ - q = a.q; - r = a.r; -} - -inline QR& QR::operator = (const QR& a) -{ - q = a.q; - r = a.r; - return *this; -} - -inline Matrix QR::Q (void) const -{ - return q; -} - -inline Matrix QR::R (void) const -{ - return r; -} - #endif /*
--- a/liboctave/dbleQRP.h +++ b/liboctave/dbleQRP.h @@ -36,15 +36,21 @@ { public: - QRP (void) {} + QRP (void) { } QRP (const Matrix& A, QR::type qr_type = QR::std); - QRP (const QRP& a); + QRP (const QRP& a) : QR (a) { p = a.p; } - QRP& operator = (const QRP& a); + QRP& operator = (const QRP& a) + { + QR::operator = (a); + p = a.p; - Matrix P (void) const; + return *this; + } + + Matrix P (void) const { return p; } friend ostream& operator << (ostream& os, const QRP& a); @@ -53,23 +59,6 @@ Matrix p; }; -inline QRP::QRP (const QRP& a) : QR (a) -{ - p = a.p; -} - -inline QRP& QRP::operator = (const QRP& a) -{ - QR::operator = (a); - p = a.p; - return *this; -} - -inline Matrix QRP::P (void) const -{ - return p; -} - #endif /*
--- a/liboctave/dbleSCHUR.h +++ b/liboctave/dbleSCHUR.h @@ -38,17 +38,32 @@ public: - SCHUR (void) {} + SCHUR (void) { } + + SCHUR (const Matrix& a, const char *ord) { init (a, ord); } - SCHUR (const Matrix& a, const char *ord); - SCHUR (const Matrix& a, const char *ord, int& info); + SCHUR (const Matrix& a, const char *ord, int& info) + { + info = init (a, ord); + } - SCHUR (const SCHUR& a); + SCHUR (const SCHUR& a) + { + schur_mat = a.schur_mat; + unitary_mat = a.unitary_mat; + } - SCHUR& operator = (const SCHUR& a); + SCHUR& operator = (const SCHUR& a) + { + schur_mat = a.schur_mat; + unitary_mat = a.unitary_mat; - Matrix schur_matrix (void) const; - Matrix unitary_matrix (void) const; + return *this; + } + + Matrix schur_matrix (void) const { return schur_mat; } + + Matrix unitary_matrix (void) const { return unitary_mat; } friend ostream& operator << (ostream& os, const SCHUR& a); @@ -60,41 +75,6 @@ Matrix unitary_mat; }; -inline SCHUR::SCHUR (const Matrix& a, const char *ord) -{ - init (a, ord); -} - -inline SCHUR::SCHUR (const Matrix& a, const char *ord, int& info) -{ - info = init (a, ord); -} - -inline SCHUR::SCHUR (const SCHUR& a) -{ - schur_mat = a.schur_mat; - unitary_mat = a.unitary_mat; -} - -inline SCHUR& -SCHUR::operator = (const SCHUR& a) -{ - schur_mat = a.schur_mat; - unitary_mat = a.unitary_mat; - - return *this; -} - -inline Matrix SCHUR::schur_matrix (void) const -{ - return schur_mat; -} - -inline Matrix SCHUR::unitary_matrix (void) const -{ - return unitary_mat; -} - #endif /*
--- a/liboctave/dbleSVD.h +++ b/liboctave/dbleSVD.h @@ -45,72 +45,49 @@ economy, }; - SVD (void) {} + SVD (void) { } + + + SVD (const Matrix& a, type svd_type) { init (a, svd_type); } - SVD (const Matrix& a, SVD::type svd_type = SVD::std); - SVD (const Matrix& a, int& info, SVD::type svd_type = SVD::std); + SVD (const Matrix& a, int& info, type svd_type) + { + info = init (a, svd_type); + } - SVD (const SVD& a); - - SVD& operator = (const SVD& a); + SVD (const SVD& a) + { + sigma = a.sigma; + left_sm = a.left_sm; + right_sm = a.right_sm; + } - DiagMatrix singular_values (void) const; - Matrix left_singular_matrix (void) const; - Matrix right_singular_matrix (void) const; + SVD& operator = (const SVD& a) + { + sigma = a.sigma; + left_sm = a.left_sm; + right_sm = a.right_sm; + + return *this; + } + + DiagMatrix singular_values (void) const { return sigma; } + + Matrix left_singular_matrix (void) const { return left_sm; } + + Matrix right_singular_matrix (void) const { return right_sm; } friend ostream& operator << (ostream& os, const SVD& a); private: - int init (const Matrix& a, SVD::type svd_type = SVD::std); + int init (const Matrix& a, type svd_type = std); DiagMatrix sigma; Matrix left_sm; Matrix right_sm; }; -inline SVD::SVD (const Matrix& a, SVD::type svd_type) -{ - init (a, svd_type); -} - -inline SVD::SVD (const Matrix& a, int& info, SVD::type svd_type) -{ - info = init (a, svd_type); -} - -inline SVD::SVD (const SVD& a) -{ - sigma = a.sigma; - left_sm = a.left_sm; - right_sm = a.right_sm; -} - -inline SVD& -SVD::operator = (const SVD& a) -{ - sigma = a.sigma; - left_sm = a.left_sm; - right_sm = a.right_sm; - - return *this; -} - -inline DiagMatrix SVD::singular_values (void) const -{ - return sigma; -} - -inline Matrix SVD::left_singular_matrix (void) const -{ - return left_sm; -} - -inline Matrix SVD::right_singular_matrix (void) const -{ - return right_sm; -} - #endif /*