Mercurial > hg > octave-nkf
changeset 5008:c2bb27ada496
[project @ 2004-09-17 14:45:39 by jwe]
author | jwe |
---|---|
date | Fri, 17 Sep 2004 14:45:39 +0000 |
parents | f8c27dad3643 |
children | 000cfedea91c |
files | PROJECTS liboctave/ChangeLog liboctave/CmplxSCHUR.cc liboctave/CmplxSCHUR.h liboctave/dbleSCHUR.cc liboctave/dbleSCHUR.h src/ChangeLog src/DLD-FUNCTIONS/det.cc src/DLD-FUNCTIONS/schur.cc |
diffstat | 9 files changed, 75 insertions(+), 47 deletions(-) [+] |
line wrap: on
line diff
--- 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 <file>.mat if only given <file>. @@ -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
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2004-09-17 David Bateman <dbateman@free.fr> + + * 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 <dbateman@free.fr> * oct-sort.h (octave_sort<T>::set_compare (bool (*comp) (T, T))):
--- 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 ();
--- 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
--- 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 ();
--- 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
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2004-09-17 David Bateman <dbateman@free.fr> + + * 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 <jwe@octave.org> * ov-fcn-inline.cc (octave_fcn_inline::octave_fcn_inline):
--- 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
--- 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 (); }