# HG changeset patch # User jwe # Date 1095432339 0 # Node ID c2bb27ada496b190db379ffafdeab1dc46cded33 # Parent f8c27dad3643214387b36b8a3e2ae7a6a8c07890 [project @ 2004-09-17 14:45:39 by jwe] diff --git a/PROJECTS b/PROJECTS --- a/PROJECTS +++ b/PROJECTS @@ -165,14 +165,8 @@ Other Data Types: ---------------- - * New types (char, short, etc.). - - * 3d matrix stuff. - * Template functions for mixed-type ops. - * Stuff for arithmetic using charMatrix, intMatrix, etc. - ------------------------ Graphical User Interface: ------------------------ @@ -192,7 +186,7 @@ working on them, it would be good to support other size specifications (integer*2, etc.). - * Make load and save work for structures. + * Make fread and fopen look in LOADPATH for files. * Make load and save look for .mat if only given . @@ -239,6 +233,8 @@ will work as expected. + * Handle multi-line input at the keyboard/debug prompt correctly. + * Fix the parser so that if (expr) 'this is a string' end diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2004-09-17 David Bateman + + * CmplxSCHUR.cc (CmplxSCHUR::init): New arg, calc_unitary to make the + calculation of the unitary matrix optional. + * dbleSCHUR.cc (SCHUR::init): Ditto. + * CmplxSCHUR.h, dbleSCHUR.h: Update decls. + 2004-09-15 David Bateman * oct-sort.h (octave_sort::set_compare (bool (*comp) (T, T))): diff --git a/liboctave/CmplxSCHUR.cc b/liboctave/CmplxSCHUR.cc --- a/liboctave/CmplxSCHUR.cc +++ b/liboctave/CmplxSCHUR.cc @@ -61,7 +61,8 @@ } int -ComplexSCHUR::init (const ComplexMatrix& a, const std::string& ord) +ComplexSCHUR::init (const ComplexMatrix& a, const std::string& ord, + bool calc_unitary) { int a_nr = a.rows (); int a_nc = a.cols (); @@ -76,10 +77,15 @@ // Workspace requirements may need to be fixed if any of the // following change. - char jobvs = 'V'; + char jobvs; char sense = 'N'; char sort = 'N'; + if (calc_unitary) + jobvs = 'V'; + else + jobvs = 'N'; + char ord_char = ord.empty () ? 'U' : ord[0]; if (ord_char == 'A' || ord_char == 'D' || ord_char == 'a' || ord_char == 'd') @@ -100,7 +106,8 @@ double rcondv; schur_mat = a; - unitary_mat.resize (n, n); + if (calc_unitary) + unitary_mat.resize (n, n); Complex *s = schur_mat.fortran_vec (); Complex *q = unitary_mat.fortran_vec (); diff --git a/liboctave/CmplxSCHUR.h b/liboctave/CmplxSCHUR.h --- a/liboctave/CmplxSCHUR.h +++ b/liboctave/CmplxSCHUR.h @@ -40,17 +40,13 @@ ComplexSCHUR (void) : schur_mat (), unitary_mat () { } - ComplexSCHUR (const ComplexMatrix& a, const std::string& ord) - : schur_mat (), unitary_mat () - { - init (a, ord); - } + ComplexSCHUR (const ComplexMatrix& a, const std::string& ord, + bool calc_unitary = true) + : schur_mat (), unitary_mat () { init (a, ord, calc_unitary); } - ComplexSCHUR (const ComplexMatrix& a, const std::string& ord, int& info) - : schur_mat (), unitary_mat () - { - info = init (a,ord); - } + ComplexSCHUR (const ComplexMatrix& a, const std::string& ord, int& info, + bool calc_unitary = true) + : schur_mat (), unitary_mat () { info = init (a, ord, calc_unitary); } ComplexSCHUR (const ComplexSCHUR& a) : schur_mat (a.schur_mat), unitary_mat (a.unitary_mat) { } @@ -82,7 +78,7 @@ select_function selector; - int init (const ComplexMatrix& a, const std::string& ord); + int init (const ComplexMatrix& a, const std::string& ord, bool calc_unitary); }; #endif diff --git a/liboctave/dbleSCHUR.cc b/liboctave/dbleSCHUR.cc --- a/liboctave/dbleSCHUR.cc +++ b/liboctave/dbleSCHUR.cc @@ -63,7 +63,7 @@ } int -SCHUR::init (const Matrix& a, const std::string& ord) +SCHUR::init (const Matrix& a, const std::string& ord, bool calc_unitary) { int a_nr = a.rows (); int a_nc = a.cols (); @@ -77,10 +77,15 @@ // Workspace requirements may need to be fixed if any of the // following change. - char jobvs = 'V'; + char jobvs; char sense = 'N'; char sort = 'N'; + if (calc_unitary) + jobvs = 'V'; + else + jobvs = 'N'; + char ord_char = ord.empty () ? 'U' : ord[0]; if (ord_char == 'A' || ord_char == 'D' || ord_char == 'a' || ord_char == 'd') @@ -102,7 +107,9 @@ double rcondv; schur_mat = a; - unitary_mat.resize (n, n); + + if (calc_unitary) + unitary_mat.resize (n, n); double *s = schur_mat.fortran_vec (); double *q = unitary_mat.fortran_vec (); diff --git a/liboctave/dbleSCHUR.h b/liboctave/dbleSCHUR.h --- a/liboctave/dbleSCHUR.h +++ b/liboctave/dbleSCHUR.h @@ -40,17 +40,12 @@ SCHUR (void) : schur_mat (), unitary_mat () { } - SCHUR (const Matrix& a, const std::string& ord) - : schur_mat (), unitary_mat () - { - init (a, ord); - } + SCHUR (const Matrix& a, const std::string& ord, bool calc_unitary = true) + : schur_mat (), unitary_mat () { init (a, ord, calc_unitary); } - SCHUR (const Matrix& a, const std::string& ord, int& info) - : schur_mat (), unitary_mat () - { - info = init (a, ord); - } + SCHUR (const Matrix& a, const std::string& ord, int& info, + bool calc_unitary = true) + : schur_mat (), unitary_mat () { info = init (a, ord, calc_unitary); } SCHUR (const SCHUR& a) : schur_mat (a.schur_mat), unitary_mat (a.unitary_mat) { } @@ -82,7 +77,7 @@ select_function selector; - int init (const Matrix& a, const std::string& ord); + int init (const Matrix& a, const std::string& ord, bool calc_unitary); }; #endif diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2004-09-17 David Bateman + + * DLD-FUNCTIONS/det.cc (Fdet): Only compute estimate of the + condition number if requested as output. + + * DLD-FUNCTIONS/schur.cc (Fschur): Only compute unitary matrix if + requested as output. + 2004-09-17 John W. Eaton * ov-fcn-inline.cc (octave_fcn_inline::octave_fcn_inline): diff --git a/src/DLD-FUNCTIONS/det.cc b/src/DLD-FUNCTIONS/det.cc --- a/src/DLD-FUNCTIONS/det.cc +++ b/src/DLD-FUNCTIONS/det.cc @@ -82,12 +82,18 @@ int info; double rcond = 0.0; - DET det = m.determinant (info, rcond); if (nargout > 1) - retval(1) = rcond; - - retval(0) = (info == -1 ? 0.0 : det.value ()); + { + DET det = m.determinant (info, rcond); + retval(1) = rcond; + retval(0) = (info == -1 ? 0.0 : det.value ()); + } + else + { + DET det = m.determinant (info); + retval(0) = (info == -1 ? 0.0 : det.value ()); + } } } else if (arg.is_complex_type ()) @@ -99,12 +105,17 @@ int info; double rcond = 0.0; - ComplexDET det = m.determinant (info, rcond); - if (nargout > 1) - retval(1) = rcond; - - retval(0) = (info == -1 ? Complex (0.0) : det.value ()); + { + ComplexDET det = m.determinant (info, rcond); + retval(1) = rcond; + retval(0) = (info == -1 ? Complex (0.0) : det.value ()); + } + else + { + ComplexDET det = m.determinant (info); + retval(0) = (info == -1 ? Complex (0.0) : det.value ()); + } } } else diff --git a/src/DLD-FUNCTIONS/schur.cc b/src/DLD-FUNCTIONS/schur.cc --- a/src/DLD-FUNCTIONS/schur.cc +++ b/src/DLD-FUNCTIONS/schur.cc @@ -300,14 +300,14 @@ if (! error_state) { - SCHUR result (tmp, ord); - if (nargout == 0 || nargout == 1) { + SCHUR result (tmp, ord, false); retval(0) = result.schur_matrix (); } else { + SCHUR result (tmp, ord, true); retval(1) = result.schur_matrix (); retval(0) = result.unitary_matrix (); } @@ -319,14 +319,15 @@ if (! error_state) { - ComplexSCHUR result (ctmp, ord); if (nargout == 0 || nargout == 1) { + ComplexSCHUR result (ctmp, ord, false); retval(0) = result.schur_matrix (); } else { + ComplexSCHUR result (ctmp, ord, true); retval(1) = result.schur_matrix (); retval(0) = result.unitary_matrix (); }